Page 1 of 1

Altering the standard transportation problem

Posted: Wed Aug 15, 2018 5:45 pm
by P.Ganss
Hello everyone,

I am trying to alter the standard transportation problem from the model library. I want to include several more "producers" and "markets" into the problem and define their distance in the d(i,j) matrix.
Here I run into my problem: I have a working excel import to get all the values for the distance matrix and to define the parameters a(i) and b(i), but I want certain connections to be non existent and their distance to bet set as zero (You cant ship from San-Diego to Topeka for example). I tried if and $ functions but everytime the solution remains 0 and I cant figure out my mistake. The program works with with other values for those distances and the solution seems to be fine.

Short: Where and how do I have to set the $ or an if function so the algorithm isnt considering those connections?

Thanks in advance!

Re: Altering the standard transportation problem

Posted: Thu Aug 16, 2018 5:41 am
by GabrielYin
Suggest you to post your code which others can run, either using BBcode or attachment :) Then we are more convenient and comprehensive to help you!

Best,
Gabriel

Re: Altering the standard transportation problem

Posted: Thu Aug 16, 2018 5:03 pm
by cbhomia
Hi,

The fact that your solution is zero makes sense if you set some distances to zero. You are minimizing cost, which is proportional to the distance between plant i and market j. If the distance for an (i,j) pair is zero, there is no cost involved in transporting product between those two. Hence minimization returns zero.

You can create another parameter valid(i,j), which is mapping of the (i,j) with 1 and 0.
1 means the transportation is valid. 0 means not valid. For your case, table may look like this

Table valid(i,j) 'if the transportation is valid'
new-york chicago topeka
seattle 1 1 1
san-diego 1 1
;
with equations subjected to valid (i,j)
supply(i).. sum(j$valid(i,j), x(i,j)) =l= a(i);
demand(j).. sum(i$valid(i,j), x(i,j)) =g= b(j);

Hope this helps.
Alternatively, you can place an upper bound on x(i,j) value of a pair

x.up(i,j)$(not valid(i,j)) =0;

Best,
Chintan

Re: Altering the standard transportation problem

Posted: Sat Aug 18, 2018 11:44 am
by P.Ganss
GabrielYin wrote: 5 years ago Suggest you to post your code which others can run, either using BBcode or attachment :) Then we are more convenient and comprehensive to help you!

Best,
Gabriel
Hi Gabriel,

Since I did not made any major changes towards the well known transportation problem I guessed my code would not give any much further information.
cbhomia wrote: 5 years ago Table valid(i,j) 'if the transportation is valid'
new-york chicago topeka
seattle 1 1 1
san-diego 1 1
;
with equations subjected to valid (i,j)
supply(i).. sum(j$valid(i,j), x(i,j)) =l= a(i);
demand(j).. sum(i$valid(i,j), x(i,j)) =g= b(j);
Perfect this helped!!