原书上的代码:
$Title The Transportation Problem of Linear Programming
Sets
i canning plants /Seattle,SanDiego/
j markets /NewYork,Chicago,Detroit/;
Parameters
a(i) capacity of plant i in cases
/Seattle 350
SanDiego 600/
b(j) demand at market j in cases
/NewYork 325
Chicago 300
Detroit 275/;
Table d(i,j) distance in thousands of miles
NewYork Chicago Detroit
Seattle 2.5 1.7 1.8
SanDiego 2.5 1.8 1.4
Scalar f in dollars per thousand miles /90/;
Parameter c(i,j) transpor cost in 1000s of dollars per cases;
c(i,j) = f*d(i,j)/1000;
Variables
x(i,j) shipment quantities in cases
z total transportation costs in 1000s of dollars;
Positive Variable x;
Equation
cost define objective function
supply(i) observe supply limit at plant i
demand(j) satisly demand at market j;
cost.. z =e= sum((i,j),c(i,j)*x(i,j));
supply(i).. sum(j,x(i,j)) =l= a(i);
demand(j).. sum(i,x(i,j)) =g= b(j);
Model transport /all/;
solve transport using lp minimizing z;
display x.l,x.m;