38 auto t6 = ws->
addJobFromString(
"bmult=" + to_string(b) +
"; solve transport min z use lp; ms=transport.modelstat; ss=transport.solvestat;", cp);
42 lock_guard<mutex> lck(*ioMutex);
43 cout <<
"Scenario bmult=" << b <<
":" << endl;
44 cout <<
" Modelstatus: " << t6.outDB().getParameter(
"ms").findRecord().value() << endl;
45 cout <<
" Solvestatus: " << t6.outDB().getParameter(
"ss").findRecord().value() << endl;
46 cout <<
" Obj: " << t6.outDB().getVariable(
"z").findRecord().level() << endl;
53 " i canning plants / seattle, san-diego / \n"
54 " j markets / new-york, chicago, topeka / ; \n"
58 " a(i) capacity of plant i in cases \n"
62 " b(j) demand at market j in cases \n"
67 "Table d(i, j) distance in thousands of miles \n"
68 " new-york chicago topeka \n"
69 " seattle 2.5 1.7 1.8 \n"
70 " san-diego 2.5 1.8 1.4; \n"
72 "Scalar f freight in dollars per case per thousand miles / 90 / ; \n"
73 "Scalar bmult demand multiplier / 1 / ; \n"
75 "Parameter c(i, j) transport cost in thousands of dollars per case; \n"
77 "c(i, j) = f * d(i, j) / 1000; \n"
80 " x(i, j) shipment quantities in cases \n"
81 " z total transportation costs in thousands of dollars; \n"
83 "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= bmult*b(j); \n"
96 "Model transport / all / ; \n"
97 "Scalar ms 'model status', ss 'solve status' \n";
106int main(
int argc,
char* argv[])
108 cout <<
"---------- Transport 6 --------------" << endl;
120 vector<double> bmultlist = { 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3 };
125 for(
double b : bmultlist)
126 v.emplace_back([&ws, cp, &ioMutex, b]{
runScenario(&ws, cp, &ioMutex, b);});
131 cout <<
"GAMSException occured: " << ex.what() << endl;
132 }
catch (exception &ex) {
133 cout << ex.what() << endl;
void setSystemDirectory(std::string systemDir)
GAMSJob addJobFromString(const std::string &gamsSource, const std::string &jobName="")
string getModelText()
Get model as string.
void runScenario(GAMSWorkspace *ws, const GAMSCheckpoint &cp, mutex *ioMutex, double b)
Run the job with a different scenario.