37 job(fws.addJobFromString(getModelSource())),
38 fopt(fws.addOptions())
47 fopt.setAllModelTypes(
"Cplex");
48 fopt.setDefine(
"dbOut1",
"dbOut1");
50 fi = fDbIn1.
addSet(
"i",
"canning plants");
51 fj = fDbIn1.addSet(
"j",
"markets");
52 fa = fDbIn1.addParameter(
"a",
"capacity of plant i in cases", fi);
53 fb = fDbIn1.addParameter(
"b",
"demand at market j in cases", fj);
54 fd = fDbIn1.addParameter(
"d",
"distance in thousands of miles", fi, fj);
55 ff = fDbIn2.addParameter(
"f",
"freight in dollars per case per thousand miles");
62 if (!fDbIn1.checkDomains())
64 if (!fDbIn2.checkDomains())
67 vector<GAMSDatabase> dbs {fDbIn1, fDbIn2};
68 job.run(fopt, checkpoint, output,
false, dbs);
70 fDbOut1 = fws.addDatabaseFromGDX(fopt.getDefine(
"dbOut1") +
".gdx");
71 fx = fDbOut1.getVariable(
"x");
72 fz = fDbOut1.getVariable(
"z");
75string Transport::getModelSource()
78 " i canning plants \n"
82 " a(i) capacity of plant i in cases \n"
83 " b(j) demand at market j in cases \n"
84 " d(i,j) distance in thousands of miles \n"
85 " Scalar f freight in dollars per case per thousand miles; \n"
87 "$if not set dbIn1 $abort 'no file name for in-database 1 file provided' \n"
91 "$if not set dbIn2 $abort 'no file name for in-database 2 file provided' \n"
96 " Parameter c(i,j) transport cost in thousands of dollars per case ; \n"
98 " c(i,j) = f * d(i,j) / 1000 ; \n"
101 " x(i,j) shipment quantities in cases \n"
102 " z total transportation costs in thousands of dollars ; \n"
104 " Positive Variable x ; \n"
107 " cost define objective function \n"
108 " supply(i) observe supply limit at plant i \n"
109 " demand(j) satisfy demand at market j ; \n"
111 " cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ; \n"
113 " supply(i) .. sum(j, x(i,j)) =l= a(i) ; \n"
115 " demand(j) .. sum(i, x(i,j)) =g= b(j) ; \n"
117 " Model transport /all/ ; \n"
119 " Solve transport using lp minimizing z ; \n"
121 "$if not set dbOut1 $abort 'no file name for out-database 1 file provided' \n"
122 " execute_unload '%dbOut1%', x, z; \n";
GAMSSet addSet(const std::string &name, const int dimension, const std::string &explanatoryText="", GAMSEnum::SetType setType=GAMSEnum::SetType::Multi)
GAMSJob addJobFromString(const std::string &gamsSource, const std::string &jobName="")
GAMSDatabase addDatabase(const std::string &databaseName="", const std::string &inModelName="")
Wrapper class definition for GAMS trnsport model.