42int main(
int argc,
char* argv[])
44 cout <<
"---------- Transport 13 --------------" << endl;
47 vector<string> plants {
"Seattle",
"San-Diego"};
48 vector<string> markets {
"New-York",
"Chicago",
"Topeka"};
49 map<string, double> capacity {
50 {
"Seattle", 350.0 }, {
"San-Diego", 600.0 }
52 map<string, double> demand {
53 {
"New-York", 325.0 }, {
"Chicago", 300.0 }, {
"Topeka", 275.0 }
55 map<tuple<string, string>,
double> distance {
56 { make_tuple(
"Seattle",
"New-York"), 2.5 },
57 { make_tuple(
"Seattle",
"Chicago"), 1.7 },
58 { make_tuple(
"Seattle",
"Topeka"), 1.8 },
59 { make_tuple(
"San-Diego",
"New-York"), 2.5 },
60 { make_tuple(
"San-Diego",
"Chicago"), 1.8 },
61 { make_tuple(
"San-Diego",
"Topeka"), 1.4 }
71 for (
string p : plants)
74 for (
string m : markets)
77 for (
string p : plants)
78 t.a().addRecord(p).setValue(capacity[p]);
80 for (
string m : markets)
81 t.b().addRecord(m).setValue(demand[m]);
83 for (
auto dis : distance)
84 t.d().addRecord(get<0>(dis.first), get<1>(dis.first)).setValue(distance[dis.first]);
86 t.f().addRecord().setValue(90);
88 t.opt().setAllModelTypes(
"cplex");
92 cout <<
"Objective: " << t.z().firstRecord().level() << endl;
94 cout <<
"x(" << rec.key(0) <<
"," << rec.key(1) <<
"): level=" << rec.level() <<
95 " marginal=" << rec.marginal() << endl;
98 cout <<
"GAMSException occured: " << ex.what() << endl;
99 }
catch (exception &ex) {
100 cout << ex.what() << endl;
void setSystemDirectory(std::string systemDir)
Wrapper class definition for GAMS trnsport model.