34std::string getDataText()
37 "i canning plants / seattle, san-diego /; \n"
58int main(
int argc,
char* argv[])
60 cout <<
"---------- Domain Checking --------------" << endl;
63 vector<string> plants {
"Seattle",
"San-Diego" };
64 vector<string> markets {
"New-York",
"Chicago",
"Topeka" };
65 map<string, double> capacity { {
"Seattle", 350.0 }, {
"San-Diego", 600.0 } };
66 map<string, double> demand { {
"New-York", 325.0 }, {
"Chicago", 300.0 }, {
"Topeka", 275.0 } };
67 map<tuple<string, string>,
double> distance {
68 { make_tuple<string,string> (
"Seattle",
"New-York"), 2.5 },
69 { make_tuple<string,string> (
"Seattle",
"Chicago"), 1.7 },
70 { make_tuple<string,string> (
"Seattle",
"Topeka"), 1.8 },
71 { make_tuple<string,string> (
"San-Diego",
"New-York"), 2.5 },
72 { make_tuple<string,string> (
"San-Diego",
"Chicago"), 1.8 },
73 { make_tuple<string,string> (
"San-Diego",
"Topeka"), 1.4 }
87 for (
auto plant: plants)
90 for (
auto market: markets)
95 for (
string plant: plants)
100 cout <<
"*** Unexpected domain violation in a" << endl;
106 for (
string market: markets)
111 cout <<
"*** Unexpected domain violation in b" << endl;
117 for (
auto t : distance) {
118 auto tuple = t.first;
119 auto t1 = get<0>(tuple);
120 auto t2 = get<1>(tuple);
126 cout <<
"*** Unexpected domain violation in d" << endl;
132 cout <<
"*** Unexpected domain violation in db" << endl;
146 cout <<
"*** Domain violation for db not recognized" << endl;
150 cout <<
"*** Domain violation for a not recognized" << endl;
154 cout <<
"*** Domain violation for d not recognized" << endl;
160 cout <<
"*** Unexpected domain violation in b" << endl;
166 cout <<
"Domain Violations of a:" << endl;
169 for (
bool vi: sdv.violInd())
170 cout << (vi ?
"true " :
"false ");
172 for (
string k: sdv.violRec().keys())
174 cout <<
"<<" << endl;
178 cout <<
"*** Number of domain violations for a should be 2 but saw " << dvCnt << endl;
184 cout <<
"Domain Violations of d:" << endl;
187 for (
bool vi: sdv.violInd()) {
188 cout << (vi ?
"true " :
"false ");
193 for (
string k: sdv.violRec().keys())
195 cout <<
"<<" << endl;
198 cout <<
"*** Number of domain violations for a should be 3 but saw " << dvCnt << endl;
204 cout <<
"Domain Violations of db:" << endl;
206 cout <<
" > " + DDV.violSym().name() +
": " << endl;
209 for (
bool vi: sdv.violInd()) {
215 for (
string k: sdv.violRec().keys())
217 cout <<
"<<" << endl;
221 cout <<
"*** Number of domain violations for db should be 5 but saw " << dvCnt << endl;
227 cout <<
"Domain Violations of db:" << endl;
229 cout <<
" > " + DDV.violSym().name() +
": " << endl;
232 for (
bool vi: sdv.violInd())
235 for (
string k: sdv.violRec().keys())
237 cout <<
"<<" << endl;
242 cout <<
"*** Number of domain violations for db should be 3 but saw " << dvCnt << endl;
247 cout <<
"Domain Violations of db:" << endl;
249 cout <<
" > " + DDV.violSym().name() +
": " << endl;
252 for (
bool vi: sdv.violInd())
255 for (
string k: sdv.violRec().keys())
257 cout <<
"<<" << endl;
262 cout <<
"*** Number of domain violations for db should be 2 but saw " << dvCnt << endl;
267 bool sawException =
false;
276 cout <<
"*** It should not be possible to export a GAMSDatabase containing domain violations by default" << endl;
286 if (!item.isRelaxed()) {
287 GAMSSet domSet = item.getSet();
288 if (domSet.
name() ==
"i") {
290 if (find(plants.begin(), plants.end(), uel.key(0)) == plants.end()) {
291 cout <<
"*** Unexpected uel " + uel.key(0) +
" found in domain i" << endl;
294 }
else if (domSet.name() ==
"j") {
296 if (find(markets.begin(), markets.end(), uel.key(0)) == markets.end()) {
297 cout <<
"*** Unexpected uel " + uel.key(0) +
" found in domain j" << endl;
301 cout <<
"*** Expected GAMSSet i and j but found " + domSet.
name() << endl;
307 cout <<
"*** Expected GAMSSet as domain but found relaxed domain " + item.name() << endl;
318 GAMSJob jAlias = ws.addJobFromString(getDataText());
321 cout <<
"Elements of aliased Set:" << endl;
323 cout <<
" > " + item.key(0) << endl;
330 cout <<
"Elements of test Set after adding empty UEL:" << endl;
335 cout <<
"Record ' a ' should be the same as ' a':" << endl;
340 testSet.
addRecord(
"123456789012345678901234567890123456789012345678901234567890123 ").
setText(
"OK");
342 sawException =
false;
344 testSet.
addRecord(
"1234567890123456789012345678901234567890123456789012345678901234").
setText(
"not OK");
349 cout <<
"*** It should not be possible to add a record with more than 63 characters" << endl;
354 testDB.
addSet(
"textOK",
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345");
355 sawException =
false;
357 testDB.
addSet(
"textNotOK",
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456");
362 cout <<
"*** It should not be possible to add an explanatory text with more than 255 characters" << endl;
366 testSet.
addRecord(
"OK").
setText(
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345");
367 sawException =
false;
369 testSet.
addRecord(
"notOK").
setText(
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456");
374 cout <<
"*** It should not be possible to add an explanatory text with more than 255 characters" << endl;
381 sawException =
false;
388 cout <<
"*** It should not be possible to add a record single AND double quote" << endl;
394 cout <<
"GAMSException occured: " << ex.what() << endl;
395 }
catch (exception &ex) {
396 cout << ex.what() << endl;
std::vector< GAMSDatabaseDomainViolation > getDatabaseDVs(int maxViol=0, int maxViolPerSym=0)
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 setSuppressAutoDomainChecking(bool value)
void setValue(const double val)
GAMSParameterRecord addRecord(const std::vector< std::string > &keys)
void setText(const std::string &text)
GAMSSetRecord findRecord(const std::vector< std::string > &keys)
GAMSSetRecord addRecord(const std::vector< std::string > &keys)
std::vector< GAMSSymbolDomainViolation > getSymbolDVs(int maxViol=0)
std::string & name() const
int numberRecords() const
std::vector< GAMSDomain > domains()
void setSystemDirectory(std::string systemDir)