The in-memory representation of an OSiL instance.. More...
#include <OSInstance.h>
Public Member Functions | |
OSInstance () | |
The OSInstance class constructor. | |
~OSInstance () | |
The OSInstance class destructor. | |
std::string | getInstanceName () |
Get instance name. | |
std::string | getInstanceSource () |
Get instance source. | |
std::string | getInstanceDescription () |
Get instance description. | |
int | getVariableNumber () |
Get variable number. | |
std::string * | getVariableNames () |
Get variable names. | |
double * | getVariableInitialValues () |
Get variable initial values. | |
std::string * | getVariableInitialStringValues () |
Get variable initial std::string values. | |
char * | getVariableTypes () |
Get variable types. | |
int | getNumberOfIntegerVariables () |
getNumberOfIntegerVariables | |
int | getNumberOfBinaryVariables () |
getNumberOfBinaryVariables | |
double * | getVariableLowerBounds () |
Get variable lower bounds. | |
double * | getVariableUpperBounds () |
Get variable upper bounds. | |
int | getObjectiveNumber () |
Get objective number. | |
std::string * | getObjectiveNames () |
Get objective names. | |
std::string * | getObjectiveMaxOrMins () |
Get objective maxOrMins. | |
int * | getObjectiveCoefficientNumbers () |
Get objective coefficient number. | |
double * | getObjectiveConstants () |
Get objective constants. | |
double * | getObjectiveWeights () |
Get objective weights. | |
SparseVector ** | getObjectiveCoefficients () |
Get objective coefficients. | |
double ** | getDenseObjectiveCoefficients () |
getDenseObjectiveCoefficients. | |
int | getConstraintNumber () |
Get constraint number. | |
std::string * | getConstraintNames () |
Get constraint names. | |
double * | getConstraintLowerBounds () |
Get constraint lower bounds. | |
double * | getConstraintUpperBounds () |
Get constraint upper bounds. | |
char * | getConstraintTypes () |
Get constraint types. | |
int | getLinearConstraintCoefficientNumber () |
Get number of specified (usually nonzero) linear constraint coefficient values. | |
bool | getLinearConstraintCoefficientMajor () |
Get whether the constraint coefficients is in column major (true) or row major (false). | |
SparseMatrix * | getLinearConstraintCoefficientsInColumnMajor () |
Get linear constraint coefficients in column major. | |
SparseMatrix * | getLinearConstraintCoefficientsInRowMajor () |
Get linear constraint coefficients in row major. | |
int | getNumberOfQuadraticTerms () |
Get the number of specified (usually nonzero) qTerms in the quadratic coefficients. | |
QuadraticTerms * | getQuadraticTerms () |
Get all the quadratic terms in the instance. | |
int * | getQuadraticRowIndexes () |
Get the indexes of rows which have a quadratic term. | |
int | getNumberOfQuadraticRowIndexes () |
Get the number of rows which have a quadratic term. | |
int | getNumberOfNonlinearExpressions () |
Get number of nonlinear expressions. | |
OSExpressionTree * | getNonlinearExpressionTree (int rowIdx) |
Get the expression tree for a given row index. | |
OSExpressionTree * | getNonlinearExpressionTreeMod (int rowIdx) |
Get the expression tree for a given row index for the modified expression trees (quadratic terms added). | |
std::vector< OSnLNode * > | getNonlinearExpressionTreeInPostfix (int rowIdx) |
Get the postfix tokens for a given row index. | |
std::vector< OSnLNode * > | getNonlinearExpressionTreeModInPostfix (int rowIdx) |
Get the postfix tokens for a given row index for the modified Expression Tree (quadratic terms added). | |
std::vector< OSnLNode * > | getNonlinearExpressionTreeInPrefix (int rowIdx) |
Get the prefix tokens for a given row index. | |
std::vector< OSnLNode * > | getNonlinearExpressionTreeModInPrefix (int rowIdx) |
Get the prefix tokens for a given row index for the modified Expression Tree (quadratic terms added). | |
int | getNumberOfNonlinearObjectives () |
int | getNumberOfNonlinearConstraints () |
std::map< int, OSExpressionTree * > | getAllNonlinearExpressionTrees () |
std::map< int, OSExpressionTree * > | getAllNonlinearExpressionTreesMod () |
int * | getNonlinearExpressionTreeIndexes () |
Get all the nonlinear expression tree indexes, i.e. | |
int | getNumberOfNonlinearExpressionTreeIndexes () |
Get the number of unique Nonlinear exrpession tree indexes. | |
int * | getNonlinearExpressionTreeModIndexes () |
Get all the nonlinear expression tree indexes, i.e. | |
int | getNumberOfNonlinearExpressionTreeModIndexes () |
Get the number of unique Nonlinear exrpession tree indexes after modifying the expression tree to contain quadratic terms. | |
bool | setInstanceSource (std::string source) |
set the instance source. | |
bool | setInstanceDescription (std::string description) |
set the instance description. | |
bool | setInstanceName (std::string name) |
set the instance name. | |
bool | setVariableNumber (int number) |
set the variable number. | |
bool | addVariable (int index, std::string name, double lowerBound, double upperBound, char type, double init, std::string initString) |
add a variable. | |
bool | setVariables (int number, std::string *names, double *lowerBounds, double *upperBounds, char *types, double *inits, std::string *initsString) |
set all the variable related elements. | |
bool | setObjectiveNumber (int number) |
set the objective number. | |
bool | addObjective (int index, std::string name, std::string maxOrMin, double constant, double weight, SparseVector *objectiveCoefficients) |
add an objective. | |
bool | setObjectives (int number, std::string *names, std::string *maxOrMins, double *constants, double *weights, SparseVector **objectitiveCoefficients) |
set all the objectives related elements. | |
bool | setConstraintNumber (int number) |
set the constraint number. | |
bool | addConstraint (int index, std::string name, double lowerBound, double upperBound, double constant) |
add a constraint. | |
bool | setConstraints (int number, std::string *names, double *lowerBounds, double *upperBounds, double *constants) |
set all the constraint related elements. | |
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 | |
bool | setQuadraticTerms (int number, int *rowIndexes, int *varOneIndexes, int *varTwoIndexes, double *coefficients, int begin, int end) |
set quadratic terms | |
bool | setQuadraticTermsInNonlinearExpressions (int number, int *rowIndexes, int *varOneIndexes, int *varTwoIndexes, double *coefficients) |
set quadratic terms in nonlinearExpressions | |
bool | initializeNonLinearStructures () |
Initialize the data structures for the nonlinear API. | |
double | calculateFunctionValue (int idx, double *x, bool new_x) |
Calculate the function value for function (constraint or objective) indexed by idx. | |
double * | calculateAllConstraintFunctionValues (double *x, double *objLambda, double *conLambda, bool new_x, int highestOrder) |
Calculate all of the constraint function values. | |
double * | calculateAllConstraintFunctionValues (double *x, bool new_x) |
Calculate all of the constraint function values, we are overloading this function and this version of the method will not use any AD and will evaluate function values from the OS Expression Tree. | |
double * | calculateAllObjectiveFunctionValues (double *x, double *objLambda, double *conLambda, bool new_x, int highestOrder) |
Calculate all of the objective function values. | |
double * | calculateAllObjectiveFunctionValues (double *x, bool new_x) |
Calculate all of the objective function values, we are overloading this function and this version of the method will not use any AD and will evaluate function values from the OS Expression Tree. | |
SparseJacobianMatrix * | calculateAllConstraintFunctionGradients (double *x, double *objLambda, double *conLambda, bool new_x, int highestOrder) |
Calculate the gradient of all constraint functions. | |
SparseVector * | calculateConstraintFunctionGradient (double *x, double *objLambda, double *conLambda, int idx, bool new_x, int highestOrder) |
Calculate the gradient of the constraint function indexed by idx. | |
SparseVector * | calculateConstraintFunctionGradient (double *x, int idx, bool new_x) |
Calculate the gradient of the constraint function indexed by idx this function is overloaded. | |
double ** | calculateAllObjectiveFunctionGradients (double *x, double *objLambda, double *conLambda, bool new_x, int highestOrder) |
Calculate the gradient of all objective functions. | |
double * | calculateObjectiveFunctionGradient (double *x, double *objLambda, double *conLambda, int objIdx, bool new_x, int highestOrder) |
Calculate the gradient of the objective function indexed by objIdx. | |
double * | calculateObjectiveFunctionGradient (double *x, int objIdx, bool new_x) |
Calculate the gradient of the objective function indexed by objIdx this function is overloaded. | |
SparseHessianMatrix * | calculateLagrangianHessian (double *x, double *objLambda, double *conLambda, bool new_x, int highestOrder) |
Calculate the Hessian of the Lagrangian Expression Tree This method will build the CppAD expression tree for only the first iteration Use this method on if the value of x does not affect the operations sequence. | |
SparseHessianMatrix * | calculateHessian (double *x, int idx, bool new_x) |
Calculate the Hessian of a constraint or objective function. | |
bool | getSparseJacobianFromColumnMajor () |
bool | getSparseJacobianFromRowMajor () |
OSExpressionTree * | getLagrangianExpTree () |
std::map< int, int > | getAllNonlinearVariablesIndexMap () |
SparseHessianMatrix * | getLagrangianHessianSparsityPattern () |
bool | addQTermsToExressionTree () |
SparseJacobianMatrix * | getJacobianSparsityPattern () |
void | duplicateExpressionTreesMap () |
duplicate the map of expression trees. | |
bool | createCppADFun (std::vector< double > vdX) |
Create the a CppAD Function object: this is a function where the domain is the set of variables for the problem and the range is the objective function plus constraints. | |
std::vector< double > | forwardAD (int p, std::vector< double > vdX) |
Perform an AD forward sweep. | |
std::vector< double > | reverseAD (int p, std::vector< double > vdlambda) |
Perform an AD reverse sweep. | |
bool | getIterateResults (double *x, double *objLambda, double *conLambda, bool new_x, int highestOrder) |
end revised AD code | |
bool | getZeroOrderResults (double *x, double *objLambda, double *conLambda) |
Calculate function values. | |
bool | getFirstOrderResults (double *x, double *objLambda, double *conLambda) |
Calculate first derivatives. | |
bool | getSecondOrderResults (double *x, double *objLambda, double *conLambda) |
Calculate second derivatives. | |
bool | initForAlgDiff () |
This should be called by nonlinear solvers using callback functions. | |
bool | initObjGradients () |
This should be called by initForAlgDiff(). | |
Public Attributes | |
InstanceHeader * | instanceHeader |
A pointer to an InstanceHeader object. | |
InstanceData * | instanceData |
A pointer to an InstanceData object. | |
CppAD::ADFun< double > * | Fad |
F is a CppAD function the range space is the objective + constraints functions, x is the domeain space. | |
bool | bUseExpTreeForFunEval |
bUseExpTreeForFunEval is set to true if you wish to use the OS Expression Tree for function evaluations instead of AD -- false by default. | |
Private Member Functions | |
bool | processVariables () |
process variables. | |
bool | processObjectives () |
process objectives. | |
bool | processConstraints () |
process constraints. | |
bool | processLinearConstraintCoefficients () |
process linear constraint coefficients. | |
Private Attributes | |
std::string | m_sInstanceName |
m_sInstanceName holds the instance name. | |
std::string | m_sInstanceSource |
m_sInstanceSource holds the instance source. | |
std::string | m_sInstanceDescription |
m_sInstanceDescription holds the instance description. | |
bool | m_bProcessVariables |
m_bProcessVariables holds whether the variables are processed. | |
int | m_iVariableNumber |
m_iVariableNumber holds the variable number. | |
int | m_iNumberOfIntegerVariables |
m_iNumberOfIntegerVariables holds the number of integer variables. | |
int | m_iNumberOfBinaryVariables |
m_iNumberOfBinaryVariables holds the number of binary variables. | |
int | m_iNumberOfQuadraticRowIndexes |
m_iNumberOfQuadraticRowIndexes holds the number of distinct rows and objectives with quadratic terms. | |
bool | m_bQuadraticRowIndexesProcessed |
m_bQuadraticRowIndexesProcessed is true if getQuadraticRowIndexes() has been called. | |
int * | m_miQuadRowIndexes |
m_miQuadRowIndexes is an integer pointer to the distinct rows indexes with a quadratic term. | |
int | m_iNumberOfNonlinearExpressionTreeIndexes |
m_iNumberOfNonlinearExpressionTreeIndexes holds the number of distinct rows and objectives with nonlinear terms. | |
bool | m_bNonlinearExpressionTreeIndexesProcessed |
m_bNonlinearExpressionTreeIndexesProcessed is true if getNonlinearExpressionTreeIndexes has been called. | |
int * | m_miNonlinearExpressionTreeIndexes |
m_miNonlinearExpressionTreeIndexes is an integer pointer to the distinct rows indexes in the nonlinear expression tree map. | |
int | m_iNumberOfNonlinearExpressionTreeModIndexes |
m_iNumberOfNonlinearExpressionTreeModIndexes holds the number of distinct rows and objectives with nonlinear terms including quadratic terms added to the nonlinear expression trees. | |
bool | m_bNonlinearExpressionTreeModIndexesProcessed |
m_bNonlinearExpressionTreeModIndexesProcessed is true if getNonlinearExpressionTreeModIndexes has been called. | |
int * | m_miNonlinearExpressionTreeModIndexes |
m_miNonlinearExpressionTreeModIndexes is an integer pointer to the distinct rows indexes in the modified expression tree map. | |
std::string * | m_msVariableNames |
m_msVariableNames holds an array of variable names. | |
double * | m_mdVariableInitialValues |
m_mdVariableInitialValues holds a double array of the initial variable values. | |
std::string * | m_msVariableInitialStringValues |
m_msVariableInitialStringValues holds a std::string array of the initial variable values. | |
char * | m_mcVariableTypes |
m_mcVariableTypes holds a char array of variable types (default = 'C'). | |
double * | m_mdVariableLowerBounds |
m_mdVariableLowerBounds holds a double array of variable lower bounds (default = 0.0). | |
double * | m_mdVariableUpperBounds |
m_mdVariableUpperBounds holds a double array of variable upper bounds (default = INF). | |
bool | m_bProcessObjectives |
m_bProcessObjectives holds whether the objectives are processed. | |
int | m_iObjectiveNumber |
m_iObjectiveNumber is the number of objective functions. | |
int | m_iObjectiveNumberNonlinear |
m_iObjectiveNumber is the number of objective functions with a nonlinear term. | |
std::string * | m_msObjectiveNames |
m_msObjectiveNames holds an array of objective names. | |
std::string * | m_msMaxOrMins |
m_msMaxOrMins holds a std::string array of objective maxOrMins ("max" or "min"). | |
int * | m_miNumberOfObjCoef |
m_miNumberOfObjCoef holds an integer array of number of objective coefficients (default = 0.0). | |
double * | m_mdObjectiveConstants |
m_mdObjectiveConstants holds an array of objective constants (default = 0.0). | |
double * | m_mdObjectiveWeights |
m_mdObjectiveWeights holds an array of objective weights (default = 1.0). | |
SparseVector ** | m_mObjectiveCoefficients |
m_mObjectiveCoefficients holds an array of objective coefficients, one set of objective coefficients for each objective. | |
bool | m_bGetDenseObjectives |
m_bGetDenseObjectives holds whether the dense objective functions are processed. | |
double ** | m_mmdDenseObjectiveCoefficients |
m_mmdDenseObjectiveCoefficients holds an array of pointers, each pointer points to a vector of dense objective function coefficients | |
bool | m_bProcessConstraints |
m_bProcessConstraints holds whether the constraints are processed. | |
int | m_iConstraintNumber |
m_iConstraintNumber is the number of constraints. | |
int | m_iConstraintNumberNonlinear |
m_iConstraintNumberNonlinear is the number of constraints that have a nonlinear term. | |
std::string * | m_msConstraintNames |
m_msConstraintNames holds an array of constraint names. | |
double * | m_mdConstraintLowerBounds |
m_mdConstraintLowerBounds holds an array of constraint lower bounds (default = -INF). | |
double * | m_mdConstraintUpperBounds |
m_mdConstraintUpperBounds holds an array of constraint upper bounds (default = INF). | |
double * | m_mdConstraintConstants |
m_mdConstraintConstants holds an array of constraint constants (default = 0.0). | |
char * | m_mcConstraintTypes |
m_mcConstraintTypes holds a char array of constraint types (R for range; L for <=; G for >=; E for =; U for unconstrained) | |
bool | m_bProcessLinearConstraintCoefficients |
m_bProcessLinearConstraintCoefficients holds whether the linear constraint coefficients are processed. | |
int | m_iLinearConstraintCoefficientNumber |
m_iLinearConstraintCoefficientNumber holds the number of specified (usually nonzero) linear constraint coefficient values. | |
bool | m_bColumnMajor |
m_bColumnMajor holds whether the linear constraint coefficients are stored in column major. | |
bool | m_binitForAlgDiff |
m_binitForAlgDiff is true if initForAlgDiff() has been called. | |
SparseMatrix * | m_linearConstraintCoefficientsInColumnMajor |
m_linearConstraintCoefficientsInColumnMajor holds the standard 3 array data structure for linear constraint coefficients (starts, indexes and values) in column major. | |
SparseMatrix * | m_linearConstraintCoefficientsInRowMajor |
m_linearConstraintCoefficientsInRowMajor holds the standard 3 array data structure for linear constraint coefficients (starts, indexes and values) in row major. | |
bool | m_bProcessQuadraticTerms |
m_bProcessQuadraticTerms holds whether the quadratic terms are processed. | |
int | m_iQuadraticTermNumber |
m_iQuadraticTermNumber holds the number of specified (usually nonzero) qTerms in the quadratic coefficients. | |
double * | m_mdConstraintFunctionValues |
m_mdConstraintFunctionValues holds a double array of constraint function values -- the size of the array is equal to getConstraintNumber(). | |
double * | m_mdObjectiveFunctionValues |
m_mdObjectiveFunctionValues holds a double array of objective function values -- the size of the array is equal to getObjectiveNumber(). | |
int | m_iJacValueSize |
m_iJacValueSize is the number of nonzero partial derivates in the Jacobian. | |
int * | m_miJacStart |
m_miJacStart holds a int array of starts for the Jacobian matrix in sparse form (row major). | |
int * | m_miJacIndex |
m_miJacIndex holds a int array of variable indices for the Jacobian matrix in sparse form (row major). | |
double * | m_mdJacValue |
m_mdJacValue holds a double array of partial derivatives for the Jacobian matrix in sparse form (row major). | |
int * | m_miJacNumConTerms |
m_miJacNumConTerms holds a int array of the number of constant terms (gradient does not change) for the Jacobian matrix in sparse form (row major). | |
SparseJacobianMatrix * | m_sparseJacMatrix |
m_sparseJacMatrix is the Jacobian matrix stored in sparse matrix format | |
int | m_iHighestTaylorCoeffOrder |
m_iHighestTaylorCoeffOrder is the order of highest calculated Taylor coefficient | |
QuadraticTerms * | m_quadraticTerms |
m_quadraticTerms the data structure for all the quadratic terms in the instance. | |
bool | m_bQTermsAdded |
m_bQTermsAdded is true if we add the quadratic terms to the expression tree | |
unsigned int | m_iNumberOfNonlinearVariables |
m_iNumberOfNonlinearVariables is the number of variables that appear in a nonlinear expression. | |
bool | m_bProcessNonlinearExpressions |
m_bProcessNonlinearExpressions holds whether the nonlinear expressions are processed. | |
int | m_iNonlinearExpressionNumber |
m_iNonlinearExpressionNumber holds the number of nonlinear expressions. | |
int * | m_miNonlinearExpressionIndexes |
m_miNonlinearExpressionIndexes holds an integer array of nonlinear expression indexes, negative indexes correspond to objectives. | |
bool | m_bProcessExpressionTrees |
m_bProcessExpressionTrees is true if the expression trees have been processed. | |
bool | m_bProcessExpressionTreesMod |
m_bProcessExpressionTreesMod is true if the modified expression trees have been processed. | |
std::map< int, OSExpressionTree * > | m_mapExpressionTrees |
m_mapExpressionTrees holds a hash map of expression tree pointers, with the key being the row index and value being the expression tree representing the nonlinear expression of that row. | |
std::map< int, int > | m_mapCppADFunRangeIndex |
OSExpressionTree * | m_LagrangianExpTree |
m_LagrangianExpTree is an OSExpressionTree object that is the expression tree for the Lagrangian function. | |
bool | m_bLagrangianExpTreeCreated |
m_bLagrangianHessionCreated is true if a Lagrangian function for the Hessian has been created | |
SparseHessianMatrix * | m_LagrangianSparseHessian |
m_LagrangianSparseHessian is the Hessian Matrix of the Lagrangian function in sparse format | |
bool | m_bLagrangianSparseHessianCreated |
m_bLagrangianSparseHessianCreated is true if the sparse Hessian Matrix for the Lagrangian was created | |
std::map< int, int > | m_mapAllNonlinearVariablesIndex |
m_mapAllNonlinearVariablesIndexMap is a map of the variables in the Lagrangian function | |
int * | m_miNonLinearVarsReverseMap |
m_miNonLinearVarsReverseMap maps the nonlinear variable number back into the original variable space | |
bool | m_bAllNonlinearVariablesIndex |
m_bAllNonlinearVariablesIndexMap is true if the map of the variables in the Lagrangian function has been constructed | |
std::map< int, OSExpressionTree * > | m_mapExpressionTreesMod |
m_mapExpressionTreesMod holds a map of expression trees, with the key being the row index and value being the expression tree representing a modification of the nonlinear expression of that row. | |
bool | m_bCppADFunIsCreated |
m_bCppADFunIsCreated is true if we have created the OSInstanc CppAD Function | |
bool | m_bCppADTapesBuilt |
is true if a CppAD Expresion Tree has been built for each row and objective with a nonlinear expression. | |
bool | m_bCppADMustReTape |
is true if a CppAD Expresion Tree has an expression that can change depending on the value of the input, e.g. | |
bool | m_bDuplicateExpressionTreesMap |
m_bDuplicateExpressionTreeMap is true if m_mapExpressionTrees was duplicated. | |
bool | m_bNonLinearStructuresInitialized |
m_bNonLinearStructuresInitialized is true if initializeNonLinearStructures( ) has been called. | |
bool | m_bSparseJacobianCalculated |
m_bSparseJacobianCalculated is true if getJacobianSparsityPattern() has been called. | |
std::map< int, std::vector < OSnLNode * > > | m_mapExpressionTreesInPostfix |
m_mapExpressionTrees holds a hash map of expression trees in postfix format, with the key being the row index and value being the expression tree representing the nonlinear expression of that row. | |
int | m_iHighestOrderEvaluated |
m_iHighestOrderEvaluated is the highest order derivative of the current iterate | |
double ** | m_mmdObjGradient |
m_mdObjGradient holds an array of pointers, each pointer points to gradient of each objective function | |
CppAD::vector< AD< double > > | m_vX |
m_vX is a vector of CppAD indpendent variables. | |
std::vector< double > | m_vdX |
m_vdX is a vector of primal variables at each iteration | |
std::vector< double > | m_vdYval |
m_vdYval is a vector of function values | |
std::vector< bool > | m_vbLagHessNonz |
m_vbLagHessNonz is a boolean vector holding the nonzero pattern of the Lagrangian of the Hessian | |
std::vector< double > | m_vdYjacval |
m_vdYval is a vector equal to a column or row of the Jacobian | |
std::vector< double > | m_vdw |
m_vdYval is a vector of derivatives -- output from a reverse sweep | |
std::vector< double > | m_vdLambda |
m_vdYval is a vector of Lagrange multipliers | |
std::vector< double > | m_vdDomainUnitVec |
m_vdDomainUnitVec is a unit vector in the domain space | |
std::vector< double > | m_vdRangeUnitVec |
m_vdRangeUnitVec is a unit vector in the range space | |
bool | m_bProcessTimeDomain |
m_bProcessTimeDomain holds whether the time domain has been processed. | |
bool | m_bProcessTimeStages |
m_bProcessTimeStages holds whether the time stages have been processed. | |
bool | m_bProcessTimeInterval |
m_bProcessTimeInterval holds whether a time interval has been processed. | |
bool | m_bFiniteTimeStages |
m_bFiniteTimeStages holds whether the time domain has the form of finite (discrete) stages. | |
int | m_iNumberOfTimeStages |
m_iNumberOfTimeStages holds the number of discrete stages |
The in-memory representation of an OSiL instance..
1. Elements become objects of class type (the ComplexType is the class)
2. The attributes, children of the element, and text correspond to members of the class. (Note text does not have a name and becomes .value)
3. Model groups such as choice and sequence and all correspond to arrays
The OSInstance class is composed of two objects: an InstanceHeader object and and InstanceData object
Definition at line 634 of file OSInstance.h.
OSInstance::OSInstance | ( | ) |
The OSInstance class constructor.
OSInstance::~OSInstance | ( | ) |
The OSInstance class destructor.
bool OSInstance::processVariables | ( | ) | [private] |
process variables.
Exception | if the elements in variables are logically inconsistent. |
bool OSInstance::processObjectives | ( | ) | [private] |
process objectives.
Exception | if the elements in objectives are logically inconsistent. |
bool OSInstance::processConstraints | ( | ) | [private] |
process constraints.
Exception | if the elements in constraints are logically inconsistent. |
bool OSInstance::processLinearConstraintCoefficients | ( | ) | [private] |
process linear constraint coefficients.
Exception | if the elements in linear constraint coefficients are logically inconsistent. |
std::string OSInstance::getInstanceName | ( | ) |
Get instance name.
std::string OSInstance::getInstanceSource | ( | ) |
Get instance source.
std::string OSInstance::getInstanceDescription | ( | ) |
Get instance description.
int OSInstance::getVariableNumber | ( | ) |
Get variable number.
std::string* OSInstance::getVariableNames | ( | ) |
Get variable names.
Exception | if the elements in variables are logically inconsistent. |
double* OSInstance::getVariableInitialValues | ( | ) |
Get variable initial values.
Exception | if the elements in variables are logically inconsistent. |
std::string* OSInstance::getVariableInitialStringValues | ( | ) |
Get variable initial std::string values.
Exception | if the elements in variables are logically inconsistent. |
char* OSInstance::getVariableTypes | ( | ) |
Get variable types.
Exception | if the elements in variables are logically inconsistent. |
int OSInstance::getNumberOfIntegerVariables | ( | ) |
getNumberOfIntegerVariables
int OSInstance::getNumberOfBinaryVariables | ( | ) |
getNumberOfBinaryVariables
double* OSInstance::getVariableLowerBounds | ( | ) |
Get variable lower bounds.
Exception | if the elements in variables are logically inconsistent. |
double* OSInstance::getVariableUpperBounds | ( | ) |
Get variable upper bounds.
Exception | if the elements in variables are logically inconsistent. |
int OSInstance::getObjectiveNumber | ( | ) |
Get objective number.
std::string* OSInstance::getObjectiveNames | ( | ) |
Get objective names.
Exception | if the elements in objectives are logically inconsistent. |
std::string* OSInstance::getObjectiveMaxOrMins | ( | ) |
Get objective maxOrMins.
One maxOrMin for each objective.
Exception | if the elements in objectives are logically inconsistent. |
int* OSInstance::getObjectiveCoefficientNumbers | ( | ) |
Get objective coefficient number.
One number for each objective.
Exception | if the elements in objectives are logically inconsistent. |
double* OSInstance::getObjectiveConstants | ( | ) |
Get objective constants.
One constant for each objective.
Exception | if the elements in objectives are logically inconsistent. |
double* OSInstance::getObjectiveWeights | ( | ) |
Get objective weights.
One weight for each objective.
Exception | if the elements in objectives are logically inconsistent. |
SparseVector** OSInstance::getObjectiveCoefficients | ( | ) |
Get objective coefficients.
One set of objective coefficients for each objective.
Exception | if the elements in objectives are logically inconsistent. |
double** OSInstance::getDenseObjectiveCoefficients | ( | ) |
getDenseObjectiveCoefficients.
int OSInstance::getConstraintNumber | ( | ) |
Get constraint number.
std::string* OSInstance::getConstraintNames | ( | ) |
Get constraint names.
Exception | if the elements in constraints are logically inconsistent. |
double* OSInstance::getConstraintLowerBounds | ( | ) |
Get constraint lower bounds.
Exception | if the elements in constraints are logically inconsistent. |
double* OSInstance::getConstraintUpperBounds | ( | ) |
Get constraint upper bounds.
Exception | if the elements in constraints are logically inconsistent. |
char* OSInstance::getConstraintTypes | ( | ) |
Get constraint types.
Exception | if the elements in constraints are logically inconsistent. |
int OSInstance::getLinearConstraintCoefficientNumber | ( | ) |
Get number of specified (usually nonzero) linear constraint coefficient values.
bool OSInstance::getLinearConstraintCoefficientMajor | ( | ) |
Get whether the constraint coefficients is in column major (true) or row major (false).
Exception | if the elements in linear constraint coefficients are logically inconsistent. |
SparseMatrix* OSInstance::getLinearConstraintCoefficientsInColumnMajor | ( | ) |
Get linear constraint coefficients in column major.
Exception | if the elements in linear constraint coefficients are logically inconsistent. |
SparseMatrix* OSInstance::getLinearConstraintCoefficientsInRowMajor | ( | ) |
Get linear constraint coefficients in row major.
Exception | if the elements in linear constraint coefficients are logically inconsistent. |
int OSInstance::getNumberOfQuadraticTerms | ( | ) |
Get the number of specified (usually nonzero) qTerms in the quadratic coefficients.
QuadraticTerms* OSInstance::getQuadraticTerms | ( | ) |
Get all the quadratic terms in the instance.
Exception | if the elements in quadratic coefficients are logically inconsistent. |
int* OSInstance::getQuadraticRowIndexes | ( | ) |
Get the indexes of rows which have a quadratic term.
int OSInstance::getNumberOfQuadraticRowIndexes | ( | ) |
Get the number of rows which have a quadratic term.
int OSInstance::getNumberOfNonlinearExpressions | ( | ) |
Get number of nonlinear expressions.
OSExpressionTree* OSInstance::getNonlinearExpressionTree | ( | int | rowIdx | ) |
OSExpressionTree* OSInstance::getNonlinearExpressionTreeMod | ( | int | rowIdx | ) |
std::vector<OSnLNode*> OSInstance::getNonlinearExpressionTreeInPostfix | ( | int | rowIdx | ) |
Get the postfix tokens for a given row index.
std::vector<OSnLNode*> OSInstance::getNonlinearExpressionTreeModInPostfix | ( | int | rowIdx | ) |
Get the postfix tokens for a given row index for the modified Expression Tree (quadratic terms added).
std::vector<OSnLNode*> OSInstance::getNonlinearExpressionTreeInPrefix | ( | int | rowIdx | ) |
Get the prefix tokens for a given row index.
std::vector<OSnLNode*> OSInstance::getNonlinearExpressionTreeModInPrefix | ( | int | rowIdx | ) |
Get the prefix tokens for a given row index for the modified Expression Tree (quadratic terms added).
int OSInstance::getNumberOfNonlinearObjectives | ( | ) |
int OSInstance::getNumberOfNonlinearConstraints | ( | ) |
std::map<int, OSExpressionTree* > OSInstance::getAllNonlinearExpressionTrees | ( | ) |
std::map<int, OSExpressionTree* > OSInstance::getAllNonlinearExpressionTreesMod | ( | ) |
int* OSInstance::getNonlinearExpressionTreeIndexes | ( | ) |
int OSInstance::getNumberOfNonlinearExpressionTreeIndexes | ( | ) |
int* OSInstance::getNonlinearExpressionTreeModIndexes | ( | ) |
int OSInstance::getNumberOfNonlinearExpressionTreeModIndexes | ( | ) |
bool OSInstance::setInstanceSource | ( | std::string | source | ) |
set the instance source.
source | holds the instance source. |
bool OSInstance::setInstanceDescription | ( | std::string | description | ) |
set the instance description.
description | holds the instance description. |
bool OSInstance::setInstanceName | ( | std::string | name | ) |
set the instance name.
name | holds the instance name. |
bool OSInstance::setVariableNumber | ( | int | number | ) |
set the variable number.
number | holds the variable number. |
bool OSInstance::addVariable | ( | int | index, | |
std::string | name, | |||
double | lowerBound, | |||
double | upperBound, | |||
char | type, | |||
double | init, | |||
std::string | initString | |||
) |
add a variable.
In order to use the add method, the setVariableNumber must first be called so that the variable number is known ahead of time to assign appropriate memory. If a variable with the given variable index already exists, the old variable will be replaced.
index | holds the variable index. It is required. | |
name | holds the variable name; use null or empty std::string ("") if no variable name. | |
lowerBound | holds the variable lower bound; use Double.NEGATIVE_INFINITY if no lower bound. | |
upperBound | holds the variable upper bound; use Double.POSITIVE_INFINITY if no upper bound. | |
type | holds the variable type character, B for Binary, I for Integer, S for String, C or any other char for Continuous) | |
init | holds the double variable initial value; use Double.NaN if no initial value. | |
initString | holds the std::string variable initial value; use null or empty std::string ("") if no initial std::string value. |
bool OSInstance::setVariables | ( | int | number, | |
std::string * | names, | |||
double * | lowerBounds, | |||
double * | upperBounds, | |||
char * | types, | |||
double * | inits, | |||
std::string * | initsString | |||
) |
set all the variable related elements.
All the previous variable-related elements will be deleted.
number | holds the number of variables. It is required. | |
names | holds a std::string array of variable names; use null if no variable names. | |
lowerBounds | holds a double array of variable lower bounds; use null if all lower bounds are 0; use Double.NEGATIVE_INFINITY if no lower bound for a specific variable in the array. | |
upperBounds | holds a double array of variable upper bounds; use null if no upper bounds; use Double.POSITIVE_INFINITY if no upper bound for a specific variable in the array. | |
types | holds a char array of variable types; use null if all variables are continuous; for a specfic variable in the array use B for Binary, I for Integer, S for String, C or any other char for Continuous,) | |
inits | holds a double array of varible initial values; use null if no initial values. | |
initsString | holds a std::string array of varible initial values; use null if no initial std::string values. |
bool OSInstance::setObjectiveNumber | ( | int | number | ) |
set the objective number.
number | holds the objective number. |
bool OSInstance::addObjective | ( | int | index, | |
std::string | name, | |||
std::string | maxOrMin, | |||
double | constant, | |||
double | weight, | |||
SparseVector * | objectiveCoefficients | |||
) |
add an objective.
In order to use the add method, the setObjectiveNumber must first be called so that the objective number is known ahead of time to assign appropriate memory. If a objective with the given objective index already exists, the old objective will be replaced. Objective index will start from -1, -2, -3, ... down, with -1 corresponding to the first objective.
index | holds the objective index. Remember the first objective index is -1, second -2, ... | |
name | holds the objective name; use null or empty std::string ("") if no objective name. | |
maxOrMin | holds the objective sense or direction; it can only take two values: "max" or "min". | |
constant | holds the objective constant; use 0.0 if no objective constant. | |
weight | holds the objective weight; use 1.0 if no objective weight. | |
objectiveCoefficients | holds the objective coefficients (null if no objective coefficients) in a sparse representation that holds two arrays: index array and a value array. |
bool OSInstance::setObjectives | ( | int | number, | |
std::string * | names, | |||
std::string * | maxOrMins, | |||
double * | constants, | |||
double * | weights, | |||
SparseVector ** | objectitiveCoefficients | |||
) |
set all the objectives related elements.
All the previous objective-related elements will be deleted.
number | holds the number of objectives. It is required. | |
names | holds a std::string array of objective names; use null if no objective names. | |
maxOrMins | holds a std::string array of objective objective senses or directions: "max" or "min"; use null if all objectives are "min". | |
constants | holds a double array of objective constants; use null if all objective constants are 0.0. | |
weights | holds a double array of objective weights; use null if all objective weights are 1.0. | |
objectitiveCoefficients | holds an array of objective coefficients, (null if no objective have any coefficeints) For each objective, the coefficients are stored in a sparse representation that holds two arrays: index array and a value array. If for a specific objective, there are no objecitve coefficients, use null for the corresponding array member. |
bool OSInstance::setConstraintNumber | ( | int | number | ) |
set the constraint number.
number | holds the constraint number. |
bool OSInstance::addConstraint | ( | int | index, | |
std::string | name, | |||
double | lowerBound, | |||
double | upperBound, | |||
double | constant | |||
) |
add a constraint.
In order to use the add method, the setConstraintNumber must first be called so that the constraint number is known ahead of time to assign appropriate memory. If a constraint with the given constraint index already exists, the old constraint will be replaced.
index | holds the constraint index. It is required. | |
name | holds the constraint name; use null or empty std::string ("") if no constraint name. | |
lowerBound | holds the constraint lower bound; use Double.NEGATIVE_INFINITY if no lower bound. | |
upperBound | holds the constraint upper bound; use Double.POSITIVE_INFINITY if no upper bound. |
bool OSInstance::setConstraints | ( | int | number, | |
std::string * | names, | |||
double * | lowerBounds, | |||
double * | upperBounds, | |||
double * | constants | |||
) |
set all the constraint related elements.
All the previous constraint-related elements will be deleted.
number | holds the number of constraints. It is required. | |
names | holds a std::string array of constraint names; use null if no constraint names. | |
lowerBounds | holds a double array of constraint lower bounds; use null if no lower bounds; use Double.NEGATIVE_INFINITY if no lower bound for a specific constraint in the array. | |
upperBounds | holds a double array of constraint upper bounds; use null if no upper bounds; use Double.POSITIVE_INFINITY if no upper bound for a specific constraint in the array. |
bool OSInstance::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
numberOfValues | holds the number of specified coefficient values (usually nonzero) in the coefficient matrix. | |
isColumnMajor | holds whether the coefficient matrix is stored in column major (true) or row major (false). | |
values | holds a double array coefficient values in the matrix. | |
valuesBegin | holds the begin index of the values array to copy from (usually 0). | |
valuesEnd | holds the end index of the values array to copy till (usually values.lenght - 1). | |
indexes | holds an integer array column/row indexes for each value in the values array. | |
indexesBegin | holds the begin index of the indexes array to copy from (usually 0). | |
indexesEnd | holds the end index of the indexes array to copy till (usually indexes.lenght - 1). | |
starts | holds an integer array start indexes in the matrix; the first value of starts should always be 0. | |
startsBegin | holds the begin index of the starts array to copy from (usually 0). | |
startsEnd | holds the end index of the starts array to copy till (usually starts.lenght - 1). |
bool OSInstance::setQuadraticTerms | ( | int | number, | |
int * | rowIndexes, | |||
int * | varOneIndexes, | |||
int * | varTwoIndexes, | |||
double * | coefficients, | |||
int | begin, | |||
int | end | |||
) |
set quadratic terms
number | holds the number of quadratic terms. | |
rowIndexes | holds an integer array of row indexes of all the quadratic terms. A negative integer corresponds to an objective row, e.g. -1 for 1st objective and -2 for 2nd. | |
varOneIndexes | holds an integer array of the first varialbe indexes of all the quadratic terms. | |
varTwoIndexes | holds an integer array of the second varialbe indexes of all the quadratic terms. | |
coefficients | holds a double array all the quadratic term coefficients. | |
begin | holds the begin index of all the arrays to copy from (usually = 0). | |
end | holds the end index of all the arrays to copy till (usually = array length -1). |
bool OSInstance::setQuadraticTermsInNonlinearExpressions | ( | int | number, | |
int * | rowIndexes, | |||
int * | varOneIndexes, | |||
int * | varTwoIndexes, | |||
double * | coefficients | |||
) |
set quadratic terms in nonlinearExpressions
number | holds the number of quadratic terms. | |
rowIndexes | holds an integer array of row indexes of all the quadratic terms. A negative integer corresponds to an objective row, e.g. -1 for 1st objective and -2 for 2nd. | |
varOneIndexes | holds an integer array of the first varialbe indexes of all the quadratic terms. | |
varTwoIndexes | holds an integer array of the second varialbe indexes of all the quadratic terms. | |
coefficients | holds a double array all the quadratic term coefficients. |
bool OSInstance::initializeNonLinearStructures | ( | ) |
Initialize the data structures for the nonlinear API.
double OSInstance::calculateFunctionValue | ( | int | idx, | |
double * | x, | |||
bool | new_x | |||
) |
Calculate the function value for function (constraint or objective) indexed by idx.
idx | is the index on the constraint (0, 1, 2, 3, ...) or objective function (-1, -2, -3, ...). | |
x | is a pointer (double array) to the current variable values | |
new_x | is false if any evaluation method was previously called for the current x has been evaluated for the current iterate x use a value of false if not sure |
double* OSInstance::calculateAllConstraintFunctionValues | ( | double * | x, | |
double * | objLambda, | |||
double * | conLambda, | |||
bool | new_x, | |||
int | highestOrder | |||
) |
Calculate all of the constraint function values.
x | is a pointer (double array) to the current variable values | |
objLambda | is the Lagrange multiplier on the objective function | |
conLambda | is pointer (double array) of Lagrange multipliers on the constratins | |
new_x | is false if any evaluation method was previously called for the current x for the current iterate | |
highestOrder | is the highest order of the derivative being calculated |
double* OSInstance::calculateAllConstraintFunctionValues | ( | double * | x, | |
bool | new_x | |||
) |
Calculate all of the constraint function values, we are overloading this function and this version of the method will not use any AD and will evaluate function values from the OS Expression Tree.
x | is a pointer (double array) to the current variable values | |
new_x | is false if any evaluation method was previously called for the current iterate |
double* OSInstance::calculateAllObjectiveFunctionValues | ( | double * | x, | |
double * | objLambda, | |||
double * | conLambda, | |||
bool | new_x, | |||
int | highestOrder | |||
) |
Calculate all of the objective function values.
x | is a pointer (double array) to the current variable values | |
objLambda | is the Lagrange multiplier on the objective function | |
conLambda | is pointer (double array) of Lagrange multipliers on the constratins | |
new_x | is false if any evaluation method was previously called for the current iterate | |
highestOrder | is the highest order of the derivative being calculated |
double* OSInstance::calculateAllObjectiveFunctionValues | ( | double * | x, | |
bool | new_x | |||
) |
Calculate all of the objective function values, we are overloading this function and this version of the method will not use any AD and will evaluate function values from the OS Expression Tree.
x | is a pointer (double array) to the current variable values | |
new_x | is false if any evaluation method was previously called for the current iterate |
SparseJacobianMatrix* OSInstance::calculateAllConstraintFunctionGradients | ( | double * | x, | |
double * | objLambda, | |||
double * | conLambda, | |||
bool | new_x, | |||
int | highestOrder | |||
) |
Calculate the gradient of all constraint functions.
x | is a pointer (double array) to the current variable values | |
objLambda | is the Lagrange multiplier on the objective function | |
conLambda | is pointer (double array) of Lagrange multipliers on the constratins | |
new_x | is false if any evaluation method was previously called for the current iterate | |
highestOrder | is the highest order of the derivative being calculated |
SparseVector* OSInstance::calculateConstraintFunctionGradient | ( | double * | x, | |
double * | objLambda, | |||
double * | conLambda, | |||
int | idx, | |||
bool | new_x, | |||
int | highestOrder | |||
) |
Calculate the gradient of the constraint function indexed by idx.
x | is a pointer (double array) to the current variable values | |
objLambda | is the Lagrange multiplier on the objective function | |
conLambda | is pointer (double array) of Lagrange multipliers on the constratins idx is the index of the constraint function gradient | |
new_x | is false if any evaluation method was previously called for the current iterate | |
highestOrder | is the highest order of the derivative being calculated |
SparseVector* OSInstance::calculateConstraintFunctionGradient | ( | double * | x, | |
int | idx, | |||
bool | new_x | |||
) |
Calculate the gradient of the constraint function indexed by idx this function is overloaded.
x | is a pointer (double array) to the current variable values idx is the index of the constraint function gradient | |
new_x | is false if any evaluation method was previously called for the current iterate | |
highestOrder | is the highest order of the derivative being calculated |
double** OSInstance::calculateAllObjectiveFunctionGradients | ( | double * | x, | |
double * | objLambda, | |||
double * | conLambda, | |||
bool | new_x, | |||
int | highestOrder | |||
) |
Calculate the gradient of all objective functions.
x | is a pointer (double array) to the current variable values | |
objLambda | is the Lagrange multiplier on the objective function | |
conLambda | is pointer (double array) of Lagrange multipliers on the constratins | |
new_x | is false if any evaluation method was previously called for the current iterate | |
highestOrder | is the highest order of the derivative being calculated |
double* OSInstance::calculateObjectiveFunctionGradient | ( | double * | x, | |
double * | objLambda, | |||
double * | conLambda, | |||
int | objIdx, | |||
bool | new_x, | |||
int | highestOrder | |||
) |
Calculate the gradient of the objective function indexed by objIdx.
x | is a pointer (double array) to the current variable values | |
objLambda | is the Lagrange multiplier on the objective function | |
conLambda | is pointer (double array) of Lagrange multipliers on the constratins objIdx is the index of the objective function being optimized | |
new_x | is false if any evaluation method was previously called for the current iterate | |
highestOrder | is the highest order of the derivative being calculated |
double* OSInstance::calculateObjectiveFunctionGradient | ( | double * | x, | |
int | objIdx, | |||
bool | new_x | |||
) |
Calculate the gradient of the objective function indexed by objIdx this function is overloaded.
x | is a pointer (double array) to the current variable values objIdx is the index of the objective function being optimized | |
new_x | is false if any evaluation method was previously called for the current iterate | |
highestOrder | is the highest order of the derivative being calculated |
SparseHessianMatrix* OSInstance::calculateLagrangianHessian | ( | double * | x, | |
double * | objLambda, | |||
double * | conLambda, | |||
bool | new_x, | |||
int | highestOrder | |||
) |
Calculate the Hessian of the Lagrangian Expression Tree This method will build the CppAD expression tree for only the first iteration Use this method on if the value of x does not affect the operations sequence.
x | is a pointer (double array) to the current variable values | |
objLambda | is the Lagrange multiplier on the objective function | |
conLambda | is pointer (double array) of Lagrange multipliers on the constratins | |
new_x | is false if any evaluation method was previously called for the current iterate | |
highestOrder | is the highest order of the derivative being calculated |
SparseHessianMatrix* OSInstance::calculateHessian | ( | double * | x, | |
int | idx, | |||
bool | new_x | |||
) |
Calculate the Hessian of a constraint or objective function.
x | is a pointer (double array) to the current variable values | |
new_x | is false if any evaluation method was previously called for the current iterate idx is the index of the either a constraint or objective function Hessian |
bool OSInstance::getSparseJacobianFromColumnMajor | ( | ) |
bool OSInstance::getSparseJacobianFromRowMajor | ( | ) |
OSExpressionTree* OSInstance::getLagrangianExpTree | ( | ) |
std::map<int, int> OSInstance::getAllNonlinearVariablesIndexMap | ( | ) |
SparseHessianMatrix* OSInstance::getLagrangianHessianSparsityPattern | ( | ) |
bool OSInstance::addQTermsToExressionTree | ( | ) |
SparseJacobianMatrix* OSInstance::getJacobianSparsityPattern | ( | ) |
void OSInstance::duplicateExpressionTreesMap | ( | ) |
duplicate the map of expression trees.
bool OSInstance::createCppADFun | ( | std::vector< double > | vdX | ) |
Create the a CppAD Function object: this is a function where the domain is the set of variables for the problem and the range is the objective function plus constraints.
vdX | is a vector of doubles holding the current primal variable values the size of x should equal instanceData->variables->numberOfVariables |
std::vector<double> OSInstance::forwardAD | ( | int | p, | |
std::vector< double > | vdX | |||
) |
Perform an AD forward sweep.
p | is the highest order Taylor coefficient | |
vdX | is a vector of doubles of the current primal variable values the size of vdX m_iNumberOfNonlinearVariables |
std::vector<double> OSInstance::reverseAD | ( | int | p, | |
std::vector< double > | vdlambda | |||
) |
Perform an AD reverse sweep.
p | is the order of the sweep | |
vdlambda | is a vector of doubles of the current dual (lagrange) variable values the size of lambda should equal number of objective functions plus number of constraints |
bool OSInstance::getIterateResults | ( | double * | x, | |
double * | objLambda, | |||
double * | conLambda, | |||
bool | new_x, | |||
int | highestOrder | |||
) |
end revised AD code
Get the information for each iteration. Get the functions values, Jacobian and Hessian of the Lagrangian
x | is a pointer of doubles of primal values for the current iteration | |
objLambda | is is a pointer of doubles of the current dual (Lagrange) multipliers on the objective functions | |
conLambda | is a pointer of doubles of the current dual (Lagrange) multipliers on the constraints | |
new_x | is false if any evaluation method was previously called | |
highestOrder | is the highest order derivative to be calculated |
bool OSInstance::getZeroOrderResults | ( | double * | x, | |
double * | objLambda, | |||
double * | conLambda | |||
) |
Calculate function values.
x | is a pointer of doubles of primal values for the current iteration | |
objLambda | is is a pointer of doubles of the current dual (Lagrange) multipliers on the objective functions | |
conLambda | is a pointer of doubles of the current dual (Lagrange) multipliers on the constraints |
bool OSInstance::getFirstOrderResults | ( | double * | x, | |
double * | objLambda, | |||
double * | conLambda | |||
) |
Calculate first derivatives.
x | is a pointer of doubles of primal values for the current iteration | |
objLambda | is is a pointer of doubles of the current dual (Lagrange) multipliers on the objective functions | |
conLambda | is a pointer of doubles of the current dual (Lagrange) multipliers on the constraints |
bool OSInstance::getSecondOrderResults | ( | double * | x, | |
double * | objLambda, | |||
double * | conLambda | |||
) |
Calculate second derivatives.
x | is a pointer of doubles of primal values for the current iteration | |
objLambda | is is a pointer of doubles of the current dual (Lagrange) multipliers on the objective functions | |
conLambda | is a pointer of doubles of the current dual (Lagrange) multipliers on the constraints |
bool OSInstance::initForAlgDiff | ( | ) |
This should be called by nonlinear solvers using callback functions.
initForAlgDiff will initialize the correct nonlinear structures in preparation for using the algorithmic differentiation routines.
bool OSInstance::initObjGradients | ( | ) |
This should be called by initForAlgDiff().
initObjGradients will initialize the objective function gradients to be equal to the coefficients given in the <coef> section of the OSiL instance
A pointer to an InstanceHeader object.
Definition at line 644 of file OSInstance.h.
A pointer to an InstanceData object.
Definition at line 647 of file OSInstance.h.
std::string OSInstance::m_sInstanceName [private] |
m_sInstanceName holds the instance name.
Definition at line 653 of file OSInstance.h.
std::string OSInstance::m_sInstanceSource [private] |
m_sInstanceSource holds the instance source.
Definition at line 657 of file OSInstance.h.
std::string OSInstance::m_sInstanceDescription [private] |
m_sInstanceDescription holds the instance description.
Definition at line 661 of file OSInstance.h.
bool OSInstance::m_bProcessVariables [private] |
m_bProcessVariables holds whether the variables are processed.
Definition at line 666 of file OSInstance.h.
int OSInstance::m_iVariableNumber [private] |
m_iVariableNumber holds the variable number.
Definition at line 671 of file OSInstance.h.
int OSInstance::m_iNumberOfIntegerVariables [private] |
m_iNumberOfIntegerVariables holds the number of integer variables.
Definition at line 676 of file OSInstance.h.
int OSInstance::m_iNumberOfBinaryVariables [private] |
m_iNumberOfBinaryVariables holds the number of binary variables.
Definition at line 681 of file OSInstance.h.
int OSInstance::m_iNumberOfQuadraticRowIndexes [private] |
m_iNumberOfQuadraticRowIndexes holds the number of distinct rows and objectives with quadratic terms.
Definition at line 686 of file OSInstance.h.
bool OSInstance::m_bQuadraticRowIndexesProcessed [private] |
m_bQuadraticRowIndexesProcessed is true if getQuadraticRowIndexes() has been called.
Definition at line 691 of file OSInstance.h.
int* OSInstance::m_miQuadRowIndexes [private] |
m_miQuadRowIndexes is an integer pointer to the distinct rows indexes with a quadratic term.
Definition at line 696 of file OSInstance.h.
int OSInstance::m_iNumberOfNonlinearExpressionTreeIndexes [private] |
m_iNumberOfNonlinearExpressionTreeIndexes holds the number of distinct rows and objectives with nonlinear terms.
Definition at line 701 of file OSInstance.h.
bool OSInstance::m_bNonlinearExpressionTreeIndexesProcessed [private] |
m_bNonlinearExpressionTreeIndexesProcessed is true if getNonlinearExpressionTreeIndexes has been called.
Definition at line 706 of file OSInstance.h.
int* OSInstance::m_miNonlinearExpressionTreeIndexes [private] |
m_miNonlinearExpressionTreeIndexes is an integer pointer to the distinct rows indexes in the nonlinear expression tree map.
Definition at line 712 of file OSInstance.h.
int OSInstance::m_iNumberOfNonlinearExpressionTreeModIndexes [private] |
m_iNumberOfNonlinearExpressionTreeModIndexes holds the number of distinct rows and objectives with nonlinear terms including quadratic terms added to the nonlinear expression trees.
Definition at line 718 of file OSInstance.h.
bool OSInstance::m_bNonlinearExpressionTreeModIndexesProcessed [private] |
m_bNonlinearExpressionTreeModIndexesProcessed is true if getNonlinearExpressionTreeModIndexes has been called.
Definition at line 723 of file OSInstance.h.
int* OSInstance::m_miNonlinearExpressionTreeModIndexes [private] |
m_miNonlinearExpressionTreeModIndexes is an integer pointer to the distinct rows indexes in the modified expression tree map.
Definition at line 729 of file OSInstance.h.
std::string* OSInstance::m_msVariableNames [private] |
m_msVariableNames holds an array of variable names.
Definition at line 734 of file OSInstance.h.
double* OSInstance::m_mdVariableInitialValues [private] |
m_mdVariableInitialValues holds a double array of the initial variable values.
Definition at line 739 of file OSInstance.h.
std::string* OSInstance::m_msVariableInitialStringValues [private] |
m_msVariableInitialStringValues holds a std::string array of the initial variable values.
Definition at line 744 of file OSInstance.h.
char* OSInstance::m_mcVariableTypes [private] |
m_mcVariableTypes holds a char array of variable types (default = 'C').
(C for Continuous; B for Binary; I for Integer; S for String)
Definition at line 750 of file OSInstance.h.
double* OSInstance::m_mdVariableLowerBounds [private] |
m_mdVariableLowerBounds holds a double array of variable lower bounds (default = 0.0).
Definition at line 755 of file OSInstance.h.
double* OSInstance::m_mdVariableUpperBounds [private] |
m_mdVariableUpperBounds holds a double array of variable upper bounds (default = INF).
Definition at line 760 of file OSInstance.h.
bool OSInstance::m_bProcessObjectives [private] |
m_bProcessObjectives holds whether the objectives are processed.
Definition at line 765 of file OSInstance.h.
int OSInstance::m_iObjectiveNumber [private] |
m_iObjectiveNumber is the number of objective functions.
Definition at line 770 of file OSInstance.h.
int OSInstance::m_iObjectiveNumberNonlinear [private] |
m_iObjectiveNumber is the number of objective functions with a nonlinear term.
Definition at line 775 of file OSInstance.h.
std::string* OSInstance::m_msObjectiveNames [private] |
m_msObjectiveNames holds an array of objective names.
Definition at line 780 of file OSInstance.h.
std::string* OSInstance::m_msMaxOrMins [private] |
m_msMaxOrMins holds a std::string array of objective maxOrMins ("max" or "min").
Definition at line 785 of file OSInstance.h.
int* OSInstance::m_miNumberOfObjCoef [private] |
m_miNumberOfObjCoef holds an integer array of number of objective coefficients (default = 0.0).
Definition at line 790 of file OSInstance.h.
double* OSInstance::m_mdObjectiveConstants [private] |
m_mdObjectiveConstants holds an array of objective constants (default = 0.0).
Definition at line 795 of file OSInstance.h.
double* OSInstance::m_mdObjectiveWeights [private] |
m_mdObjectiveWeights holds an array of objective weights (default = 1.0).
Definition at line 800 of file OSInstance.h.
SparseVector** OSInstance::m_mObjectiveCoefficients [private] |
m_mObjectiveCoefficients holds an array of objective coefficients, one set of objective coefficients for each objective.
Definition at line 806 of file OSInstance.h.
bool OSInstance::m_bGetDenseObjectives [private] |
m_bGetDenseObjectives holds whether the dense objective functions are processed.
Definition at line 811 of file OSInstance.h.
double** OSInstance::m_mmdDenseObjectiveCoefficients [private] |
m_mmdDenseObjectiveCoefficients holds an array of pointers, each pointer points to a vector of dense objective function coefficients
Definition at line 817 of file OSInstance.h.
bool OSInstance::m_bProcessConstraints [private] |
m_bProcessConstraints holds whether the constraints are processed.
Definition at line 822 of file OSInstance.h.
int OSInstance::m_iConstraintNumber [private] |
m_iConstraintNumber is the number of constraints.
Definition at line 827 of file OSInstance.h.
int OSInstance::m_iConstraintNumberNonlinear [private] |
m_iConstraintNumberNonlinear is the number of constraints that have a nonlinear term.
Definition at line 832 of file OSInstance.h.
std::string* OSInstance::m_msConstraintNames [private] |
m_msConstraintNames holds an array of constraint names.
Definition at line 837 of file OSInstance.h.
double* OSInstance::m_mdConstraintLowerBounds [private] |
m_mdConstraintLowerBounds holds an array of constraint lower bounds (default = -INF).
Definition at line 842 of file OSInstance.h.
double* OSInstance::m_mdConstraintUpperBounds [private] |
m_mdConstraintUpperBounds holds an array of constraint upper bounds (default = INF).
Definition at line 847 of file OSInstance.h.
double* OSInstance::m_mdConstraintConstants [private] |
m_mdConstraintConstants holds an array of constraint constants (default = 0.0).
Definition at line 853 of file OSInstance.h.
char* OSInstance::m_mcConstraintTypes [private] |
m_mcConstraintTypes holds a char array of constraint types (R for range; L for <=; G for >=; E for =; U for unconstrained)
Definition at line 859 of file OSInstance.h.
bool OSInstance::m_bProcessLinearConstraintCoefficients [private] |
m_bProcessLinearConstraintCoefficients holds whether the linear constraint coefficients are processed.
Definition at line 864 of file OSInstance.h.
int OSInstance::m_iLinearConstraintCoefficientNumber [private] |
m_iLinearConstraintCoefficientNumber holds the number of specified (usually nonzero) linear constraint coefficient values.
Definition at line 870 of file OSInstance.h.
bool OSInstance::m_bColumnMajor [private] |
m_bColumnMajor holds whether the linear constraint coefficients are stored in column major.
Definition at line 875 of file OSInstance.h.
bool OSInstance::m_binitForAlgDiff [private] |
m_binitForAlgDiff is true if initForAlgDiff() has been called.
Definition at line 880 of file OSInstance.h.
m_linearConstraintCoefficientsInColumnMajor holds the standard 3 array data structure for linear constraint coefficients (starts, indexes and values) in column major.
Definition at line 887 of file OSInstance.h.
m_linearConstraintCoefficientsInRowMajor holds the standard 3 array data structure for linear constraint coefficients (starts, indexes and values) in row major.
Definition at line 893 of file OSInstance.h.
bool OSInstance::m_bProcessQuadraticTerms [private] |
m_bProcessQuadraticTerms holds whether the quadratic terms are processed.
Definition at line 899 of file OSInstance.h.
int OSInstance::m_iQuadraticTermNumber [private] |
m_iQuadraticTermNumber holds the number of specified (usually nonzero) qTerms in the quadratic coefficients.
Definition at line 905 of file OSInstance.h.
double* OSInstance::m_mdConstraintFunctionValues [private] |
m_mdConstraintFunctionValues holds a double array of constraint function values -- the size of the array is equal to getConstraintNumber().
Definition at line 910 of file OSInstance.h.
double* OSInstance::m_mdObjectiveFunctionValues [private] |
m_mdObjectiveFunctionValues holds a double array of objective function values -- the size of the array is equal to getObjectiveNumber().
Definition at line 915 of file OSInstance.h.
int OSInstance::m_iJacValueSize [private] |
m_iJacValueSize is the number of nonzero partial derivates in the Jacobian.
Definition at line 920 of file OSInstance.h.
int* OSInstance::m_miJacStart [private] |
m_miJacStart holds a int array of starts for the Jacobian matrix in sparse form (row major).
Definition at line 925 of file OSInstance.h.
int* OSInstance::m_miJacIndex [private] |
m_miJacIndex holds a int array of variable indices for the Jacobian matrix in sparse form (row major).
Definition at line 930 of file OSInstance.h.
double* OSInstance::m_mdJacValue [private] |
m_mdJacValue holds a double array of partial derivatives for the Jacobian matrix in sparse form (row major).
Definition at line 935 of file OSInstance.h.
int* OSInstance::m_miJacNumConTerms [private] |
m_miJacNumConTerms holds a int array of the number of constant terms (gradient does not change) for the Jacobian matrix in sparse form (row major).
Definition at line 942 of file OSInstance.h.
m_sparseJacMatrix is the Jacobian matrix stored in sparse matrix format
Definition at line 947 of file OSInstance.h.
int OSInstance::m_iHighestTaylorCoeffOrder [private] |
m_iHighestTaylorCoeffOrder is the order of highest calculated Taylor coefficient
Definition at line 953 of file OSInstance.h.
QuadraticTerms* OSInstance::m_quadraticTerms [private] |
m_quadraticTerms the data structure for all the quadratic terms in the instance.
` (rowIdx, varOneIdx, varTwoIdx, coef)
Definition at line 959 of file OSInstance.h.
bool OSInstance::m_bQTermsAdded [private] |
m_bQTermsAdded is true if we add the quadratic terms to the expression tree
Definition at line 963 of file OSInstance.h.
unsigned int OSInstance::m_iNumberOfNonlinearVariables [private] |
m_iNumberOfNonlinearVariables is the number of variables that appear in a nonlinear expression.
Definition at line 969 of file OSInstance.h.
bool OSInstance::m_bProcessNonlinearExpressions [private] |
m_bProcessNonlinearExpressions holds whether the nonlinear expressions are processed.
Definition at line 974 of file OSInstance.h.
int OSInstance::m_iNonlinearExpressionNumber [private] |
m_iNonlinearExpressionNumber holds the number of nonlinear expressions.
Definition at line 979 of file OSInstance.h.
int* OSInstance::m_miNonlinearExpressionIndexes [private] |
m_miNonlinearExpressionIndexes holds an integer array of nonlinear expression indexes, negative indexes correspond to objectives.
Definition at line 985 of file OSInstance.h.
bool OSInstance::m_bProcessExpressionTrees [private] |
m_bProcessExpressionTrees is true if the expression trees have been processed.
Definition at line 990 of file OSInstance.h.
bool OSInstance::m_bProcessExpressionTreesMod [private] |
m_bProcessExpressionTreesMod is true if the modified expression trees have been processed.
Definition at line 995 of file OSInstance.h.
std::map<int, OSExpressionTree*> OSInstance::m_mapExpressionTrees [private] |
m_mapExpressionTrees holds a hash map of expression tree pointers, with the key being the row index and value being the expression tree representing the nonlinear expression of that row.
Definition at line 1001 of file OSInstance.h.
std::map<int, int> OSInstance::m_mapCppADFunRangeIndex [private] |
Definition at line 1005 of file OSInstance.h.
OSExpressionTree* OSInstance::m_LagrangianExpTree [private] |
m_LagrangianExpTree is an OSExpressionTree object that is the expression tree for the Lagrangian function.
Definition at line 1011 of file OSInstance.h.
bool OSInstance::m_bLagrangianExpTreeCreated [private] |
m_bLagrangianHessionCreated is true if a Lagrangian function for the Hessian has been created
Definition at line 1016 of file OSInstance.h.
m_LagrangianSparseHessian is the Hessian Matrix of the Lagrangian function in sparse format
Definition at line 1021 of file OSInstance.h.
bool OSInstance::m_bLagrangianSparseHessianCreated [private] |
m_bLagrangianSparseHessianCreated is true if the sparse Hessian Matrix for the Lagrangian was created
Definition at line 1027 of file OSInstance.h.
std::map<int, int> OSInstance::m_mapAllNonlinearVariablesIndex [private] |
m_mapAllNonlinearVariablesIndexMap is a map of the variables in the Lagrangian function
Definition at line 1032 of file OSInstance.h.
int* OSInstance::m_miNonLinearVarsReverseMap [private] |
m_miNonLinearVarsReverseMap maps the nonlinear variable number back into the original variable space
Definition at line 1037 of file OSInstance.h.
bool OSInstance::m_bAllNonlinearVariablesIndex [private] |
m_bAllNonlinearVariablesIndexMap is true if the map of the variables in the Lagrangian function has been constructed
Definition at line 1043 of file OSInstance.h.
std::map<int, OSExpressionTree*> OSInstance::m_mapExpressionTreesMod [private] |
m_mapExpressionTreesMod holds a map of expression trees, with the key being the row index and value being the expression tree representing a modification of the nonlinear expression of that row.
We incorporate the linear and quadratic term for a variable into the corresponding expression tree before gradient and Hessian calculations
Definition at line 1051 of file OSInstance.h.
bool OSInstance::m_bCppADFunIsCreated [private] |
m_bCppADFunIsCreated is true if we have created the OSInstanc CppAD Function
Definition at line 1057 of file OSInstance.h.
bool OSInstance::m_bCppADTapesBuilt [private] |
is true if a CppAD Expresion Tree has been built for each row and objective with a nonlinear expression.
Definition at line 1063 of file OSInstance.h.
bool OSInstance::m_bCppADMustReTape [private] |
is true if a CppAD Expresion Tree has an expression that can change depending on the value of the input, e.g.
an if statement -- false by default
Definition at line 1069 of file OSInstance.h.
bool OSInstance::m_bDuplicateExpressionTreesMap [private] |
m_bDuplicateExpressionTreeMap is true if m_mapExpressionTrees was duplicated.
Definition at line 1074 of file OSInstance.h.
bool OSInstance::m_bNonLinearStructuresInitialized [private] |
m_bNonLinearStructuresInitialized is true if initializeNonLinearStructures( ) has been called.
Definition at line 1079 of file OSInstance.h.
bool OSInstance::m_bSparseJacobianCalculated [private] |
m_bSparseJacobianCalculated is true if getJacobianSparsityPattern() has been called.
Definition at line 1084 of file OSInstance.h.
std::map<int, std::vector<OSnLNode*> > OSInstance::m_mapExpressionTreesInPostfix [private] |
m_mapExpressionTrees holds a hash map of expression trees in postfix format, with the key being the row index and value being the expression tree representing the nonlinear expression of that row.
Definition at line 1090 of file OSInstance.h.
int OSInstance::m_iHighestOrderEvaluated [private] |
m_iHighestOrderEvaluated is the highest order derivative of the current iterate
Definition at line 1097 of file OSInstance.h.
double** OSInstance::m_mmdObjGradient [private] |
m_mdObjGradient holds an array of pointers, each pointer points to gradient of each objective function
Definition at line 1103 of file OSInstance.h.
CppAD::vector< AD<double> > OSInstance::m_vX [private] |
m_vX is a vector of CppAD indpendent variables.
Definition at line 1110 of file OSInstance.h.
std::vector<double> OSInstance::m_vdX [private] |
m_vdX is a vector of primal variables at each iteration
Definition at line 1116 of file OSInstance.h.
std::vector<double> OSInstance::m_vdYval [private] |
m_vdYval is a vector of function values
Definition at line 1122 of file OSInstance.h.
std::vector<bool> OSInstance::m_vbLagHessNonz [private] |
m_vbLagHessNonz is a boolean vector holding the nonzero pattern of the Lagrangian of the Hessian
Definition at line 1129 of file OSInstance.h.
std::vector<double> OSInstance::m_vdYjacval [private] |
m_vdYval is a vector equal to a column or row of the Jacobian
Definition at line 1135 of file OSInstance.h.
std::vector<double> OSInstance::m_vdw [private] |
m_vdYval is a vector of derivatives -- output from a reverse sweep
Definition at line 1141 of file OSInstance.h.
std::vector<double> OSInstance::m_vdLambda [private] |
m_vdYval is a vector of Lagrange multipliers
Definition at line 1147 of file OSInstance.h.
std::vector<double> OSInstance::m_vdDomainUnitVec [private] |
m_vdDomainUnitVec is a unit vector in the domain space
Definition at line 1154 of file OSInstance.h.
std::vector<double> OSInstance::m_vdRangeUnitVec [private] |
m_vdRangeUnitVec is a unit vector in the range space
Definition at line 1160 of file OSInstance.h.
bool OSInstance::m_bProcessTimeDomain [private] |
m_bProcessTimeDomain holds whether the time domain has been processed.
Definition at line 1166 of file OSInstance.h.
bool OSInstance::m_bProcessTimeStages [private] |
m_bProcessTimeStages holds whether the time stages have been processed.
Definition at line 1171 of file OSInstance.h.
bool OSInstance::m_bProcessTimeInterval [private] |
m_bProcessTimeInterval holds whether a time interval has been processed.
Definition at line 1176 of file OSInstance.h.
bool OSInstance::m_bFiniteTimeStages [private] |
m_bFiniteTimeStages holds whether the time domain has the form of finite (discrete) stages.
Definition at line 1181 of file OSInstance.h.
int OSInstance::m_iNumberOfTimeStages [private] |
m_iNumberOfTimeStages holds the number of discrete stages
Definition at line 1186 of file OSInstance.h.
CppAD::ADFun<double>* OSInstance::Fad |
F is a CppAD function the range space is the objective + constraints functions, x is the domeain space.
Definition at line 2107 of file OSInstance.h.
bUseExpTreeForFunEval is set to true if you wish to use the OS Expression Tree for function evaluations instead of AD -- false by default.
Definition at line 2240 of file OSInstance.h.