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 SanDiego 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!
Altering the standard transportation problem

 User
 Posts: 43
 Joined: 6 months ago
 Location: Dallas, TX, USA
Re: Altering the standard transportation problem
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
Best,
Gabriel
Re: Altering the standard transportation problem
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'
newyork chicago topeka
seattle 1 1 1
sandiego 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
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'
newyork chicago topeka
seattle 1 1 1
sandiego 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
Hi Gabriel,GabrielYin wrote: ↑1 month agoSuggest 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
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.
Perfect this helped!!