19 #include "OSInstance.h"
25 #ifdef COIN_HAS_KNITRO
42 #ifdef COIN_HAS_BONMIN
46 #ifdef COIN_HAS_COUENNE
59 using std::ostringstream;
65 std::string
runSolver(std::string solverName, std::string osol,
72 if (solverType == NULL)
73 throw ErrorClass(
"No appropriate solver found");
76 solverType->
osol = osol;
80 std::string resultString = solverType->
osrl;
82 if (solverType != NULL)
89 if (solverType != NULL)
105 if (solverType == NULL)
106 throw ErrorClass(
"No appropriate solver found");
113 std::string resultString = solverType->
osrl;
114 if (solverType != NULL)
121 if (solverType != NULL)
130 std::string
runSolver(std::string solverName, std::string osol,
139 osinstance = osilreader->
readOSiL(osil);
142 if (solverType == NULL)
143 throw ErrorClass(
"No appropriate solver found");
146 solverType->
osol = osol;
150 std::string resultString = solverType->
osrl;
151 if (solverType != NULL)
160 if (solverType != NULL)
180 osinstance = osilreader->
readOSiL(osil);
183 if (solverType == NULL)
184 throw ErrorClass(
"No appropriate solver found");
191 std::string resultString = solverType->
osrl;
192 if (solverType != NULL)
201 if (solverType != NULL)
217 if (solverName ==
"")
219 if (osinstance == NULL)
221 "there was a NULL instance sent to buildSolver");
234 solverName =
"bonmin";
246 solverName =
"ipopt";
257 if (solverName.find(
"ipopt") != std::string::npos)
260 #ifdef COIN_HAS_IPOPT
264 throw ErrorClass(
"the Ipopt solver requested is not present");
268 else if (solverName.find(
"lindo") != std::string::npos)
271 #ifdef COIN_HAS_LINDO
275 throw ErrorClass(
"the Lindo solver requested is not present");
279 else if (solverName.find(
"clp") != std::string::npos)
285 else if (solverName.find(
"cplex") != std::string::npos)
291 throw ErrorClass(
"the Cplex solver requested is not present");
295 else if (solverName.find(
"glpk") != std::string::npos)
301 throw ErrorClass(
"the GLPK solver requested is not present");
305 else if (solverName.find(
"dylp") != std::string::npos)
311 throw ErrorClass(
"the DyLP solver requested is not present");
315 else if (solverName.find(
"symphony") != std::string::npos)
317 #ifdef COIN_HAS_SYMPHONY
321 throw ErrorClass(
"the SYMPHONY solver requested is not present");
325 else if (solverName.find(
"knitro") != std::string::npos)
327 #ifdef COIN_HAS_KNITRO
331 throw ErrorClass(
"the Knitro solver requested is not present");
335 else if (solverName.find(
"vol") != std::string::npos)
341 throw ErrorClass(
"the Vol solver requested is not present");
345 else if (solverName.find(
"bonmin") != std::string::npos)
348 #ifdef COIN_HAS_BONMIN
352 throw ErrorClass(
"the Bonmin solver requested is not present");
356 else if (solverName.find(
"couenne") != std::string::npos)
359 #ifdef COIN_HAS_COUENNE
363 throw ErrorClass(
"the Couenne solver requested is not present");
367 else if (solverName.find(
"cbc") != std::string::npos)
373 else if (solverName.find(
"gurobi") != std::string::npos)
379 throw ErrorClass(
"the Gurobi solver requested is not present");
383 else if (solverName.find(
"mosek") != std::string::npos)
389 throw ErrorClass(
"the Mosek solver requested is not present");
393 else if (solverName.find(
"soplex") != std::string::npos)
395 #ifdef COIN_HAS_SOPLEX
399 throw ErrorClass(
"the Soplex solver requested is not present");
403 else if (solverName.find(
"xpress") != std::string::npos)
409 throw ErrorClass(
"the Xpress solver requested is not present");
413 else if (solverName.find(
"csdp") != std::string::npos)
420 throw ErrorClass(
"the CSDP solver requested is not present");
426 std::string errorMessage;
427 errorMessage =
"solver " + solverName +
" is not supported";
436 if (solverType != NULL)
int getNumberOfIntegerVariables()
getNumberOfIntegerVariables
the LindoSolver class solves problems using Lindo.
The CsdpSolver class solves problems using Csdp.
The CouenneSolver class solves problems using Ipopt.
std::string osrl
osrl holds the solution or result of the model
the KnitroSolver class solves problems using Knitro.
OSInstance * readOSiL(const std::string &osil)
parse the OSiL model instance.
The IpoptSolver class solves problems using Ipopt.
int getNumberOfNonlinearExpressions()
Get number of nonlinear expressions.
std::string osol
osol holds the options for the solver
virtual void solve()=0
solve is a virtual function – the actual solvers will implement their own solve method ...
Used to read an OSiL string.
DefaultSolver * selectSolver(std::string solverName, OSInstance *osinstance)
A method to select the solver.
OSOption * osoption
osoption holds the solver options in-memory as 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.
OSInstance * osinstance
osinstance holds the problem instance in-memory as an OSInstance object
std::string sSolverName
sSolverName is the name of the Coin solver used, e.g.
virtual void setSolverOptions()=0
setSolverOptions is a virtual function – the actual solvers will implement their own setSolverOptions...
int getNumberOfQuadraticTerms()
Get the number of specified (usually nonzero) qTerms in the quadratic coefficients.
Implements a solve method for the Coin solvers.
The BonminSolver class solves problems using Ipopt.
virtual void buildSolverInstance()=0
buildSolverInstance is a virtual function – the actual solvers will implement their own buildSolverIn...
The in-memory representation of an OSiL instance..
used for throwing exceptions.
int getNumberOfBinaryVariables()
getNumberOfBinaryVariables