38 #include "CoinHelperFunctions.hpp"
40 #include "OSInstance.h"
42 #include "OSParameters.h"
51 WindowsErrorPopupBlocker();
52 cout <<
"Start Building the Model" << endl;
80 osinstance->
addObjective(-1,
"objfunction",
"max", 0.0, 1.0, objcoeff);
101 double *
values =
new double[ 3];
102 int *indexes =
new int[ 3];
103 int *starts =
new int[ 3];
114 indexes, 0, 2, starts, 0, 2);
132 std::vector<ExprNode*> nlNodeVec;
141 nlNodeVariablePoint->
idx=0;
142 nlNodeVec.push_back( nlNodeVariablePoint);
145 nlNodeNumberPoint->
value = 1.0;
146 nlNodeVec.push_back( nlNodeNumberPoint);
149 nlNodeVec.push_back( nlNodePoint);
152 nlNodeVec.push_back( nlNodePoint);
168 nlNodeVariablePoint->
idx=1;
169 nlNodeVec.push_back( nlNodeVariablePoint);
172 nlNodeVariablePoint->
idx=2;
173 nlNodeVec.push_back( nlNodeVariablePoint);
176 nlNodeVec.push_back( nlNodePoint);
190 nlNodeVariablePoint->
idx=2;
191 nlNodeVec.push_back( nlNodeVariablePoint);
194 nlNodeVec.push_back( nlNodePoint);
210 nlNodeVariablePoint->
idx=0;
211 nlNodeVec.push_back( nlNodeVariablePoint);
214 nlNodeVariablePoint->
idx=1;
215 nlNodeVec.push_back( nlNodeVariablePoint);
218 nlNodeVec.push_back( nlNodePoint);
233 nlNodeVariablePoint->
idx=1;
234 nlNodeVec.push_back( nlNodeVariablePoint);
237 nlNodeNumberPoint->
value = 1.0;
238 nlNodeVec.push_back( nlNodeNumberPoint);
241 nlNodeVec.push_back( nlNodePoint);
244 nlNodeVariablePoint->
idx=0;
245 nlNodeVec.push_back( nlNodeVariablePoint);
250 nlNodeVec.push_back( nlNodeMaxPoint);
265 nlNodeVariablePoint->
idx=1;
266 nlNodeVec.push_back( nlNodeVariablePoint);
269 nlNodeNumberPoint->
value = 1.0;
270 nlNodeVec.push_back( nlNodeNumberPoint);
273 nlNodeVariablePoint->
idx=1;
274 nlNodeVec.push_back( nlNodeVariablePoint);
277 nlNodeVec.push_back( nlNodePoint);
292 nlNodeVariablePoint->
idx=1;
293 nlNodeVec.push_back( nlNodeVariablePoint);
296 nlNodeNumberPoint->
value = 2.0;
297 nlNodeVec.push_back( nlNodeNumberPoint);
300 nlNodeVec.push_back( nlNodePoint);
303 nlNodeVariablePoint->
idx=1;
304 nlNodeVec.push_back( nlNodeVariablePoint);
307 nlNodeVec.push_back( nlNodePoint);
310 nlNodeVariablePoint->
idx=1;
311 nlNodeVec.push_back( nlNodeVariablePoint);
314 nlNodeVec.push_back( nlNodePoint);
317 nlNodeVariablePoint->
idx=0;
318 nlNodeVec.push_back( nlNodeVariablePoint);
321 nlNodeVec.push_back( nlNodePoint);
330 cout <<
"End Building the Model: Here is What you built" << endl;
334 cout << osilwriter->
writeOSiL( osinstance);
335 std::cout << osinstance->
printModel( ) << std::endl;
338 cout <<
"Done writing the Model" << endl;
343 cout <<
"Done with garbage collection" << endl;
This file defines the OSnLNode class along with its derived classes.
bool addVariable(int index, std::string name, double lowerBound, double upperBound, char type)
add a variable.
NonlinearExpressions * nonlinearExpressions
nonlinearExpressions is a pointer to a NonlinearExpressions object
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
std::string printModel()
Print the infix representation of the problem.
unsigned int inumberOfChildren
inumberOfChildren is the number of OSnLNode child elements If this number is not fixed, e.g., for a sum node, it is temporarily set to 0
int idx
idx is the index of the variable
std::string errormsg
errormsg is the error that is causing the exception to be thrown
int main(int argc, char *argv[])
The in-memory representation of the <nonlinearExpressions> element.
The OSnLNodeNumber Class.
Used to hold part of the instance in memory.
bool setConstraintNumber(int number)
set the number of constraints.
Nl ** nl
nl is pointer to an array of Nl object pointers
bool bDeleteArrays
bDeleteArrays is true if we delete the arrays in garbage collection set to true by default ...
OSnLNode * createExpressionTreeFromPostfix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in postfix format and create a scalar-valued OS...
The OSnLNodeVariable Class.
bool setObjectiveNumber(int number)
set the number of objectives.
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.
double value
value is the value of the number
a sparse vector data structure
OSnLNode ** m_mChildren
m_mChildren holds all the operands, that is, nodes that the current node operates on...
OSnLNode * m_treeRoot
m_treeRoot holds the root node (of OSnLNode type) of the expression tree.
InstanceData * instanceData
A pointer to an InstanceData object.
The in-memory representation of the <nl> element.
int idx
idx holds the row index of the nonlinear expression
bool setInstanceSource(std::string source)
set the instance source.
bool setInstanceDescription(std::string description)
set the instance description.
std::string writeOSiL(const OSInstance *theosinstance)
create an osil string from an OSInstance object
ScalarExpressionTree * osExpressionTree
osExpressionTree contains the root of the ScalarExpressionTree
double * values
values holds a double array of nonzero values.
int numberOfNonlinearExpressions
numberOfNonlinearExpressions is the number of <nl> elements in the <nonlinearExpressions> element...
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..
The OSnLNode Class for nonlinear expressions.
used for throwing exceptions.
Take an OSInstance object and write a string that validates against the OSiL schema.