SQL2GMS - GAMS
SQL2GMS - GAMS
SQL2GMS - GAMS
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
28<br />
<strong>SQL2GMS</strong><br />
set j /<br />
$include j.inc<br />
/;<br />
parameter demand /<br />
$include demand.inc<br />
/;<br />
parameter supply /<br />
$include supply.inc<br />
/;<br />
parameter dist /<br />
$include dist.inc<br />
/;<br />
display i,j,demand,supply,dist;<br />
Step 1: sr1.gms<br />
$ontext<br />
step 1: data manipulation step<br />
execute as: > gams sr1 restart=s0 save=s1<br />
$offtext<br />
Scalar f 'freight in dollars per case per thousand miles' /90/ ;<br />
Parameter c(i,j) 'transport cost in thousands of dollars per case';<br />
c(i,j) = f * dist(i,j) / 1000 ;<br />
Step 2: sr2.gms<br />
$ontext<br />
step 2: model definition<br />
execute as: > gams sr2 restart=s1 save=s2<br />
$offtext<br />
Variables<br />
x(i,j) 'shipment quantities in cases'<br />
z 'total transportation costs in thousands of dollars' ;<br />
Positive Variable x ;<br />
Equations<br />
ecost 'define objective function'<br />
esupply(i) 'observe supply limit at plant i'<br />
edemand(j) 'satisfy demand at market j' ;<br />
ecost .. z =e= sum((i,j), c(i,j)*x(i,j)) ;<br />
esupply(i) .. sum(j, x(i,j)) =l= supply(i) ;<br />
edemand(j) .. sum(i, x(i,j)) =g= demand(j) ;<br />
Step 3: sr3.gms<br />
$ontext<br />
© 2010 <strong>GAMS</strong> Development Coorporation