37 " i canning plants / seattle, san-diego / \n"
38 " j markets / new-york, chicago, topeka / ; \n"
41 " a(i) capacity of plant i in cases \n"
45 " b(j) demand at market j in cases \n"
50 "Table d(i,j) distance in thousands of miles \n"
51 " new-york chicago topeka \n"
52 " seattle 2.5 1.7 1.8 \n"
53 " san-diego 2.5 1.8 1.4 ; \n"
55 "Scalar f freight in dollars per case per thousand miles /90/;\n";
62 " i canning plants \n"
66 " a(i) capacity of plant i in cases \n"
67 " b(j) demand at market j in cases \n"
68 " d(i,j) distance in thousands of miles \n"
69 "Scalar f freight in dollars per case per thousand miles; \n"
71 "$if not set incname $abort 'no include file name for data file provided'\n"
72 "$include %incname% \n"
74 " Parameter c(i,j) transport cost in thousands of dollars per case ; \n"
76 " c(i,j) = f * d(i,j) / 1000 ; \n"
79 " x(i,j) shipment quantities in cases \n"
80 " z total transportation costs in thousands of dollars ; \n"
82 " Positive Variable x ; \n"
86 " cost define objective function \n"
87 " supply(i) observe supply limit at plant i \n"
88 " demand(j) satisfy demand at market j ; \n"
90 " cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ; \n"
92 " supply(i) .. sum(j, x(i,j)) =l= a(i) ; \n"
94 " demand(j) .. sum(i, x(i,j)) =g= b(j) ; \n"
96 " Model transport /all/ ; \n"
98 " Solve transport using lp minimizing z ; \n"
100 "Display x.l, x.m ; \n";
108int main(
int argc,
char* argv[])
110 cout <<
"---------- Transport 2 --------------" << endl;
119 ofstream tdata(ws.workingDirectory() + cPathSep +
"tdata.gms");
129 cout <<
"x(" << rec.key(0) <<
"," << rec.key(1) <<
"):" <<
" level=" << rec.level() <<
" marginal="
130 << rec.marginal() << endl;
133 cout <<
"GAMSException occured: " << ex.what() << endl;
134 }
catch (exception &ex) {
135 cout << ex.what() << endl;
GAMSVariable getVariable(const std::string &name)
void setDefine(const std::string &key, const std::string &value)
void setSystemDirectory(std::string systemDir)
string getDataText()
Get data as string.
string getModelText()
Get model as string.