Altering the standard transportation problem

Problems with modeling
Post Reply
P.Ganss
User
User
Posts: 4
Joined: 3 months ago

Altering the standard transportation problem

Post by P.Ganss » 3 months ago

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!

GabrielYin
User
User
Posts: 53
Joined: 8 months ago
Location: Dallas, TX, USA

Re: Altering the standard transportation problem

Post by GabrielYin » 3 months 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

cbhomia
User
User
Posts: 8
Joined: 5 months ago

Re: Altering the standard transportation problem

Post by cbhomia » 3 months ago

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

P.Ganss
User
User
Posts: 4
Joined: 3 months ago

Re: Altering the standard transportation problem

Post by P.Ganss » 3 months ago

GabrielYin wrote:
3 months 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:
3 months 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!!

Post Reply