$ontext
LP model to be called by tr4_run.m and tr5_run.m.
In this model we assume the sets and parameters defining the LP are read
from GDX and the solution written back to GDX
$offtext
$if NOT set INFILE $set INFILE inputData
$if NOT set OUTFILE $set OUTFILE solutionData
sets
i 'canning plants'
j 'markets'
;
parameters
a(i) 'capacity of plant i in cases'
b(j) 'demand at market j in cases'
d(i,j) 'distance in thousands of miles'
f 'freight in dollars per case per thousand miles'
c(i,j) 'transport cost in thousands of dollars per case'
;
$gdxin %INFILE%
$load i j a b d f
$gdxin
c(i,j) = f * d(i,j) / 1000 ;
positive variables x(i,j) shipment quantities in cases;
free variable z total transportation costs in thousands of dollars;
equations
cost define objective function
supply(i) observe supply limit at plant i
demand(j) satisfy 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;
scalars modelStat, solveStat;
modelStat = transport.modelstat;
solveStat = transport.solvestat;
execute_unload '%OUTFILE%', modelStat, solveStat, z, x;