33 using std::ostringstream;
71 std::string osol =
"";
86 if(
sSolverName.find(
"lindo") != std::string::npos)
89 bool bLindoIsPresent =
false;
91 bLindoIsPresent =
true;
94 if(bLindoIsPresent ==
false)
throw ErrorClass(
"the Lindo solver requested is not present");
112 if(
sSolverName.find(
"cplex") != std::string::npos)
119 if(
sSolverName.find(
"glpk") != std::string::npos)
128 if(
sSolverName.find(
"ipopt") != std::string::npos)
132 bool bIpoptIsPresent =
false;
135 #ifdef COIN_HAS_IPOPT
136 bIpoptIsPresent =
true;
138 ipoptSolver->
osol = osol;
140 ipoptSolver->
solve();
141 return ipoptSolver->
osrl ;
143 if(bIpoptIsPresent ==
false)
throw ErrorClass(
"the Ipopt solver requested is not present");
148 if(
sSolverName.find(
"symphony") != std::string::npos)
155 if(
sSolverName.find(
"dylp") != std::string::npos)
162 throw ErrorClass(
"a supported solver is not present");
194 return osagent->
solve(osil, osol);
202 ostringstream outStr;
215 std::string *varNames;
216 varNames =
new std::string[
numVar];
218 for(i = 0; i <
numVar; i++)
222 varNames[ i] = outStr.str();
234 for(i = 0; i <
numVar; i++)
239 std::string maxOrMin =
"min";
240 if(
objType ==
true) maxOrMin =
"max";
244 std::string *conNames;
245 conNames =
new std::string[
numCon];
248 for(i = 0; i <
numCon; i++)
252 conNames[ i] = outStr.str();
the LindoSolver class solves problems using Lindo.
Used by a client to invoke a remote solver.
bool addVariable(int index, std::string name, double lowerBound, double upperBound, char type)
add a variable.
bool objType
objType indicates whether or not we have a max (1) or a min (0)
double * qVal
qVal is a pointer to the coefficient value of each of the quadratic terms.
bool setLinearConstraintCoefficients(int numberOfValues, bool isColumnMajor, double *values, int valuesBegin, int valuesEnd, int *indexes, int indexesBegin, int indexesEnd, int *starts, int startsBegin, int startsEnd)
set linear constraint coefficients
double * vl
vl is a pointer to the lower bounds on the varialbes
std::string osrl
osrl holds the solution or result of the model
OSInstance * osinstance
osinstance is a pointer to an OSInstance object that gets created from the MATLAB data structures ...
std::string errormsg
errormsg is the error that is causing the exception to be thrown
void createOSInstance()
Create an OSInstance.
bool setQuadraticTermsInNonlinearExpressions(int number, int *rowIndexes, int *varOneIndexes, int *varTwoIndexes, double *coefficients)
set quadratic terms in nonlinearExpressions
SparseMatrix * sparseMat
sparseMat is a pointer to an OS Sprase Matrix data structure
std::string solve(std::string osil, std::string osol)
implement the solve() method which is a virtual function in OShL, this is synchronous ...
double * vu
vu is a pointer to the upper bounds on the variables
int numCon
numCon is the number of constraints in the problem
std::string sAgentAddress
is the address of the solver service
virtual void solve()
solve results in an instance being read into the Ipopt data structures and optimize ...
The IpoptSolver class solves problems using Ipopt.
int * qIndex2
qIndex2 is a pointer to the index of the second variable in each of the quadratic terms ...
int startSize
startSize is the dimension of the starts array
double * bl
bl is a pointer to the lower bounds on the constraints
int * indexes
indexes holds an integer array of rowIdx (or colIdx) elements in coefMatrix (AMatrix).
std::string osol
osol holds the options for the solver
bool setInstanceName(std::string name)
set the instance name.
virtual void solve()=0
solve is a virtual function – the actual solvers will implement their own solve method ...
std::string sSolverName
sSolverName is the name of the solver
bool setConstraintNumber(int number)
set the number of constraints.
int valueSize
valueSize is the dimension of the indexes and values arrays
bool setObjectiveNumber(int number)
set the number of objectives.
int numQTerms
numQTerms is the number of quadratic terms
bool addConstraint(int index, std::string name, double lowerBound, double upperBound, double constant)
add a constraint.
bool addObjective(int index, std::string name, std::string maxOrMin, double constant, double weight, SparseVector *objectiveCoefficients)
add an objective.
a sparse vector data structure
std::string solve()
Solve the problem instance.
bool m_bWhiteSpace
m_bWhiteSpace is set to true if we write white space in the file
double * values
values holds a double array of value elements in coefMatrix (AMatrix), which contains nonzero element...
OSInstance * osinstance
osinstance holds the problem instance in-memory as an OSInstance object
int * qIndex1
qIndex1 is a pointer to the index of the first variable in each of the quadratic terms ...
int numVar
numVar is the number of variables in the problem
int * qRows
qRows is a pointer to the row index of each quadratic term
OSMatlab()
the OSMatlab class constructor
std::string instanceName
instanceName is the name of the problem instance
std::string sSolverName
sSolverName is the name of the Coin solver used, e.g.
bool setInstanceDescription(std::string description)
set the instance description.
std::string writeOSiL(const OSInstance *theosinstance)
create an osil string from an OSInstance object
Implements a solve method for the Coin solvers.
int * starts
starts holds an integer array of start elements in coefMatrix (AMatrix), which points to the start of...
double * values
values holds a double array of nonzero values.
DefaultSolver * solverType
solverType is the a pointer to the sovler that will be requested
char * varType
varType is a pointer to the variable type eg C, B, I
std::string osil
is the osil instance that gets created from the MATLAB data structures
int * indexes
indexes holds an integer array of indexes whose corresponding values are nonzero. ...
bool setVariableNumber(int number)
set the number of variables.
The in-memory representation of an OSiL instance..
used for throwing exceptions.
double * bu
bu is a pointer to the upper bounds on the constraints
~OSMatlab()
the OSMatlab class destructor
Take an OSInstance object and write a string that validates against the OSiL schema.
double * obj
obj is a pointer to the objective function coefficients