42int main(
int argc,
char* argv[])
44 cout <<
"---------- Transport GDX --------------" << endl;
53 vector<string> plants = {
54 "Seattle",
"San-Diego"
56 vector<string> markets = {
57 "New-York",
"Chicago",
"Topeka"
59 map<string, double> capacity = {
60 {
"Seattle", 350.0 }, {
"San-Diego", 600.0 }
62 map<string, double> demand = {
63 {
"New-York", 325.0 }, {
"Chicago", 300.0 }, {
"Topeka", 275.0 }
65 map<tuple<string, string>,
double> distance = {
66 { make_tuple(
"Seattle",
"New-York"), 2.5 },
67 { make_tuple(
"Seattle",
"Chicago"), 1.7 },
68 { make_tuple(
"Seattle",
"Topeka"), 1.8 },
69 { make_tuple(
"San-Diego",
"New-York"), 2.5 },
70 { make_tuple(
"San-Diego",
"Chicago"), 1.8 },
71 { make_tuple(
"San-Diego",
"Topeka"), 1.4 }
79 for (
string p: plants)
84 for (
string m: markets)
89 for (
string p: plants)
94 for (
string m: markets)
99 for (
auto t : distance)
109 cout <<
"Content of GDX file 'data.gdx':";
110 string command =
"gdxdump " + ws.workingDirectory() + cPathSep +
"data.gdx";
111 int ret = system(command.c_str());
113 cerr <<
"system(" << command.c_str() <<
") returned " << ret << endl;
121 iNew.push_back(rec.key(0));
125 jNew.push_back(rec.key(0));
127 map<string, double> aNew;
129 aNew[rec.key(0)] = rec.value();
131 map<string, double> bNew;
133 bNew[rec.key(0)] = rec.value();
135 map<tuple<string, string>,
double> dNew;
137 dNew[make_tuple(rec.key(0), rec.key(1))] = rec.value();
141 cout <<
"i:" << endl;
143 cout <<
" " << s << endl;
144 cout <<
"j:" << endl;
146 cout <<
" " << s << endl;
147 cout <<
"a:" << endl;
148 for (
auto rec : aNew)
149 cout <<
" " << rec.first <<
" : " << rec.second << endl;
150 cout <<
"b:" << endl;
151 for (
auto rec : bNew)
152 cout <<
" " << rec.first <<
" : " << rec.second << endl;
153 cout <<
"d:" << endl;
154 for (
auto rec : dNew)
155 cout <<
" " << get<0>(rec.first) <<
", " << get<1>(rec.first) <<
" : " << rec.second << endl;
156 cout <<
"f:" << endl;
160 cout <<
"GAMSException occured: " << ex.what() << endl;
161 }
catch (exception &ex) {
162 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="")
void doExport(const std::string &filePath="")
GAMSSet getSet(const std::string &name)
GAMSParameter getParameter(const std::string &name)
void setValue(const double val)
GAMSParameterRecord firstRecord(const std::vector< std::string > &slice)
GAMSParameterRecord addRecord(const std::vector< std::string > &keys)
GAMSSetRecord addRecord(const std::vector< std::string > &keys)
void setSystemDirectory(std::string systemDir)