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"
56 "Scalar bmult demand multiplier /1/; \n"
58 "Parameter c(i,j) transport cost in thousands of dollars per case ; \n"
60 " c(i,j) = f * d(i,j) / 1000 ; \n"
63 " x(i,j) shipment quantities in cases \n"
64 " z total transportation costs in thousands of dollars ; \n"
66 "Positive Variable x ; \n"
69 " cost define objective function \n"
70 " supply(i) observe supply limit at plant i \n"
71 " demand(j) satisfy demand at market j ; \n"
73 "cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ; \n"
75 "supply(i) .. sum(j, x(i,j)) =l= a(i) ; \n"
77 "demand(j) .. sum(i, x(i,j)) =g= bmult*b(j) ; \n"
79 "Model transport /all/ ; \n"
80 "Scalar ms 'model status', ss 'solve status'; \n";
89int main(
int argc,
char* argv[])
91 cout <<
"---------- Transport 5 --------------" << endl;
103 vector<double> bmultlist = { 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3 };
106 for (
double b : bmultlist)
108 GAMSJob t5 = ws.addJobFromString(
"bmult=" + to_string(b) +
"; solve transport min z use lp; ms=transport.modelstat; ss=transport.solvestat;", cp);
110 cout <<
"Scenario bmult=" << b <<
":" << endl;
117 cout <<
"GAMSException occured: " << ex.what() << endl;
118 }
catch (exception &ex) {
119 cout << ex.what() << endl;
GAMSParameter getParameter(const std::string &name)
GAMSVariable getVariable(const std::string &name)
GAMSParameterRecord findRecord(const std::vector< std::string > &keys)
GAMSVariableRecord findRecord(const std::vector< std::string > &keys)
void setSystemDirectory(std::string systemDir)
string getModelText()
Get model as string.