37 #include "CoinHelperFunctions.hpp"
39 #include "OSInstance.h"
41 #include "OSParameters.h"
55 WindowsErrorPopupBlocker();
56 cout <<
"Start Building the Model" << endl;
82 osinstance->
addObjective(-1,
"objfunction",
"max", 0.0, 1.0, objcoeff);
103 double *
values =
new double[ 3];
104 int *indexes =
new int[ 3];
105 int *starts =
new int[ 3];
116 indexes, 0, 2, starts, 0, 2);
129 std::vector<OSnLNode*> nlNodeVec;
138 nlNodeVariablePoint->
idx=0;
139 nlNodeVec.push_back( nlNodeVariablePoint);
142 nlNodeNumberPoint->
value = 1.0;
143 nlNodeVec.push_back( nlNodeNumberPoint);
146 nlNodeVec.push_back( nlNodePoint);
149 nlNodeVec.push_back( nlNodePoint);
165 nlNodeVariablePoint->
idx=0;
166 nlNodeVec.push_back( nlNodeVariablePoint);
169 nlNodeVariablePoint->
idx=1;
170 nlNodeVec.push_back( nlNodeVariablePoint);
173 nlNodeVec.push_back( nlNodePoint);
187 nlNodeVariablePoint->
idx=0;
188 nlNodeVec.push_back( nlNodeVariablePoint);
191 nlNodeVariablePoint->
idx=1;
192 nlNodeVec.push_back( nlNodeVariablePoint);
195 nlNodeVec.push_back( nlNodePoint);
210 nlNodeVariablePoint->
idx=1;
211 nlNodeVec.push_back( nlNodeVariablePoint);
214 nlNodeNumberPoint->
value = 1.0;
215 nlNodeVec.push_back( nlNodeNumberPoint);
218 nlNodeVec.push_back( nlNodePoint);
221 nlNodeVariablePoint->
idx=0;
222 nlNodeVec.push_back( nlNodeVariablePoint);
227 nlNodeVec.push_back( nlNodeMaxPoint);
242 nlNodeVariablePoint->
idx=1;
243 nlNodeVec.push_back( nlNodeVariablePoint);
246 nlNodeNumberPoint->
value = 1.0;
247 nlNodeVec.push_back( nlNodeNumberPoint);
250 nlNodeVariablePoint->
idx=1;
251 nlNodeVec.push_back( nlNodeVariablePoint);
254 nlNodeVec.push_back( nlNodePoint);
269 nlNodeVariablePoint->
idx=1;
270 nlNodeVec.push_back( nlNodeVariablePoint);
273 nlNodeNumberPoint->
value = 2.0;
274 nlNodeVec.push_back( nlNodeNumberPoint);
277 nlNodeVec.push_back( nlNodePoint);
280 nlNodeVariablePoint->
idx=1;
281 nlNodeVec.push_back( nlNodeVariablePoint);
284 nlNodeVec.push_back( nlNodePoint);
287 nlNodeVariablePoint->
idx=1;
288 nlNodeVec.push_back( nlNodeVariablePoint);
291 nlNodeVec.push_back( nlNodePoint);
294 nlNodeVariablePoint->
idx=0;
295 nlNodeVec.push_back( nlNodeVariablePoint);
298 nlNodeVec.push_back( nlNodePoint);
307 cout <<
"End Building the Model: Here is What you built" << endl;
311 cout << osilwriter->
writeOSiL( osinstance);
312 std::cout << osinstance->
printModel( ) << std::endl;
315 cout <<
"Done writing the Model" << endl;
320 cout <<
"Done with garbage collection" << endl;
321 cout <<
"Program terminates normally" << 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 OSnLNodeNumber Class.
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 to hold the instance in memory.
used for throwing exceptions.
Take an OSInstance object and write a string that validates against the OSiL schema.