43int main(
int argc,
char* argv[])
45 cout <<
"---------- Transport GDX --------------" << endl;
54 vector<string> plants = {
55 "Seattle",
"San-Diego"
57 vector<string> markets = {
58 "New-York",
"Chicago",
"Topeka"
60 map<string, double> capacity = {
61 {
"Seattle", 350.0 }, {
"San-Diego", 600.0 }
63 map<string, double> demand = {
64 {
"New-York", 325.0 }, {
"Chicago", 300.0 }, {
"Topeka", 275.0 }
66 map<tuple<string, string>,
double> distance = {
67 { make_tuple(
"Seattle",
"New-York"), 2.5 },
68 { make_tuple(
"Seattle",
"Chicago"), 1.7 },
69 { make_tuple(
"Seattle",
"Topeka"), 1.8 },
70 { make_tuple(
"San-Diego",
"New-York"), 2.5 },
71 { make_tuple(
"San-Diego",
"Chicago"), 1.8 },
72 { make_tuple(
"San-Diego",
"Topeka"), 1.4 }
80 for (
string p: plants)
85 for (
string m: markets)
90 for (
string p: plants)
95 for (
string m: markets)
100 for (
auto t : distance)
110 cout <<
"Content of GDX file 'data.gdx':";
111 string command =
"gdxdump " + ws.workingDirectory() + cPathSep +
"data.gdx";
112 int ret = system(command.c_str());
114 cerr <<
"system(" << command.c_str() <<
") returned " << ret << endl;
122 iNew.push_back(rec.key(0));
126 jNew.push_back(rec.key(0));
128 map<string, double> aNew;
130 aNew[rec.key(0)] = rec.value();
132 map<string, double> bNew;
134 bNew[rec.key(0)] = rec.value();
136 map<tuple<string, string>,
double> dNew;
138 dNew[make_tuple(rec.key(0), rec.key(1))] = rec.value();
142 cout <<
"i:" << endl;
144 cout <<
" " << s << endl;
145 cout <<
"j:" << endl;
147 cout <<
" " << s << endl;
148 cout <<
"a:" << endl;
149 for (
auto rec : aNew)
150 cout <<
" " << rec.first <<
" : " << rec.second << endl;
151 cout <<
"b:" << endl;
152 for (
auto rec : bNew)
153 cout <<
" " << rec.first <<
" : " << rec.second << endl;
154 cout <<
"d:" << endl;
155 for (
auto rec : dNew)
156 cout <<
" " << get<0>(rec.first) <<
", " << get<1>(rec.first) <<
" : " << rec.second << endl;
157 cout <<
"f:" << endl;
161 cout <<
"GAMSException occured: " << ex.what() << endl;
162 }
catch (exception &ex) {
163 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)