40 " i(*) canning plants / / \n"
41 " j(*) markets / / \n"
44 " a(i) capacity of plant i in cases / / \n"
45 " b(j) demand at market j in cases / / \n"
46 " d(i,j) distance in thousands of miles / / \n"
47 " Scalar f freight in dollars per case per thousand miles /0/; \n"
49 " Parameter c(i,j) transport cost in thousands of dollars per case ; \n"
51 " c(i,j) = f * d(i,j) / 1000 ; \n"
54 " x(i,j) shipment quantities in cases \n"
55 " z total transportation costs in thousands of dollars ; \n"
57 " Positive Variable x ; \n"
60 " cost define objective function \n"
61 " supply(i) observe supply limit at plant i \n"
62 " demand(j) satisfy demand at market j ; \n"
64 " cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ; \n"
66 " supply(i) .. sum(j, x(i,j)) =l= a(i) ; \n"
68 " demand(j) .. sum(i, x(i,j)) =g= b(j) ; \n"
70 " Model transport /all/ ; \n"
72 " Solve transport using lp minimizing z ; \n";
78 return "$if not set gdxincname $abort 'no include file name for data file provided'\n"
79 "$gdxin %gdxincname% \n"
81 "$load i j a b d f \n"
84 " Display x.l, x.m ; \n";
110int main(
int argc,
char* argv[])
112 cout <<
"---------- Transport 11 --------------" << endl;
117 std::string cpName =
"tbase";
121 vector<string> plants {
"Seattle",
"San-Diego" };
122 vector<string> markets {
"New-York",
"Chicago",
"Topeka" };
123 map<string, double> capacity {
124 {
"Seattle", 350.0 }, {
"San-Diego", 600.0 }
126 map<string, double> demand {
127 {
"New-York", 325.0 }, {
"Chicago", 300.0 }, {
"Topeka", 275.0 }
129 map<tuple<string,string>,
double> distance {
130 { make_tuple(
"Seattle",
"New-York"), 2.5 },
131 { make_tuple(
"Seattle",
"Chicago"), 1.7 },
132 { make_tuple(
"Seattle",
"Topeka"), 1.8 },
133 { make_tuple(
"San-Diego",
"New-York"), 2.5 },
134 { make_tuple(
"San-Diego",
"Chicago"), 1.8 },
135 { make_tuple(
"San-Diego",
"Topeka"), 1.4 }
143 ws.gamsLib(
"trnsport");
149 for (
auto plant : plants)
153 for (
auto market : markets)
157 for (
auto plant : plants)
161 for (
auto market : markets)
165 for (
auto t : distance) {
166 auto tuple = t.first;
167 auto t1 = get<0>(tuple);
168 auto t2 = get<1>(tuple);
183 cout <<
"x(" << record.key(0) <<
"," << record.key(1) <<
"): level=" << record.level() <<
184 " marginal=" << record.marginal() << endl;
187 cout <<
"GAMSException occured: " << ex.what() << endl;
188 }
catch (exception &ex) {
189 cout << ex.what() << endl;
GAMSSet addSet(const std::string &name, const int dimension, const std::string &explanatoryText="", GAMSEnum::SetType setType=GAMSEnum::SetType::Multi)
GAMSParameter addParameter(const std::string &name, const int dimension, const std::string &explanatoryText="")
GAMSVariable getVariable(const std::string &name)
void setAllModelTypes(const std::string &solver)
void setDefine(const std::string &key, const std::string &value)
void setAction(const GAMSOptions::EAction::EActionEnum value)
void setValue(const double val)
GAMSParameterRecord addRecord(const std::vector< std::string > &keys)
GAMSSetRecord addRecord(const std::vector< std::string > &keys)
void setSystemDirectory(std::string systemDir)
void setWorkingDirectory(std::string workingDir)
std::string workingDirectory() const
GAMSJob addJobFromString(const std::string &gamsSource, const std::string &jobName="")
GAMSCheckpoint addCheckpoint(const std::string &checkpointName="")
string getBaseModelText()
Get model as string.
void createSaveRestart(int argc, char *argv[], const string &checkpointName)
Create Save and Restart checkpoint.
string getModelText()
Get model as string.