Talk:Transportation problem: Difference between revisions

From Rosetta Code
Content added Content deleted
(+ note about the Java/D Versions)
Line 19: Line 19:


I have found the function getClosedPath() not easy to understand and semantically a little complex (and bug prone to translate). So can you comment the parts of getClosedPath() to help me write simpler D code, or can you restructure it to make its workings more linear (in D I've used three different 'stones' variables inside it, including a dup-ping)?
I have found the function getClosedPath() not easy to understand and semantically a little complex (and bug prone to translate). So can you comment the parts of getClosedPath() to help me write simpler D code, or can you restructure it to make its workings more linear (in D I've used three different 'stones' variables inside it, including a dup-ping)?
: Yes, I was planning to add a comment there, it's not very clear. I think you're supposed to use a breath-first or depth-first search, but it occurred to me that if you remove all the "stones" that do not have a horizontal AND vertical neighbor (and therefore cannot be corner-stones) you will be left with the stones that form the closed path. (Removing stones is done in a infinite loop because certain stones will only be removed after you've removed another.) Then you have to put the remaining stones in the correct plus-minus order. (See also the link to the stepping stone explanation). [[User:Fwend|Fwend]] ([[User talk:Fwend|talk]]) 21:28, 6 November 2014 (UTC)

Revision as of 21:28, 6 November 2014

It is pretty interesting the task. Why no one wants to try to make solutions in the own language? Русский (talk) 20:02, 24 August 2013 (UTC)

Hi Русский, for me, the problem is that I cannot easily see an algorithm to solve the problem and cannot read the non-english example to produce an example in Python for example. --Paddy3118 (talk) 18:56, 25 August 2013 (UTC)
But it's a classic of linear programming, which is studied in any technical college. Русский (talk) 11:11, 27 August 2013 (UTC)
I've been too busy with (many!) other things for much Rosetta Code problem solving. I've only been doing things the past few days because I've had some time off work (long weekend/public holiday/:-) :-) :-)). –Donal Fellows (talk) 21:51, 25 August 2013 (UTC)
  • So, added the implementation in the language with English lexical base. Now the algorithm will be more clear. It is based on the construction of the redistribution cycle. It is a closed line connecting certain way the occupied cells of the distribution plan. After building the cycle and redistributing the supplies, the procedure is repeated until you reach the optimal supply plan. Русский (talk) 08:38, 25 January 2014 (UTC)
  • Maybe should add a more detailed description of the algorithm of solving this problem? Русский (talk) 09:45, 9 February 2014 (UTC)

Task Description

I suggest this task is shortened by assuming the starting point is a good initial basis for a feasible solution. Code for the NW allocation would then not be required given that other methods for generating an initial basis are available--Nigel Galloway (talk) 11:52, 18 September 2014 (UTC)

I fail to see the benefit. The NW method is too simple to be given its own task page, so it's nice to have it included in this one. More sophisticated methods can be handled in separate tasks and we can link to them from here. Fwend (talk) 12:47, 18 September 2014 (UTC)
Also I think it's better for testing purposes if the initial feasible solution is off the mark. That way your optimal solution routine is more pressured to produce a correct result than when you have an estimate that may already be correct to begin with. Fwend (talk) 13:16, 18 September 2014 (UTC)

Regarding The Java/D Versions

I have converted the Java version to D language. I've used a class Shipment as in the Java code. Perhaps there are good enough ways to use values (a matrix of structs) instead, and reduce indirections.

I have found the function getClosedPath() not easy to understand and semantically a little complex (and bug prone to translate). So can you comment the parts of getClosedPath() to help me write simpler D code, or can you restructure it to make its workings more linear (in D I've used three different 'stones' variables inside it, including a dup-ping)?

Yes, I was planning to add a comment there, it's not very clear. I think you're supposed to use a breath-first or depth-first search, but it occurred to me that if you remove all the "stones" that do not have a horizontal AND vertical neighbor (and therefore cannot be corner-stones) you will be left with the stones that form the closed path. (Removing stones is done in a infinite loop because certain stones will only be removed after you've removed another.) Then you have to put the remaining stones in the correct plus-minus order. (See also the link to the stepping stone explanation). Fwend (talk) 21:28, 6 November 2014 (UTC)