76 #include "OSInstance.h"
91 #ifdef COIN_HAS_KNITRO
103 #ifdef COIN_HAS_GAMSUTILS
107 #ifdef COIN_HAS_IPOPT
116 #ifdef COIN_HAS_BONMIN
120 #ifdef COIN_HAS_COUENNE
131 using std::ostringstream;
136 #define MAXCHARS 5000
172 int main(
int argC,
const char* argV[])
174 WindowsErrorPopupBlocker();
175 std::ostringstream outStr;
190 const char *space =
" ";
191 const char *quote =
"\"";
193 std::string configFileName =
"";
202 bool scannerActive =
false;
213 if (argV[i][0] !=
'\"')
214 for (
int k=0;
k<strlen(argV[i]);
k++)
216 if (argV[i][
k] ==
' ')
224 if (strlen(osss) + strlen(argV[i]) + 3 >
MAXCHARS)
225 throw ErrorClass(
"The command line exceeds allocated storage. Increase parameter MAXCHARS.");
227 strcat(osss, argV[i]);
233 if (strlen(osss) + strlen(argV[i]) + 1 >
MAXCHARS)
234 throw ErrorClass(
"The command line exceeds allocated storage. Increase parameter MAXCHARS.");
235 strcat(osss, argV[i]);
244 outStr <<
"Input String = " << osss << std::endl;
248 scannerActive =
true;
269 scannerActive =
false;
278 scannerActive =
true;
285 outStr <<
"configFileName = " << configFileName << std::endl;
290 configFileName.c_str());
304 scannerActive =
false;
313 scannerActive =
true;
334 scannerActive =
false;
353 std::string osrl = osrlwriter->
writeOSrL(osresult);
357 if (oscommandline->
browser !=
"")
359 std::string str = oscommandline->
browser +
" "
361 const char *ch = &str[0];
380 delete oscommandline;
390 outStr << std::endl <<
"using print level " << oscommandline->
printLevel <<
" for stdout" << std::endl;
404 if (oscommandline->
logFile !=
"")
412 "Added channel " + oscommandline->
logFile);
416 "Output channel " + oscommandline->
logFile +
" previously defined");
425 outStr << std::endl <<
"using print level " << oscommandline->
filePrintLevel;
426 outStr <<
" for " << oscommandline->
logFile << std::endl;
442 outStr << std::endl << std::endl <<
get_help() << std::endl;
445 delete oscommandline;
446 oscommandline = NULL;
457 delete oscommandline;
458 oscommandline = NULL;
475 std::string osrl = osrlwriter->
writeOSrL(osresult);
480 if (oscommandline->
browser !=
"")
482 std::string str = oscommandline->
browser +
" "
484 const char *ch = &str[0];
503 delete oscommandline;
504 oscommandline = NULL;
505 delete inputFileUtil;
506 inputFileUtil = NULL;
514 outStr <<
"HERE ARE THE OPTION VALUES:" << endl;
515 if(oscommandline->
configFile !=
"") outStr <<
"Config file = " << oscommandline->
configFile << endl;
516 if(oscommandline->
osilFile !=
"") outStr <<
"OSiL file = " << oscommandline->
osilFile << endl;
517 if(oscommandline->
osolFile !=
"") outStr <<
"OSoL file = " << oscommandline->
osolFile << endl;
518 if(oscommandline->
osrlFile !=
"") outStr <<
"OSrL file = " << oscommandline->
osrlFile << endl;
522 if(oscommandline->
mpsFile !=
"") outStr <<
"MPS File Name = " << oscommandline->
mpsFile << endl;
523 if(oscommandline->
nlFile !=
"") outStr <<
"NL File Name = " << oscommandline->
nlFile << endl;
525 if(oscommandline->
browser !=
"") outStr <<
"Browser Value = " << oscommandline->
browser << endl;
526 if(oscommandline->
solverName !=
"") outStr <<
"Selected Solver = " << oscommandline->
solverName << endl;
528 if(oscommandline->
printModel) outStr <<
"print model prior to solve/send" << endl;
530 outStr <<
"print level for stdout: " << oscommandline->
printLevel << endl;
531 if(oscommandline->
logFile !=
"")
533 outStr <<
"also send output to " << oscommandline->
logFile << endl;
534 outStr <<
"print level for file output: " << oscommandline->
filePrintLevel << endl;
542 for (k = 0; k < oscommandline->
solverName.length(); k++)
581 outStr <<
"could not open file properly" << endl;
593 std::string osrl = osrlwriter->
writeOSrL(osresult);
597 if (oscommandline->
browser !=
"")
599 std::string str = oscommandline->
browser +
" "
601 const char *ch = &str[0];
617 delete oscommandline;
618 oscommandline = NULL;
635 solve(oscommandline);
651 knock(oscommandline);
658 delete oscommandline;
659 oscommandline = NULL;
672 std::string osrl =
"";
678 #ifdef COIN_HAS_GAMSUTILS
690 if (oscommandline->
osil ==
"")
693 if (oscommandline->
nlFile !=
"")
699 if (oscommandline->
mpsFile !=
"")
712 oscommandline->
osil =
"";
726 if (oscommandline->
osol ==
"")
728 std::ostringstream outStr;
730 <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?> <osol xmlns=\"os.optimizationservices.org\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"os.optimizationservices.org http://www.optimizationservices.org/schemas/";
732 outStr <<
"/OSoL.xsd\"></osol>";
733 oscommandline->
osol = outStr.str();
735 osrl = osagent->
solve(oscommandline->
osil, oscommandline->
osol);
739 if (oscommandline->
browser !=
"")
741 std::string str = oscommandline->
browser +
" "
743 const char *ch = &str[0];
756 if (oscommandline->
osil !=
"")
764 if (oscommandline->
nlFile !=
"")
780 std::string sModelOptionName =
"modelOptions.osol";
781 if (fileUtil == NULL) fileUtil =
new FileUtil();
791 "nl file specified locally but ASL not present");
796 if (oscommandline->
mpsFile !=
"")
806 #ifdef COIN_HAS_GAMSUTILS
812 "a Gams Control specified locally but GAMSIP not present");
819 "Error: no osil, GAMS dat, AMPL nl, or mps file given for a local solve --- \n NOTE: information in the osol file is ignored for local solves.");
836 if (oscommandline->
browser !=
"")
838 std::string str = oscommandline->
browser +
" "
840 const char *ch = &str[0];
851 if (osilreader != NULL)
854 if (mps2osil != NULL)
858 if(nl2os != NULL)
delete nl2os;
861 #ifdef COIN_HAS_GAMSUTILS
862 if(gams2osil != NULL)
delete gams2osil;
871 std::string osrl =
"";
876 std::string::size_type pos1 = eclass.
errormsg.find(
"<osrl");
877 if(pos1 == std::string::npos)
893 if (oscommandline->
browser !=
"")
895 std::string str = oscommandline->
browser +
" "
897 const char *ch = &str[0];
911 if(osrlwriter != NULL)
918 if (osilreader != NULL)
921 if (mps2osil != NULL)
925 if(nl2os != NULL)
delete nl2os;
928 #ifdef COIN_HAS_GAMSUTILS
929 if(gams2osil != NULL)
delete gams2osil;
955 throw ErrorClass(
"please specify service location (url)");
964 std::string osrl =
"";
969 string::size_type pos1 = eclass.
errormsg.find(
"<osrl");
970 if(pos1 == std::string::npos)
990 if(osrlwriter != NULL)
1005 std::string osplOutput =
"";
1016 if (oscommandline->
osol ==
"")
1045 throw ErrorClass(
"please specify service location (url)");
1052 std::string osrl =
"";
1057 string::size_type pos1 = eclass.
errormsg.find(
"<osrl");
1058 if(pos1 == std::string::npos)
1064 std::string osrl = osrlwriter->
writeOSrL(osresult);
1071 if(osresult != NULL)
1076 if(osrlwriter != NULL)
1098 if (oscommandline->
osil ==
"")
1101 if (oscommandline->
nlFile !=
"")
1107 if (oscommandline->
mpsFile !=
"")
1113 oscommandline->
osil =
"";
1121 if (oscommandline->
osol ==
"")
1140 bSend = osagent->
send(oscommandline->
osil, oscommandline->
osol);
1145 "Send failed, check to make sure you sent a jobID not on the system.");
1152 throw ErrorClass(
"please specify service location (url)");
1157 std::string osrl =
"";
1164 string::size_type pos1 = eclass.
errormsg.find(
"<osrl");
1165 if(pos1 == std::string::npos)
1184 if(osresult != NULL)
1189 if(osrlwriter != NULL)
1203 std::string osrl =
"";
1212 if (oscommandline->
osol ==
"")
1237 std::ostringstream outStr;
1241 outStr <<
"Solver Result Written to File: " << oscommandline->
osrlFile << endl;
1243 if (oscommandline->
browser !=
"")
1245 std::string str = oscommandline->
browser +
" "
1247 const char *ch = &str[0];
1260 throw ErrorClass(
"please specify service location (url)");
1268 std::string osrl =
"";
1273 string::size_type pos1 = eclass.
errormsg.find(
"<osrl");
1274 if(pos1 == std::string::npos)
1287 if(osresult != NULL)
1292 if(osrlwriter != NULL)
1308 std::string osplOutput =
"";
1316 if (oscommandline->
osol ==
"")
1335 osplOutput = osagent->
kill(oscommandline->
osol);
1349 throw ErrorClass(
"please specify service location (url)");
1357 std::string osrl =
"";
1362 string::size_type pos1 = eclass.
errormsg.find(
"<osrl");
1363 if(pos1 == std::string::npos)
1377 if(osresult != NULL)
1382 if(osrlwriter != NULL)
1412 oscommandline->
osil = osil;
1419 "trying to convert nl to osil without AMPL ASL configured");
1434 #ifdef COIN_HAS_GAMSIO
1442 oscommandline->
osil = osil;
1449 "trying to convert Gams control file to osil without GAMSUTILS configured");
1471 oscommandline->
osil = osil;
1492 <<
"A service location is required"
1495 <<
"Please type the URL of the remote service: ";
1504 std::string configFileName =
"";
1508 bool scannerActive =
false;
1511 scannerActive =
true;
1514 std::string lineText;
1516 std::string wordSep =
" ";
1517 std::string dblQuote =
"\"";
1518 std::string optionName =
"";
1519 std::string optionValue =
"";
1520 std::string::size_type indexStart;
1521 std::string::size_type indexEnd;
1524 const int nCommands = 14;
1525 std::string commandArray[nCommands] =
1526 {
"solve",
"send",
"getJobID",
"retrieve",
"kill",
"knock",
1527 "quit",
"exit",
"reset",
"list",
"?",
"help",
"version",
1531 const int nOptions = 14;
1532 std::string optionArray[nOptions] =
1533 {
"osil",
"osrl",
"osol",
"mps",
"nl",
"dat",
1534 "serviceLocation",
"solver",
"osplInput",
"osplOutput",
1535 "printRow",
"printLevel",
"logFile",
"fileLogLevel"
1540 std::map<string, int> commandMap;
1542 for(k = 0; k < nCommands; k++)
1544 commandMap[ commandArray[
k] ] =
k;
1549 std::map<string, int> optionMap;
1551 for(k = 0; nOptions; k++)
1553 optionMap[ optionArray[
k] ] =
k;
1556 std::cout <<
"At the prompt enter a valid command or option value pair.\n";
1557 std::cout <<
"Enter the \"solve\" command to optimize.\n";
1558 std::cout <<
"Type \"quit\" or \"exit\" to leave the application. \n";
1559 std::cout <<
"Type \"help\" or \"?\" for a list of valid options.\n\n";
1561 while (oscommandline->
quit !=
true)
1563 std::cout <<
"Please enter a command, or an option followed by an option value: ";
1564 getline(std::cin, lineText);
1565 lineText =
" " + lineText +
" ";
1567 indexStart = lineText.find_first_not_of(wordSep);
1568 if (indexStart == string::npos)
1570 std::cout << std::endl;
1571 std::cout <<
"You did not enter a valid option. "
1572 <<
"Type \"help\" or \"?\" for a list of valid options."
1577 indexEnd = lineText.find_first_of(wordSep, indexStart + 1);
1578 optionName = lineText.substr(indexStart, indexEnd - indexStart);
1581 if( (commandMap.find(optionName) == commandMap.end() ) &&
1582 (optionMap.find(optionName) == optionMap.end() ) )
1584 std::cout << std::endl;
1585 std::cout <<
"You did not enter a valid option. "
1586 <<
"Type \"help\" or \"?\" for a list of valid options."
1594 indexStart = lineText.find_first_not_of(wordSep, indexEnd + 1);
1595 if (indexStart != std::string::npos && lineText[indexStart] ==
'\"')
1597 indexEnd = lineText.find_first_of(dblQuote, indexStart + 1);
1602 indexEnd = lineText.find_first_of(wordSep, indexStart + 1);
1605 if (indexStart != std::string::npos && indexEnd != std::string::npos)
1607 optionValue = lineText.substr(indexStart + skipChars,
1608 indexEnd - indexStart - skipChars);
1620 if( commandMap.find(optionName) != commandMap.end() )
1622 switch (commandMap[ optionName] )
1627 if(oscommandline->
osil ==
"" && oscommandline->
mps ==
"" && oscommandline->
nl ==
"")
1631 <<
"You did not specify an optimization instance!!!\n"
1632 <<
"Please enter file format option (osil, nl, or mps) \n"
1633 <<
"followed by the option value which is the file location. \n"
1638 solve(oscommandline);
1640 std::cout <<
"\nSolve command executed. Please see " << oscommandline->
osrlFile <<
" for results." << std::endl;
1648 send(oscommandline);
1665 if( (oscommandline->
osolFile ==
"") && (oscommandline->
jobID ==
"") )
1669 <<
"Cannot retrieve: no JobID and no OSoL file"
1685 if( (oscommandline->
osolFile ==
"") && (oscommandline->
jobID ==
"") )
1689 <<
"Cannot kill: no JobID and no OSoL file"
1694 kill(oscommandline);
1713 <<
"Cannot knock -- no OSplInputFile specified"
1718 knock(oscommandline);
1739 std::cout <<
"\nAll options reset.\n";
1775 throw ErrorClass(
"we don't have a valid command");
1784 if (optionValue ==
"")
1787 if(optionMap.find(optionName) != optionMap.end() )
1790 switch (optionMap[ optionName] )
1795 <<
"Please enter the name of an osil file: ";
1801 <<
"Please enter the name of an osrl file: ";
1806 <<
"Please enter the name of an osol file: ";
1811 <<
"Please enter the name of an mps file: ";
1816 <<
"Please enter the name of an AMPL nl file: ";
1821 <<
"Please enter the name of a dat file: ";
1826 <<
"Please enter the serviceLocation: ";
1831 <<
"Please enter the name of the solver: ";
1836 <<
"Please enter the name of an osplInput file: ";
1841 <<
"Please enter the name of an osplOutput file: ";
1846 <<
"Please enter the number of a constraint (>=0) or objective (<0): ";
1851 <<
"Please enter the print level (0-"
1857 <<
"Please enter the name of the log file: ";
1862 <<
"Please enter the print level (0-"
1863 << ENUM_OUTPUT_LEVEL_NUMBER_OF_LEVELS <<
"): ";
1870 getline(std::cin, lineText);
1874 indexStart = lineText.find_first_not_of(wordSep, 0);
1875 if (lineText[indexStart] ==
'\"')
1877 indexEnd = lineText.find_first_of(dblQuote, indexStart + 1);
1882 indexEnd = lineText.find_first_of(wordSep, indexStart + 1);
1885 if (indexStart != std::string::npos && indexEnd != std::string::npos)
1887 optionValue = lineText.substr(indexStart + skipChars,
1888 indexEnd - indexStart - skipChars);
1901 if(optionMap.find(optionName) != optionMap.end() )
1903 switch (optionMap[ optionName] )
1907 oscommandline->
osilFile = optionValue;
1910 (oscommandline->
osilFile).c_str());
1915 oscommandline->
osrlFile = optionValue;
1919 oscommandline->
osolFile = optionValue;
1922 (oscommandline->
osolFile).c_str());
1926 oscommandline->
mpsFile = optionValue;
1929 (oscommandline->
mpsFile).c_str());
1933 oscommandline->
nlFile = optionValue;
1936 (oscommandline->
nlFile).c_str());
1940 oscommandline->
datFile = optionValue;
1943 (oscommandline->
datFile).c_str());
1980 <<
"Please enter the print level (0-"
1986 <<
"Please enter the name of the log file: ";
1991 <<
"Please enter the print level (0-"
1992 << ENUM_OUTPUT_LEVEL_NUMBER_OF_LEVELS <<
"): ";
2002 std::cout << std::endl;
2006 std::cout << eclass.
errormsg << std::endl;
2012 scannerActive =
false;
2013 delete oscommandline;
2014 oscommandline = NULL;
2021 std::ostringstream helpMsg;
2023 helpMsg <<
"************************* HELP *************************"
2026 <<
"In this HELP file we assume that the solve service method is used and "
2029 <<
"that we are solving problems locally, that is the solver is on the "
2032 <<
"machine running this OSSolverService. See Section 10.3 of the User\'s "
2035 <<
"Manual for other service methods or calling a server remotely. "
2037 helpMsg <<
"The OSSolverService takes the parameters listed below. "
2040 <<
"The order of the parameters is irrelevant. Not all the parameters "
2042 helpMsg <<
"are required. However, the location of an instance file is "
2045 <<
"required when using the solve service method. The location of the "
2047 helpMsg <<
"instance file is specified using the osil option. " << endl;
2052 <<
"-osil xxx.osil this is the name of the file that contains the "
2054 helpMsg <<
"optimization instance in OSiL format. This option may be "
2056 helpMsg <<
"specified in the OSoL solver options file. " << endl;
2061 <<
"-osol xxx.osol this is the name of the file that contains the solver options. "
2063 helpMsg <<
"It is not necessary to specify this option. " << endl;
2068 <<
"-osrl xxx.osrl this is the name of the file to which the solver solution is written. "
2071 <<
"It is not necessary to specify this option. If this option is not specified, "
2073 helpMsg <<
"the result will be printed to standard out. " << endl;
2078 <<
"-osplInput xxx.ospl this is the name of an input file in the OS Process"
2080 helpMsg <<
" Language (OSpL), this is used as input to the knock method."
2086 <<
"-osplOutput xxx.ospl this is the name of an output file in the OS Process"
2089 <<
"Language (OSpL), this the output string from the knock and kill methods."
2094 helpMsg <<
"-serviceLocation url is the URL of the solver service. "
2097 <<
"This is not required, and if not specified it is assumed that "
2099 helpMsg <<
"the problem is solved locally. " << endl;
2104 <<
"-serviceMethod methodName this is the method on the solver service to be invoked. "
2107 <<
"The options are solve, send, kill, knock, getJobID, and retrieve. "
2110 <<
"This option is not required, and the default value is solve. "
2116 <<
"-mps xxx.mps this is the name of the mps file if the problem instance "
2119 <<
"is in mps format. The default file format is OSiL so this option is not required. "
2125 <<
"-nl xxx.nl this is the name of the AMPL nl file if the problem "
2128 <<
"instance is in AMPL nl format. The default file format is OSiL "
2130 helpMsg <<
"so this option is not required. " << endl;
2135 <<
"-solver solverName Possible values for default OS installation "
2138 <<
"are bonmin(COIN-OR Bonmin), couenne (COIN-OR Couenne), clp (COIN-OR Clp),"
2140 helpMsg <<
"cbc (COIN-OR Cbc), dylp (COIN-OR DyLP), ipopt (COIN-OR Ipopt),"
2142 helpMsg <<
"and symphony (COIN-OR SYMPHONY). Other solvers supported"
2145 <<
"(if the necessary libraries are present) are cplex (Cplex through COIN-OR Osi),"
2148 <<
"glpk (glpk through COIN-OR Osi), knitro (Knitro), and lindo (LINDO)."
2150 helpMsg <<
"If no value is specified for this parameter," << endl;
2151 helpMsg <<
"then cbc is the default value of this parameter." << endl;
2156 <<
"-browser browserName this paramater is a path to the browser on the "
2159 <<
"local machine. If this optional parameter is specified then the "
2161 helpMsg <<
"solver result in OSrL format is transformed using XSLT into "
2163 helpMsg <<
"HTML and displayed in the browser. " << endl;
2168 <<
"-config pathToConfigureFile this parameter specifies a path on "
2171 <<
"the local machine to a text file containing values for the input parameters. "
2174 <<
"This is convenient for the user not wishing to constantly retype parameter values. "
2177 <<
"This configure file can contain values for all of the other parameters. "
2182 helpMsg <<
"--version or -v get the current version of this executable "
2187 helpMsg <<
"--help or -h to get this help file " << endl;
2192 <<
"Note: If you specify a configure file by using the -config option, you can "
2195 <<
"override the values of the options in the configure file by putting them in "
2197 helpMsg <<
"at the command line. " << endl << endl;
2200 <<
"See the OS User\' Manual: http://www.coin-or.org/OS/doc/osUsersManual.pdf"
2202 helpMsg <<
"for more detail on how to use the OS project. " << endl;
2205 helpMsg <<
"********************************************************"
2208 return helpMsg.str();
2214 std::ostringstream versionMsg;
2215 versionMsg <<
"In order to find the version of this project " << endl;
2216 versionMsg <<
"connect to the directory where you downloaded " << endl;
2217 versionMsg <<
"and do: " << endl;
2218 versionMsg <<
"svn info " << endl;
2220 return versionMsg.str();
2225 std::ostringstream optionMsg;
2230 <<
"***************** VALID COMMANDS AND OPTIONS ********************"
2236 <<
"quit/exit -- terminate the executable"
2239 <<
"help/? -- produce this list of options"
2242 <<
"reset -- erase all previous option settings"
2245 <<
"list -- list the current option values"
2248 <<
"solve -- call the solver synchronously"
2251 <<
"send -- call the solver asynchronously"
2254 <<
"kill -- end a job on the remote server"
2257 <<
"retrieve -- get job result on the remote server"
2260 <<
"knock -- get job information on the remote server"
2263 <<
"getJobID -- get a job ID from the remote server"
2268 <<
"OPTIONS (THESE REQUIRE A VALUE):"
2271 <<
"osil -- the location of the model instance in OSiL format"
2274 <<
"mps -- the location of the model instance in MPS format"
2277 <<
"nl -- the location of the model instance in AMPL nl format"
2280 <<
"osol -- the location of the solver option file in OSoL format"
2283 <<
"osrl -- the location of the solver result file in OSrL format"
2286 <<
"osplInput -- the name of an input file in OSpL format"
2289 <<
"osplOutput -- the name of an output file in the OSpL format"
2292 <<
"serviceLocation -- the URL of a remote solver service"
2295 <<
"solver -- specify the solver to invoke"
2298 <<
"See http://www.coin-or.org/OS/"
2301 <<
"for more detail on how to use the OS project."
2308 <<
"printModel -- print the currently defined model"
2311 <<
"printRow nnn -- print row n of the currently defined model"
2314 <<
" if nnn >= 0, prints a constraint, otherwise prints an objective row"
2317 <<
"printLevel nnn -- control the amount of output sent to stdout"
2320 <<
" valid values are 0..";
2327 <<
"logFile --- a secondary output device"
2330 <<
"filePrintLevel nnn -- control the amount of output sent to the secondary output device"
2333 <<
" valid values are 0..";
2342 <<
"*****************************************************************"
2345 <<
"At the prompt enter a valid command or option value pair."
2348 <<
"Enter the \"solve\" command to optimize."
2351 <<
"Type \"quit/exit\" to leave the application."
2354 <<
"Type \"help\" or \"?\" for a list of valid options."
2358 return optionMsg.str();
2365 <<
"HERE ARE THE OPTION VALUES SO FAR:"
2368 cout <<
"Config file = "
2372 cout <<
"OSiL file = "
2376 cout <<
"OSoL file = "
2380 cout <<
"OSrL file = "
2385 cout <<
"OSpL Input file = "
2389 cout <<
"Service Method = "
2392 if (oscommandline->
mpsFile !=
"")
2393 cout <<
"MPS File Name = "
2396 if (oscommandline->
nlFile !=
"")
2397 cout <<
"NL File Name = "
2401 cout <<
"Selected Solver = "
2405 cout <<
"Service Location = "
2409 if (oscommandline->
jobID !=
"")
2411 << oscommandline->
jobID
2417 if (oscommandline->
osil ==
"" && oscommandline->
mps ==
"" && oscommandline->
nl ==
"")
2420 <<
"no instance defined; print command ignored" << std::endl;
2424 if (oscommandline->
osil !=
"")
2432 else if (oscommandline->
nl !=
"")
2445 std::cout <<
"no ASL present to read nl file; print command ignored" << std::endl;
2448 else if (oscommandline->
mps !=
"")
2462 if (osinstance == NULL)
2465 <<
"no instance defined; print command ignored" << std::endl;
2469 std::cout << osinstance->
printModel() << std::endl;
2477 std::cout <<
"no line number given; print command ignored" << std::endl;
2486 std::cout <<
"invalid row number; print command ignored" << std::endl;
2489 if (oscommandline->
osil ==
"" && oscommandline->
mps ==
"" && oscommandline->
nl ==
"")
2492 <<
"no instance defined; print command ignored" << std::endl;
2496 std::cout << std::endl <<
"Row " << rownumber <<
":" << std::endl << std::endl;
2497 if (oscommandline->
osil !=
"")
2505 else if (oscommandline->
nl !=
"")
2518 std::cout <<
"no ASL present to read nl file; print command ignored" << std::endl;
2521 else if (oscommandline->
mps !=
"")
2537 if (rownumberstring ==
"")
2538 std::cout <<
"no line number given; print command ignored" << std::endl;
2543 rownumber = atoi((rownumberstring).c_str());
2547 std::cout <<
"invalid row number; print command ignored" << std::endl;
2550 if (osinstance == NULL)
2553 <<
"no instance defined; print command ignored" << std::endl;
2557 std::cout << std::endl <<
"Row " << rownumber <<
":" << std::endl << std::endl;
2558 std::cout << osinstance->
printModel(rownumber) << std::endl;
std::string datFile
the name of the file that holds an instance in GAMS dat format
void getJobID(OSCommandLine *oscommandline, OSnl2OS *osnl2os)
std::string OSgetVersionInfo()
int printLevel
this parameter controls the amount of output to print the higher the number, the more output is gener...
bool invokeHelp
if this parameter is true we print the contents of the file help.txt and return
Used by a client to invoke a remote solver.
#define DEFAULT_OUTPUT_LEVEL
void getOSiLFromNl(OSCommandLine *oscommandline)
Some wrappers around routines that allow getting problem instances in other formats: ...
void send(OSCommandLine *oscommandline, OSnl2OS *osnl2os)
bool writeFileFromString(char *fname, std::string thestring)
write a file from an input string.
std::string retrieve(std::string osol)
implement the retrieve() method which is a virtual function in OShL
const OSSmartPtr< OSOutput > osoutput
std::string dat
the string that holds an instance in GAMS dat format
bool writeVersion
if this parameter is true we print the current version of the OS project
void doPrintModel(OSCommandLine *oscommandline)
std::string osplInput
osplInput is the content of the osplInputFile
std::string serviceLocation
serviceLocation is the URL of the remote solver when a local solver is not used
std::string printModel()
Print the infix representation of the problem.
bool send(std::string osil, std::string osol)
implement the send() method which is a virtual function in OShL
std::string jobID
the JobID
std::string osil
osil is the content of the osilFile
std::string errormsg
errormsg is the error that is causing the exception to be thrown
std::string nlFile
the name of the file that holds an instance in AMPL nl format
bool interactiveShell(std::string *schema, std::string *testFileName, std::string *outFileName, bool *compress, bool *addWhiteSpace, bool *verifyObjects, bool *useRandomObjects, unsigned int *seed, int *nrep, double *density, bool *conformant)
int main(int argc, char *argv[])
int AddChannel(std::string name)
Add a channel to the array outputChannel.
int ossslex_init(void **ptr)
bool OSPrint(ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level, std::string outStr)
This is the main method to output a string All output generated by the program should ultimately use ...
bool readNl(std::string stub)
read the nl file
bool createOSObjects()
create an OSInstance and OSOption representation from the AMPL nl content (Some of the information in...
void setOsol(std::string osol)
set the osol string
std::string solve(std::string osil, std::string osol)
implement the solve() method which is a virtual function in OShL, this is synchronous ...
void knock(OSCommandLine *oscommandline, OSnl2OS *osnl2os)
Template class for Smart Pointers.
Take an OSResult object and write a string that validates against OSrL.
std::string nl
the string that holds an instance in AMPL nl format
std::string get_version()
Take an OSOption object and write a string that validates against the OSoL schema.
std::string browser
this parameter is a path to the browser on the local machine.
std::string osplInputFile
name of an input file with xml in OS process language format, used for example to knock on a server...
OSInstance * readOSiL(const std::string &osil)
parse the OSiL model instance.
int ossslex_destroy(void *scanner)
std::string writeOSrL(OSResult *theosresult)
create an osrl string from an OSResult object
std::string osrlFile
osrlFile is the name of the file where the solver should write the result (in OSrL format) ...
std::string gamsControlFile
the name of the file that holds the GAMS control parameters
std::string logFile
this optional parameter contains the path to a logfile that can be used as an alternate output stream...
struct yy_buffer_state * YY_BUFFER_STATE
std::string mps
the string that holds an instance in MPS format
void getOSiLFromGams(OSCommandLine *oscommandline)
bool createOSInstance()
Creates an OSInstance from the GAMS smag instance representation.
std::string osilFile
osilFile is the name of the file that holds the model instance in OSiL format
std::string osplOutputFile
name of an output file where the solver should write the result of a knock or kill service request ...
void solve(OSCommandLine *oscommandline, OSnl2OS *osnl2os)
Next we have implementations of the six remote service methods solve, send, retrieve, knock, kill, getJobID (Do not bother with local solve; use runSolver instead)
bool printModel
if this parameter is true we print the current instance as read from an osil, nl or mps file ...
#define OS_SCHEMA_VERSION
Used to read an OSiL string.
void getServiceLocation(OSCommandLine *oscommandline)
======================== Interactive shell =========================
OSOption * osoption
osoption is a pointer to the OSOption object that gets created from the information in the nl file (a...
std::string printRowNumberAsString
this parameter contains a string representation (!) of the row number if only a single row (constrain...
std::string configFile
configFile is the name of the file that holds the configuration options if the OSSolverService reads ...
std::string writeOSoL(OSOption *theosoption)
create an osol string from an OSOption object
std::string mpsFile
the name of the file that holds an instance in MPS format
ENUM_OUTPUT_LEVEL
Enumeration for the different verbosity levels that can be used in producing output.
std::string runSolver(std::string solverName, std::string osol, OSInstance *osinstance)
This class is used to invoke a solver locally.
void retrieve(OSCommandLine *oscommandline, OSnl2OS *osnl2os)
int filePrintLevel
this parameter controls the amount of output to send to the log file (if used) the higher the number...
void doPrintRow(OSInstance *osinstance, std::string rownumberstring)
void setyyextra(OSCommandLine *oscommandline, void *scanner)
bool setGeneralMessage(std::string message)
Set the general message.
std::string serviceMethod
the service method the OSSolverService should execute, i.e.
bool setGeneralStatusType(std::string type)
Set the general status type, which can be: success, error, warning.
std::string osol
osol is the content of the osolFile
std::string knock(std::string ospl, std::string osol)
implement the knock() method which is a virtual function in OShL
bool createOSInstance()
create an OSInstance from the MPS instance representation
std::string writeOSiL(const OSInstance *theosinstance)
create an osil string from an OSInstance object
bool quit
if this parameter is true we quit/exit
std::string osolFile
osolFile is the name of the file that holds the solver options in OSoL format
std::string getFileAsString(const char *fname)
read a file and return contents as a string.
bool setJobID(std::string jobID)
Set the job ID.
std::string get_options()
void list_options(OSCommandLine *oscommandline)
std::string kill(std::string osol)
implement the kill() method which is a virtual function in OShL
std::string getJobID(std::string osol)
implement the getJobID() method which is a virtual function in OShL
void getOSiLFromMps(OSCommandLine *oscommandline)
int ossslex(void *scanner)
This class is used to store command line options for the OSSolverService executable and to provide me...
The in-memory representation of an OSiL instance..
class used to make it easy to read and write files.
OSInstance * osinstance
osinstance is a pointer to the OSInstance object that gets created from the instance represented in N...
OSInstance * osinstance
osinstance is a pointer to the OSInstance object that gets created from the information in the nl fil...
Creating a OSInstance from a GAMS model given as GAMS Modeling Object (GMO).
void kill(OSCommandLine *oscommandline, OSnl2OS *osnl2os)
used for throwing exceptions.
std::string solverName
the name of the solver to be invoked locally, e.g -solver Ipopt
Take an OSInstance object and write a string that validates against the OSiL schema.
bool SetPrintLevel(std::string name, ENUM_OUTPUT_LEVEL *level, int dim)
Modify all print levels associated with a channel.
YY_BUFFER_STATE osss_scan_string(const char *osss, void *scanner)
void reset_options()
a function to reset the command line to default values useful especially in the interactive shell ...