69 #include "OSInstance.h"
85 #ifdef COIN_HAS_BONMIN
89 #ifdef COIN_HAS_COUENNE
97 #include "CoinError.hpp"
105 # ifdef HAVE_STRING_H
108 # error "don't have header file for string"
112 #include "CoinError.hpp"
113 #include "CoinHelperFunctions.hpp"
123 #define MAXCHARS 5000
137 using std::ostringstream;
140 std::string *optionFile, std::string *serviceLocation);
144 int main(
int argc,
char **argv)
146 WindowsErrorPopupBlocker();
148 std::ostringstream outStr;
161 char *amplclient_options = NULL;
163 std::string sSolverName =
"";
164 std::string osolFileName =
"";
165 std::string osol =
"";
166 std::string serviceLocation =
"";
167 std::string nlfile =
"";
172 outStr <<
"Here is the command line:";
173 for (
int i=0; i<argc; i++) outStr <<
" " << argv[i];
180 amplclient_options = getenv(
"OSAmplClient_options");
181 if( amplclient_options != NULL)
185 outStr <<
"HERE ARE THE AMPLCLIENT OPTIONS " << amplclient_options << endl;
193 for(k = 0; k < sSolverName.length(); k++)
195 sSolverName[
k] = tolower( sSolverName[ k]);
200 if(osolFileName.size() > 0)
211 cw = ASL_alloc(ASL_read_fg);
212 rw = ASL_alloc(ASL_read_fg);
215 jac0dim((
char*)stub, (
fint)strlen(stub));
235 outStr <<
"Error detected: " << eclass.
errormsg << std::endl;
253 std::string sModelInstanceName =
"modelInstance.osil";
273 std::string sModelOptionName =
"modelOptions.osol";
287 std::string osrl =
"";
294 if(serviceLocation.size() == 0 )
321 outStr <<
"Place remote synchronous call: " << serviceLocation << endl << endl << endl;
324 osrl = osagent->
solve(osil, osol);
325 if (osrl.size() == 0)
throw ErrorClass(
"Nothing was returned from the server, please check service address");
353 std::string sResultFileName =
"solutionResult.osrl";
358 std::string::size_type pos1 = osrl.find(
"error");
359 if(pos1 == std::string::npos)
361 std::string sReport =
"model was solved";
363 osresult = osrlreader->
readOSrL( osrl);
380 outStr <<
"There was an error parsing the OSrL string" << endl << eclass.
errormsg << endl << endl;
384 if (solverType != NULL)
398 if (solWriter != NULL)
delete solWriter;
407 std::string *solverOptions, std::string *serviceLocation)
409 std::ostringstream outStr;
430 *solverOptions = oscommandline->
osolFile;
438 outStr <<
"There was an error processing OSAmplClient options: " << endl << eclass.
errormsg << endl << endl;
Used by a client to invoke a remote solver.
bool writeFileFromString(char *fname, std::string thestring)
write a file from an input string.
const OSSmartPtr< OSOutput > osoutput
std::string serviceLocation
serviceLocation is the URL of the remote solver when a local solver is not used
std::string errormsg
errormsg is the error that is causing the exception to be thrown
int main(int argc, char *argv[])
int ossslex_init(void **ptr)
OSResult * readOSrL(const std::string &posrl)
Get an OSResult object from an OSrL string.
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 ...
Take an OSResult object and write a string that validates against OSrL.
Bonmin::BqpdSolver::fint fint
Take an OSOption object and write a string that validates against the OSoL schema.
int ossslex_destroy(void *scanner)
std::string writeOSrL(OSResult *theosresult)
create an osrl string from an OSResult object
struct yy_buffer_state * YY_BUFFER_STATE
void getAmplClientOptions(char *options, std::string *solverName, std::string *optionFile, std::string *serviceLocation)
OSOption * osoption
osoption is a pointer to the OSOption object that gets created from the information in the nl file (a...
bool writeSolFile(std::string osrl, ASL *asl, std::string filename)
Convert the solution to AMPL .sol format.
std::string writeOSoL(OSOption *theosoption)
create an osol string from an OSOption object
The Default Solver Class.
std::string runSolver(std::string solverName, std::string osol, OSInstance *osinstance)
This class is used to invoke a solver locally.
void setyyextra(OSCommandLine *oscommandline, void *scanner)
bool setGeneralMessage(std::string message)
Set the general message.
bool m_bWhiteSpace
m_bWhiteSpace is set to true if we write white space in the file
bool setGeneralStatusType(std::string type)
Set the general status type, which can be: success, error, warning.
std::string writeOSiL(const OSInstance *theosinstance)
create an osil string from an OSInstance object
std::string osolFile
osolFile is the name of the file that holds the solver options in OSoL format
ASL * getASL(std::string name)
return a pointer to an ASL object
std::string getFileAsString(const char *fname)
read a file and return contents as a string.
int ossslex(void *scanner)
This class is used to store command line options for the OSSolverService executable and to provide me...
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 information in the nl fil...
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.
YY_BUFFER_STATE osss_scan_string(const char *osss, void *scanner)