org.optimizationservices.oscommon.representationparser
Class OSiLReader

java.lang.Object
  extended by org.optimizationservices.oscommon.representationparser.OSgLReader
      extended by org.optimizationservices.oscommon.representationparser.OSiLReader

public class OSiLReader
extends OSgLReader

The OSiLReader class parses an OSiL instance into a DOM tree and provides a set of "get" methods (e.g. getVariableNames) that can be used to retrieve different pieces of information of the optimization instance.

Since:
OS 1.0
Version:
1.0, 03/14/2004
Author:
Robert Fourer, Jun Ma, Kipp Martin
See Also:
org.optimizationservices.ossolver.parser.FMLHandler, org.optimizationservices.ossolver.parser.FMLReader, XMLReader, OSiLReader

Field Summary
 
Fields inherited from class org.optimizationservices.oscommon.representationparser.OSgLReader
m_document
 
Constructor Summary
OSiLReader()
          constructor.
OSiLReader(boolean validate)
          constructor.
 
Method Summary
 double calculateFunction(int rowIdx, double[] x)
          Calculate the function (nonlinear+quadratic+linear) value in a specified constraint (row) given the current variable values.
 double calculateFunction(int rowIdx, double[] x, boolean functionEvaluated)
          Calculate the function (nonlinear+quadratic+linear) value in a specified constraint (row) given the current variable values.
 double[] calculateLinearConstraintFunctions(double[] x)
          Calculate the all the linear constraint function values given the current variable values.
 double calculateLinearFunction(int rowIdx, double[] x)
          Calculate the linear function value in a specified constraint (row) given the current variable values.
 double calculateLinearObjectiveFunction(int rowIdx, double[] x)
          Calculate the linear objective function value given the current variable values.
 double calculateNonlinearDerivative(int rowIdx, double[] x, int varIndex, boolean functionEvaluated)
          Calculate the nonlinear function derivative in a specified constraint (row) given the current variable values w.r.t one variable.
 it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap calculateNonlinearDerivatives(int rowIdx, double[] x, boolean functionEvaluated)
          Calculate the nonlinear function derivatives in a specified constraint (row) given the current variable values w.r.t all variables.
 double calculateNonlinearFunction(int rowIdx, double[] x)
          Calculate the nonlinear function value in a specified constraint (row) given the current variable values.
 double calculateNonlinearFunction(int rowIdx, double[] x, boolean functionEvaluated)
          Calculate the nonlinear function value in a specified constraint (row) given the current variable values.
 java.lang.String calculateNonlinearFunction(int rowIdx, java.lang.String[] x, boolean functionEvaluated)
          Calculate the nonlinear function value in a specified constraint (row) given the current variable values.
 it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap calculateNonlinearHessianMatrix(int rowIdx, double[] x, boolean derivativeEvaluated)
          Calculate the nonlinear Hessian in a specified constraint (row) given the current variable values w.r.t all variables.
 double[] calculateQuadraticConstraintFunctions(double[] x)
          Calculate all quadratic constraint function values given the current variable values.
 double calculateQuadraticFunction(int rowIdx, double[] x)
          Calculate the quadratic function value in a specified constraint (row) given the current variable values.
 double calculateQuadraticObjectiveFunction(int rowIdx, double[] x)
          Calculate the quadratic objective function value given the current variable values.
 double[] getConstraintConstants()
          Get the values of all constraint constants in the OSiL instance.
 double[] getConstraintLowerBounds()
          Get the values of all constraint lower bounds (or left hand sides) in the OSiL instance.
 java.lang.String[] getConstraintNames()
          Get the values of all constraint names in the OSiL instance.
 int getConstraintNumber()
          Get the number of constraints.
 char[] getConstraintTypes()
          Get constraint types.
 double[] getConstraintUpperBounds()
          Get the values of all constraint upper bounds (or right hand sides) in the OSiL instance.
static java.lang.String getDelimiter()
           
 double[][] getDenseLinearConstraintCoefficientMatrix()
          Construct and get the nonsparse A matrix from the linearConstraintCoefficients.
 double[][] getDenseObjectiveCoefficients()
          Get the nonzero coefficient values of the first objective function in the OSiL instance.
 int getExpressionTreeSize(int rowIdx)
          Get the expression tree size, i.e.
 double[] getFirstDenseObjectiveCoefficientValues()
          Get the nonzero coefficient values of the first objective function in the OSiL instance.
 int getFirstObjectiveCoefficientNumber()
          Get the number of nonzero coefficient values of the first objective function in the OSiL instance.
 double getFirstObjectiveConstant()
          Get the constant of the first objective function in the OSiL instance.
 java.lang.String getFirstObjectiveMaxOrMin()
          Get the maxOrMin (direction or sense) of the first objective function in the OSiL instance.
 java.lang.String getFirstObjectiveName()
          Get the name of the first objective function in the OSiL instance.
 int[] getFirstObjectiveNonzeroCoefficientIndexes()
          Get the nonzero coefficient indexes of the first objective function in the OSiL instance.
 double[] getFirstObjectiveNonzeroCoefficientValues()
          Get the nonzero coefficient values of the first objective function in the OSiL instance.
 double getFirstObjectiveWeight()
          Get the weight of the first objective function in the OSiL instance.
 java.util.HashSet getIdentifiers(int rowIdx)
          Get a set of names of identifiers that exist in the nonlinear function of the specified constraint (row).
 java.util.Vector getInfix(int rowIdx)
          Express the function in the specified constraint (row) in an infix vecotr of operator symbols.
 java.lang.String getInstanceDescription()
          Get the value of <description> element in the OSiL instance.
 java.lang.String getInstanceName()
          Get the value of <name> element in the OSiL instance.
 java.lang.String getInstanceSource()
          Get the value of <source> element in the OSiL instance.
 int[][] getJacobianNonzeroIndexes()
           Get row (constraint) and col (var) indexes of nonzero elements of the constraint gradients (Jacobian Matrix).
 double getLinearConstraintCoefficient(int rowIdx, int colIdx)
          Get the linear Constraint coefficient given row and column numbers.
 boolean getLinearConstraintCoefficientMajor()
          Gets whether the coefMatrix (AMatrix) holding linear program data is stored by column.
 int[] getLinearConstraintCoefficientMatrixNonzeroIndexes()
          Get the the values of the vector element rowIdx or colIdx in coefMatrix.
 double[] getLinearConstraintCoefficientMatrixNonzeroValues()
          Get the values of the vector element value in coefMatrix, which contains nonzero elements.
 int[] getLinearConstraintCoefficientMatrixStartIndexes()
          Get the values of the elements <start> in coefMatrix, which points to the start of a column (row) of nonzero elements in linearConstraintCoefficients.
 int getLinearConstraintCoefficientNumber()
          Get the number of specified values (usually nonzero) in the linear coefficient matrix.
 java.util.HashSet getLogicAndRelationalSymbols(int rowIdx)
           
 java.lang.String getLogicError()
          Get logic error messages (one a line) the OSiLReader finds in the OSiL instance.
 java.util.HashSet getNetworkArcs(int rowIdx)
          Get a set of network arcs that are referred in the expression tree of the specified constraint (row), each set member is of the form: arcName:propertyName, that is arcName and property name delimited :.
 java.util.HashSet getNetworkNodes(int rowIdx)
          Get a set of network nodes that are referred in the expression tree of the specified constraint (row), each set member is of the form: nodeName:propertyName, that is nodeName and property name delimited :.
static java.lang.String getNlNodeInfo()
           
 double getNonlinearDerivative(int rowIdx, int varIndex)
          Get the nonlinear function derivative in a specified constraint (row) given the current variable values w.r.t.
 it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap getNonlinearDerivatives(int rowIdx)
          Get the nonlinear function derivatives in a specified constraint (row) given the current variable values w.r.t.
 OSExpressionTree getNonlinearExpression(int rowIdx)
          Get the nonlinear expression of a certain constraint (row).
 it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap getNonlinearExpressions()
          Process <nl> elements in the OSiL instance, which are the nolinear extensions to the linear program data and construct nolinear expression trees
 int getNonlinearExpressionTreeNumber()
          Get the number of nonlinear expressions.
 it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap getNonlinearHessianMatrix(int rowIdx)
          Get the nonlinear Hessian in a specified constraint (row) given the current variable values w.r.t all variables.
 double getNonlinearHessianValue(int rowIdx, int i, int j)
          Get the nonlinear Hessian in a specified constraint (row) given the current variable values w.r.t Xi and Xj.
 java.util.Vector getNonlinearInfix(int rowIdx)
          Express the nonlinear function in the specified constraint (row) in an infix vector of operator symbols If the row idx is negative, it returns that from an objective function.
 java.util.Vector getNonlinearPostfix(int rowIdx)
          Express the nonlinear function in the specified constraint (row) in a postfix vector of operator symbols.
 java.util.Vector getNonlinearPrefix(int rowIdx)
          Express the nonlinear function in the specified row in a prefix vector of operator symbols If the row idx is negative, it returns that from an objective function.
 java.util.HashSet getNonlinearQuadraticTerms(int rowIdx)
          Get a set of quadratic terms that exist in the expression tree of the specified constraint (row), each set member is of the form: i,j,coef, that is the first variable index, the second variable index and the coefficient value, delimited by comma.
 OSnLNode getNonlinearRootNode(int rowIdx)
          Get the nonlinear function's root node (of OSnLNode type).
 it.unimi.dsi.fastutil.ints.IntOpenHashSet getNonlinearVariableIndices(int rowIdx)
          Get an integer set of indices of the variables that exist in the nonlinear part of the function in a specified constraint (row).
 int getNumberOfComplementsOperator(int rowIdx)
          Get the number of the complements operator in the expression tree of the specified constraint (row).
 int getNumberOfProbabilityFunctions(int rowIdx)
          Get the number of probability functions in the nonlinear function of the specified constraint (row).
 int getNumberOfProbOperator(int rowIdx)
          Get the number of the probability operator (usually in chance constraint) in the expression tree of the specified constraint (row).
 int getNumberOfStatisticFunctions(int rowIdx)
          Get the number of statistic functions in the nonlinear function of the specified constraint (row).
 java.util.HashSet getNumberValues(int rowIdx)
          Get a set of number values that exist in the nonlinear function of the specified constraint (row).
 int[] getObjectiveCoefficientNumbers()
          Get the numbers of nonzero coefficient values of all the objective functions in the OSiL instance.
 SparseVector[] getObjectiveCoefficients()
          Get objective coefficients.
 double[] getObjectiveConstants()
          Get a double array of all the objective function constants in the OSiL instance.
 java.lang.String[] getObjectiveMaxOrMins()
          Get a string array of all the objective function maxOrMins (directions or senses) in the OSiL instance.
 java.lang.String[] getObjectiveNames()
          Get a string array of all the objective function names in the OSiL instance.
 int[][] getObjectiveNonzeroCoefficientIndexes()
          Get the nonzero coefficient indexes of all the objective functions in the OSiL instance.
 double[][] getObjectiveNonzeroCoefficientValues()
          Get the nonzero coefficient values of all the objective functions in the OSiL instance.
 int getObjectiveNumber()
          Get the number of objective functions.
 double[] getObjectiveWeights()
          Get a double array of all the objective function weights in the OSiL instance.
 OSInstance getOSInstance()
          get the OSInstance, a standard optimization problem/data api.
 java.util.Vector getPostfix(int rowIdx)
          Express the function in the specified constraint (row) in a postfix vecotr of operator symbols.
 java.util.Vector getPrefix(int rowIdx)
          Express the function in the specified constraint (row) in a prefix vector of operator symbols..
 int getQuadraticTermNumber()
          Get the number of specified qTerms (usually nonzero) in the quadratic coefficients.
 QuadraticTerms getQuadraticTerms()
          Get all the quadratic terms in quadratic coefficients.
 java.util.HashSet getSimulationNames(int rowIdx)
          Get a set of names of the simulations that exist in the expression tree of the specified constraint (row).
 int getTrigonometricFunctionNumbers(int rowIdx)
          Get the number of trigonometric functions in the nonlinear function of the specified row.
 java.util.HashSet getUserFunctionNames(int rowIdx)
          Get a set of names of the user defined functions that exist in the expression tree of the specified constraint (row).
 java.lang.String[] getVariableInitialStringValues()
          Get the values of all variable initial string values in the OSiL instance.
 double[] getVariableInitialValues()
          Get the values of all variable initial double values in the OSiL instance.
 double[] getVariableLowerBounds()
          Get the values of all variable lower bounds in the OSiL instance.
 java.lang.String[] getVariableNames()
          Get the values of all variable names in the OSiL instance.
 int getVariableNumber()
          Get the the number of variables.
 char[] getVariableTypes()
          Get the types of all the variables, (e.g.
 double[] getVariableUpperBounds()
          Get the values of all variable upper bounds in the OSiL instance.
 org.w3c.dom.Element getXMLDataElement()
          Get the xmlData element.
 java.lang.String getXMLDataString()
          Get the xmlData in a string.
 java.util.HashSet getXPath(int rowIdx)
          Get a set of XPaths that exist in the expression tree of the specified constraint (row), each set member is of the form: uri:path, that is uri and path delimited by :.
 it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap linearizeNonlinearFunction(int rowIdx)
          Linearize the the expression tree of a specified constraint (row) so that it doesn't contain linear terms.
static void main(java.lang.String[] argv)
          main for test purposes.
 boolean quadratizeNonlinearFunction(int rowIdx)
          Quadratize the current expression tree, or make all the quadratic terms written in the form of a quadratic node with its children being the quadratic terms.
 int simplifyNonlinearFunction(int rowIdx)
          Simplify the nonlinear part of the function in a specified constraint (row).
 
Methods inherited from class org.optimizationservices.oscommon.representationparser.OSgLReader
getDocument, getRootElement, isValidate, readFile, readString, setDocument, setRootElement, setValidate, writeToFile, writeToSring, writeToStandardOutput
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OSiLReader

public OSiLReader(boolean validate)
constructor.

Parameters:
validate - holds whether the reader should be validating against the schema or not.

OSiLReader

public OSiLReader()
constructor.

Method Detail

getOSInstance

public OSInstance getOSInstance()
                         throws java.lang.Exception
get the OSInstance, a standard optimization problem/data api.

Returns:
the OSInstance.
Throws:
java.lang.Exception - if there are errors getting the OSInstnace.

getLogicError

public java.lang.String getLogicError()
Get logic error messages (one a line) the OSiLReader finds in the OSiL instance.

Returns:
logic error messages (one a line) the OSiLReader finds in the OSiL instance.

getInstanceName

public java.lang.String getInstanceName()
Get the value of <name> element in the OSiL instance.

Returns:
the name of the OSiL instance, null if none.

getInstanceSource

public java.lang.String getInstanceSource()
Get the value of <source> element in the OSiL instance.

Returns:
the source information of the OSiL instance, null if none.

getInstanceDescription

public java.lang.String getInstanceDescription()
Get the value of <description> element in the OSiL instance.

Returns:
the description information of the OSiL instance, null if none.

getVariableNumber

public int getVariableNumber()
Get the the number of variables.

Returns:
the number of variables.

getObjectiveNumber

public int getObjectiveNumber()
Get the number of objective functions.

Returns:
the number of Objectives.

getConstraintNumber

public int getConstraintNumber()
Get the number of constraints.

Returns:
the number of constraints.

getLinearConstraintCoefficientNumber

public int getLinearConstraintCoefficientNumber()
Get the number of specified values (usually nonzero) in the linear coefficient matrix.

Returns:
the number of values in the linear coefficient matrix.

getQuadraticTermNumber

public int getQuadraticTermNumber()
Get the number of specified qTerms (usually nonzero) in the quadratic coefficients.

Returns:
the number of specified qTerms (usually nonzero) in the quadratic coefficients.

getNonlinearExpressionTreeNumber

public int getNonlinearExpressionTreeNumber()
Get the number of nonlinear expressions.

Returns:
the number of nonlinear expressions.

getVariableNames

public java.lang.String[] getVariableNames()
Get the values of all variable names in the OSiL instance.

Returns:
a String array of variable names in the OSiL instance.

getVariableInitialValues

public double[] getVariableInitialValues()
Get the values of all variable initial double values in the OSiL instance.

Returns:
a double array of variable initial values in the OSiL instance.

getVariableInitialStringValues

public java.lang.String[] getVariableInitialStringValues()
Get the values of all variable initial string values in the OSiL instance.

Returns:
a String array of variable initial values in the OSiL instance.

getVariableTypes

public char[] getVariableTypes()
Get the types of all the variables, (e.g. 'C' for continuous type, 'I' for integer type, 'B' for binary type and 'S' for string type).

Returns:
a Character vector of variable types in the OSiL instance.

getVariableLowerBounds

public double[] getVariableLowerBounds()
Get the values of all variable lower bounds in the OSiL instance.

Returns:
a double array of variable lower bounds in the OSiL instance.

getVariableUpperBounds

public double[] getVariableUpperBounds()
Get the values of all variable upper bounds in the OSiL instance.

Returns:
a double array of variable upper bounds in the OSiL instance.

getFirstObjectiveName

public java.lang.String getFirstObjectiveName()
Get the name of the first objective function in the OSiL instance.

Returns:
the first objective name of the OSiL instance, null string if none.

getObjectiveNames

public java.lang.String[] getObjectiveNames()
Get a string array of all the objective function names in the OSiL instance.

Returns:
a string array of all the objective function names, null if none.

getFirstObjectiveMaxOrMin

public java.lang.String getFirstObjectiveMaxOrMin()
Get the maxOrMin (direction or sense) of the first objective function in the OSiL instance.

Returns:
the first objective maxOrMin of the OSiL instance, null string if none.

getObjectiveMaxOrMins

public java.lang.String[] getObjectiveMaxOrMins()
Get a string array of all the objective function maxOrMins (directions or senses) in the OSiL instance.

Returns:
a string array of all the objective function maxOrMins, null if none.

getFirstObjectiveConstant

public double getFirstObjectiveConstant()
Get the constant of the first objective function in the OSiL instance.

Returns:
the first objective constant of the OSiL instance, 0 if none.

getObjectiveConstants

public double[] getObjectiveConstants()
Get a double array of all the objective function constants in the OSiL instance.

Returns:
a double array of all the objective function constants, null if none.

getFirstObjectiveWeight

public double getFirstObjectiveWeight()
Get the weight of the first objective function in the OSiL instance.

Returns:
the first objective function weight of the OSiL instance, 0 if none.

getObjectiveWeights

public double[] getObjectiveWeights()
Get a double array of all the objective function weights in the OSiL instance.

Returns:
a double array of all the objective function weights, null if none.

getFirstDenseObjectiveCoefficientValues

public double[] getFirstDenseObjectiveCoefficientValues()
Get the nonzero coefficient values of the first objective function in the OSiL instance.

Returns:
the nonzero coefficient values of the first objective function in the OSiL instance, null if none.

getDenseObjectiveCoefficients

public double[][] getDenseObjectiveCoefficients()
Get the nonzero coefficient values of the first objective function in the OSiL instance.

Returns:
the nonzero coefficient values of the first objective function in the OSiL instance, null if none.

getFirstObjectiveCoefficientNumber

public int getFirstObjectiveCoefficientNumber()
Get the number of nonzero coefficient values of the first objective function in the OSiL instance.

Returns:
the number of nonzero coefficient values of the first objective function in the OSiL instance, -1 if no objective functions.

getObjectiveCoefficientNumbers

public int[] getObjectiveCoefficientNumbers()
Get the numbers of nonzero coefficient values of all the objective functions in the OSiL instance.

Returns:
an integer arrays of the numbers of nonzero coefficient values of all the objective functions in the OSiL instance, null if no objective functions.

getFirstObjectiveNonzeroCoefficientValues

public double[] getFirstObjectiveNonzeroCoefficientValues()
Get the nonzero coefficient values of the first objective function in the OSiL instance.

Returns:
the nonzero coefficient values of the first objective function in the OSiL instance, null if none.

getObjectiveNonzeroCoefficientValues

public double[][] getObjectiveNonzeroCoefficientValues()
Get the nonzero coefficient values of all the objective functions in the OSiL instance.

Returns:
an array of double arrays; each double array holds the nonzero coefficient values of an objective function, null if none.

getFirstObjectiveNonzeroCoefficientIndexes

public int[] getFirstObjectiveNonzeroCoefficientIndexes()
Get the nonzero coefficient indexes of the first objective function in the OSiL instance.

Returns:
the nonzero coefficient indexes of the first objective function in the OSiL instance, null if none.

getObjectiveNonzeroCoefficientIndexes

public int[][] getObjectiveNonzeroCoefficientIndexes()
Get the nonzero coefficient indexes of all the objective functions in the OSiL instance.

Returns:
an array of integer arrays; each integer array holds the variable indexes of the nonzero coefficient values of an objective function, null if none.

getObjectiveCoefficients

public SparseVector[] getObjectiveCoefficients()
                                        throws java.lang.Exception
Get objective coefficients. One set of objective coefficients for each objective.

Returns:
an array of objective coefficients, null if no objective coefficients. If any one objective has objective coefficients, the array will not be null and the array size is equal to the number of objective functions. Each member of the array can still be null if the corresponding objective function doesn't have coefficients. Each member of the array is of type ObjectiveCoefficients. The ObjectiveCoefficients class contains two arrays: variableIndexes is an integer array and values is a double array of coefficient values.
Throws:
java.lang.Exception
See Also:
SparseVector

getConstraintNames

public java.lang.String[] getConstraintNames()
Get the values of all constraint names in the OSiL instance.

Returns:
a String array of constraint names in the OSiL instance.

getConstraintLowerBounds

public double[] getConstraintLowerBounds()
Get the values of all constraint lower bounds (or left hand sides) in the OSiL instance.

Returns:
a double array of constraint lower bound values in the OSiL instance.

getConstraintUpperBounds

public double[] getConstraintUpperBounds()
Get the values of all constraint upper bounds (or right hand sides) in the OSiL instance.

Returns:
a double array of constraint upper bound values in the OSiL instance.

getConstraintConstants

public double[] getConstraintConstants()
Get the values of all constraint constants in the OSiL instance.

Returns:
a double array of constraint constants in the OSiL instance.

getConstraintTypes

public char[] getConstraintTypes()
                          throws java.lang.Exception
Get constraint types.

Returns:
a char array of constraint types, null if constraints.
Throws:
java.lang.Exception - if the elements in constraints are logically inconsistent.

getLinearConstraintCoefficient

public double getLinearConstraintCoefficient(int rowIdx,
                                             int colIdx)
Get the linear Constraint coefficient given row and column numbers.

Parameters:
rowIdx - holds the row number to which the linear function belongs.
colIdx - holds the column number or the variable index.
Returns:
the linear function value in the specified constraint (row) given the current variable values.

getLinearConstraintCoefficientMatrixStartIndexes

public int[] getLinearConstraintCoefficientMatrixStartIndexes()
Get the values of the elements <start> in coefMatrix, which points to the start of a column (row) of nonzero elements in linearConstraintCoefficients.

Returns:
an Integer array of the the values of the elements <start> in coefMatrix.

getLinearConstraintCoefficientMatrixNonzeroValues

public double[] getLinearConstraintCoefficientMatrixNonzeroValues()
Get the values of the vector element value in coefMatrix, which contains nonzero elements.

Returns:
a double array of the the values of the elements <value> in coefMatrix.

getLinearConstraintCoefficientMatrixNonzeroIndexes

public int[] getLinearConstraintCoefficientMatrixNonzeroIndexes()
Get the the values of the vector element rowIdx or colIdx in coefMatrix. If the matrix is stored by column (row), rowIdx (colIdx) is the vector of row (column) indices.

Returns:
an integer array of the the values of the elements <rowIdx> or <colIdx> in coefMatrix.

getLinearConstraintCoefficientMajor

public boolean getLinearConstraintCoefficientMajor()
Gets whether the coefMatrix (AMatrix) holding linear program data is stored by column. If false, the matrix is stored by row.

Returns:
whether the coefMatrix (AMatrix) holding linear program data is stored by column. If false, the matrix is stored by row.

getDenseLinearConstraintCoefficientMatrix

public double[][] getDenseLinearConstraintCoefficientMatrix()
Construct and get the nonsparse A matrix from the linearConstraintCoefficients.

Returns:
a 2-dim array of doubles that represents the nonsparse A Matrix.

getQuadraticTerms

public QuadraticTerms getQuadraticTerms()
Get all the quadratic terms in quadratic coefficients.

Returns:
the QuadraticTerms data structure for all quadratic terms in the quadratic coefficients, null if none. The QuadraticTerms contains four arrays: rowIndexes, varOneIndexes, varTwoIndexes, coefficients
See Also:
QuadraticTerms

calculateLinearObjectiveFunction

public double calculateLinearObjectiveFunction(int rowIdx,
                                               double[] x)
Calculate the linear objective function value given the current variable values.

Parameters:
rowIdx - holds the row number to which the linear function belongs. if negative, it is an objective function.
x - holds the values of the variables in a double array.
Returns:
the linear objective function value given the current variable values.

calculateQuadraticObjectiveFunction

public double calculateQuadraticObjectiveFunction(int rowIdx,
                                                  double[] x)
Calculate the quadratic objective function value given the current variable values.

Parameters:
rowIdx - holds the row number to which the quadratic function belongs. if negative, it is an objective function.
x - holds the values of the variables in a double array.
Returns:
the quadratic objective function value given the current variable values.

calculateLinearFunction

public double calculateLinearFunction(int rowIdx,
                                      double[] x)
Calculate the linear function value in a specified constraint (row) given the current variable values. If the row idx is negative, it returns a linear objective function

Parameters:
rowIdx - holds the row number to which the linear function belongs. if negative, it is an objective function.
x - holds the values of the variables in a double array.
Returns:
the linear function value in the specified constraint (row) given the current variable values. If the row idx is negative, it returns the linear objective function

calculateQuadraticFunction

public double calculateQuadraticFunction(int rowIdx,
                                         double[] x)
Calculate the quadratic function value in a specified constraint (row) given the current variable values. If the row idx is negative, it returns a quadratic objective function

Parameters:
rowIdx - holds the row number to which the quadratic function belongs. if negative, it is an objective function.
x - holds the values of the variables in a double array.
Returns:
the quadratic function value in the specified constraint (row) given the current variable values. If the row idx is negative, it returns the quadratic objective function

calculateLinearConstraintFunctions

public double[] calculateLinearConstraintFunctions(double[] x)
Calculate the all the linear constraint function values given the current variable values.

Parameters:
x - holds the values of the variables in a double array.
Returns:
all the linear function values given the current variable values in a double array.

calculateQuadraticConstraintFunctions

public double[] calculateQuadraticConstraintFunctions(double[] x)
Calculate all quadratic constraint function values given the current variable values.

Parameters:
x - holds the values of the variables in a double array.
Returns:
all quadratic constraint function values given the current variable values. If no qudratic terms, null will be returned.

getNlNodeInfo

public static java.lang.String getNlNodeInfo()
Returns:
the information of all nonlinear nodes in a colon delimited string. The string is in a table format with the first row being the colmn title.

getDelimiter

public static java.lang.String getDelimiter()
Returns:
the delimiter used in the expression postfix and prefix notation strings.

getNonlinearExpressions

public it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap getNonlinearExpressions()
Process <nl> elements in the OSiL instance, which are the nolinear extensions to the linear program data and construct nolinear expression trees

Returns:
a hash map of expression trees, with the key being the rowIdx (row number) and value being the expression tree representing the nonlinear function of that constraint (row).

getNonlinearExpression

public OSExpressionTree getNonlinearExpression(int rowIdx)
Get the nonlinear expression of a certain constraint (row). Constraint row starts with row 0. If the row idx is negative, it corresponds to an objective.

Parameters:
rowIdx - holds the row number to which the nonlinear expression belongs. if negative, it is an objective function.
Returns:
the nnonlinear expression of a certain constraint (row). Constraint row starts with row 0. If the row idx is negative, it corresponds to an objective. If there is no nonlinear part of a constraint (row), then a null will be returned.

getNonlinearRootNode

public OSnLNode getNonlinearRootNode(int rowIdx)
Get the nonlinear function's root node (of OSnLNode type). The method is of little use due to the fact that most of the methods in the OSnLNode class are protected or protected. User should try the getNonlinearExpression(int)in this class instead.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. if negative, it is an objective function.
Returns:
the nonlinear function's root node (of OSnLNode type).
See Also:
getNonlinearExpression(int)

calculateNonlinearFunction

public double calculateNonlinearFunction(int rowIdx,
                                         double[] x)
Calculate the nonlinear function value in a specified constraint (row) given the current variable values.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. if negative, it is an objective function.
x - holds the values of the variables in a double array.
Returns:
the nonlinear function value in the specified constraint (row) given the current variable values.

calculateFunction

public double calculateFunction(int rowIdx,
                                double[] x)
Calculate the function (nonlinear+quadratic+linear) value in a specified constraint (row) given the current variable values.

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
x - holds the values of the variables in a double array.
Returns:
the function value in the specified constraint (row) given the current variable values.

calculateNonlinearFunction

public double calculateNonlinearFunction(int rowIdx,
                                         double[] x,
                                         boolean functionEvaluated)
Calculate the nonlinear function value in a specified constraint (row) given the current variable values. If the function has been evaluated over the current x values, the method will retrieve it.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. if negative, it is an objective function.
x - holds the values of the variables in a double array.
functionEvaluated - holds whether the function has been evaluated.
Returns:
the nonlinear function value in the specified constraint (row) given the current variable values.

calculateFunction

public double calculateFunction(int rowIdx,
                                double[] x,
                                boolean functionEvaluated)
Calculate the function (nonlinear+quadratic+linear) value in a specified constraint (row) given the current variable values.

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
x - holds the values of the variables in a double array.
functionEvaluated - holds whether the function has been evaluated.
Returns:
the function value in the specified constraint (row) given the current variable values.

calculateNonlinearFunction

public java.lang.String calculateNonlinearFunction(int rowIdx,
                                                   java.lang.String[] x,
                                                   boolean functionEvaluated)
Calculate the nonlinear function value in a specified constraint (row) given the current variable values. If the function has been evaluated over the current x values, the method will retrieve it.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. if negative, it is an objective function.
x - holds the values of the variables in a string array.
functionEvaluated - holds whether the function has been evaluated.
Returns:
the nonlinear function value in the specified constraint (row) given the current variable values in a string.

calculateNonlinearDerivatives

public it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap calculateNonlinearDerivatives(int rowIdx,
                                                                                      double[] x,
                                                                                      boolean functionEvaluated)
Calculate the nonlinear function derivatives in a specified constraint (row) given the current variable values w.r.t all variables.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. If negative, it's an objective function.
x - holds the values of the variables in a double array.
functionEvaluated - holds whether the function has been evaluated.
Returns:
a hashmap of the nonzero function derivative values given the current variable values. The map keys are variable indexes, and the map values are nonzero derivatives.

getNonlinearDerivatives

public it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap getNonlinearDerivatives(int rowIdx)
Get the nonlinear function derivatives in a specified constraint (row) given the current variable values w.r.t. all variables. This method assumes that the derivatives have already been calculated over the current variable values.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. If negative, it's an objective function.
Returns:
a hashmap of the nonzero function derivative values given the current variable values. The map keys are variable indexes, and the map values are nonzero derivatives. This method assumes that the derivative values have already been calculated over the current variable values w.r.t all variables.

calculateNonlinearDerivative

public double calculateNonlinearDerivative(int rowIdx,
                                           double[] x,
                                           int varIndex,
                                           boolean functionEvaluated)
Calculate the nonlinear function derivative in a specified constraint (row) given the current variable values w.r.t one variable.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. If negative, it's an objective function.
x - holds the values of the variables in a double array.
varIndex - holds the variable index on which to take the derivative.
functionEvaluated - holds whether the function has been evaluated.
Returns:
the nonlinear function derivative in the specified constraint (row) given the current variable values w.r.t the specified variable.

getNonlinearDerivative

public double getNonlinearDerivative(int rowIdx,
                                     int varIndex)
Get the nonlinear function derivative in a specified constraint (row) given the current variable values w.r.t. one variable. This method assumes that the derivatives have already been calculated over the current variable values.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. If negative, it's an objective function.
varIndex - holds the variable index on which to take the derivative.
Returns:
the nonlinear function derivative in the specified constraint (row) given of the current variable values w.r.t the specified variable assuming that the derivative has already been calculated over the current variable values w.r.t the specified variable.

calculateNonlinearHessianMatrix

public it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap calculateNonlinearHessianMatrix(int rowIdx,
                                                                                              double[] x,
                                                                                              boolean derivativeEvaluated)
Calculate the nonlinear Hessian in a specified constraint (row) given the current variable values w.r.t all variables.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. If negative, it's an objective function.
x - holds the values of the variables in a double array.
derivativeEvaluated - holds whether the function derivatives have been evaluated.
Returns:
a sparse hash map of the upper triangular non-zero second partial derivatives w.r.t to variable i and then j, given the current variable values. The map keys are the strings of variable indexes delimited by a comma, i.e. "i,j" and the map values are the Hessian values.

getNonlinearHessianMatrix

public it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap getNonlinearHessianMatrix(int rowIdx)
Get the nonlinear Hessian in a specified constraint (row) given the current variable values w.r.t all variables. This method assumes that the Hessian has already been calculated over the current variable values.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. If negative, it's an objective function.
Returns:
a sparse hash map of the upper triangular non-zero second partial derivatives w.r.t to variable i and then j, given the current variable values. The map keys are the strings of variable indexes delimited by a comma, i.e. "i,j" and the map values are the Hessian values. This method assumes that the Hessian has already been calculated over the current variable values w.r.t all variables.

getNonlinearHessianValue

public double getNonlinearHessianValue(int rowIdx,
                                       int i,
                                       int j)
Get the nonlinear Hessian in a specified constraint (row) given the current variable values w.r.t Xi and Xj. This method assumes that the Hessian has already been calculated over the current variable values.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. If negative, it's an objective function.
i - holds the first variable index of the second order partial derivative.
j - holds the second variable index of the second order partial derivative.
Returns:
the function Hessian value (i.e. second order partial derivative) corresponding to variable i and j.

getNonlinearPostfix

public java.util.Vector getNonlinearPostfix(int rowIdx)
Express the nonlinear function in the specified constraint (row) in a postfix vector of operator symbols. If the row idx is negative, it returns that from an objective function.

Parameters:
rowIdx - holds the row number to which the nonlinear function belongs. if negative, it is an objective function.
Returns:
the nonlinear function in the specified constraint (row) expressed in a postfix vector of operator symbols.. If the row idx is negative, it returns that from an objective function.

getNonlinearPrefix

public java.util.Vector getNonlinearPrefix(int rowIdx)
Express the nonlinear function in the specified row in a prefix vector of operator symbols If the row idx is negative, it returns that from an objective function.

Parameters:
rowIdx - holds the row idx to which the nonlinear function belongs. if negative, it is an objective function.
Returns:
the nonlinear function in the specified constraint (row) expressed in a prefix vector of operator symbols. If the row idx is negative, it returns that from an objective function.

getNonlinearInfix

public java.util.Vector getNonlinearInfix(int rowIdx)
Express the nonlinear function in the specified constraint (row) in an infix vector of operator symbols If the row idx is negative, it returns that from an objective function.

Parameters:
rowIdx - holds the row idx to which the nonlinear function belongs. if negative, it is an objective function.
Returns:
the nonlinear function in the specified constraint (row) expressed in an infix vector of operator symbols. If the row idx is negative, it returns that from an objective function.

getPostfix

public java.util.Vector getPostfix(int rowIdx)
Express the function in the specified constraint (row) in a postfix vecotr of operator symbols. If the row idx is negative, it returns that from an objective function.

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
the function in the specified constraint (row) expressed in a postfix vector of operator symbols.. If the row idx is negative, it returns that from an objective function.

getPrefix

public java.util.Vector getPrefix(int rowIdx)
Express the function in the specified constraint (row) in a prefix vector of operator symbols.. If the row idx is negative, it returns that from an objective function.

Parameters:
rowIdx - holds the row idx to which the function belongs. if negative, it is an objective function.
Returns:
the function in the specified constraint (row) expressed in a prefix vector of operator symbols.. If the row idx is negative, it returns that from an objective function.

getInfix

public java.util.Vector getInfix(int rowIdx)
Express the function in the specified constraint (row) in an infix vecotr of operator symbols. If the row idx is negative, it returns that from an objective function.

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
the function in the specified constraint (row) expressed in a infix vector of operator symbols.. If the row idx is negative, it returns that from an objective function.

simplifyNonlinearFunction

public int simplifyNonlinearFunction(int rowIdx)
Simplify the nonlinear part of the function in a specified constraint (row).

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
the reduction size, i.e. the number of nodes taken out of the original expression tree. If 0, the nonlinear function is reduced.

linearizeNonlinearFunction

public it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap linearizeNonlinearFunction(int rowIdx)

Linearize the the expression tree of a specified constraint (row) so that it doesn't contain linear terms. The expression tree of the node will become smaller if there are linear terms. If the node is fully linear, the node becomes null. If the node is not linear at all, it will remain the same and the returned hash map has a size zero.

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
a hashmap of linear terms extracted out from the expression tree of the specified row, with keys being the variable indices and values being the variable coefficients.

quadratizeNonlinearFunction

public boolean quadratizeNonlinearFunction(int rowIdx)

Quadratize the current expression tree, or make all the quadratic terms written in the form of a quadratic node with its children being the quadratic terms.

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
whether there is conversion of some quadratic terms.

getNonlinearVariableIndices

public it.unimi.dsi.fastutil.ints.IntOpenHashSet getNonlinearVariableIndices(int rowIdx)
Get an integer set of indices of the variables that exist in the nonlinear part of the function in a specified constraint (row).

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
a set of indices of the variables that exist in the nonlinear part of the function in the specified constraint (row).

getJacobianNonzeroIndexes

public int[][] getJacobianNonzeroIndexes()

Get row (constraint) and col (var) indexes of nonzero elements of the constraint gradients (Jacobian Matrix). This is usually needed before a nonlinear optimization starts. A variable index will be counted once everytime the variable appears in a separate row (or constraint).

It is not appropriate to use this method if there is a variable that takes as its index an integer-valued variable.

Returns:
a two dimmensional integer array indexes = int[2][numNonzeroIndexes]. So in essense, the method returns two arrays of the same size. The 1st array -- indexes[0] of size numNonzeroIndexes -- contains the row (constraint) number of a variable indexes and the 2nd array -- indexes[1] again of size numNonzeroIndexes -- contains the variable indexes. For example if indexes[0] = {0, 0, 1, 1, 2} and indexes[1] = {1, 3, 0, 2, 1}, it means variables appear in (row, col) = (0, 1), (0, 3), (1, 0), (1, 2) and (2, 1) so the corresponding entries in the Jacobian matrix may be nonzeros.

getExpressionTreeSize

public int getExpressionTreeSize(int rowIdx)
Get the expression tree size, i.e. the number of nodes, of the nonlinear expression tree in the specified constraint (row).

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
the tree size, i.e. the number of nodes, of the nonlinear expression tree in the specified constraint (row).

getTrigonometricFunctionNumbers

public int getTrigonometricFunctionNumbers(int rowIdx)
Get the number of trigonometric functions in the nonlinear function of the specified row.

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
the number of trigonometric functions in the nonlinear function of the specified row.

getNumberOfStatisticFunctions

public int getNumberOfStatisticFunctions(int rowIdx)
Get the number of statistic functions in the nonlinear function of the specified constraint (row).

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
the number of statistic functions in the nonlinear function of the specified constraint (row).

getNumberOfProbabilityFunctions

public int getNumberOfProbabilityFunctions(int rowIdx)
Get the number of probability functions in the nonlinear function of the specified constraint (row).

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
the number of probability functions in the nonlinear function of the specified constraint (row).

getNumberValues

public java.util.HashSet getNumberValues(int rowIdx)
Get a set of number values that exist in the nonlinear function of the specified constraint (row).

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
a set of number values that exist in the nonlinear function of the specified constraint (row).

getIdentifiers

public java.util.HashSet getIdentifiers(int rowIdx)
Get a set of names of identifiers that exist in the nonlinear function of the specified constraint (row).

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
a set of names of identifiers that exist in the nonlinear function of the specified constraint (row).

getLogicAndRelationalSymbols

public java.util.HashSet getLogicAndRelationalSymbols(int rowIdx)
Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
a set of logic and relational operator symbols that exist in the nonlinear expression of the specified constraint (row).

getNonlinearQuadraticTerms

public java.util.HashSet getNonlinearQuadraticTerms(int rowIdx)
Get a set of quadratic terms that exist in the expression tree of the specified constraint (row), each set member is of the form: i,j,coef, that is the first variable index, the second variable index and the coefficient value, delimited by comma.

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
a set of quadratic terms that exist in the expression tree of the specified constraint (row).

getSimulationNames

public java.util.HashSet getSimulationNames(int rowIdx)
Get a set of names of the simulations that exist in the expression tree of the specified constraint (row).

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
a set of names of the simulations that exist in the expression tree of the specified constraint (row).

getUserFunctionNames

public java.util.HashSet getUserFunctionNames(int rowIdx)
Get a set of names of the user defined functions that exist in the expression tree of the specified constraint (row).

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
a set of names of the user defined functions that exist in the expression tree of the specified constraint (row).

getXPath

public java.util.HashSet getXPath(int rowIdx)
Get a set of XPaths that exist in the expression tree of the specified constraint (row), each set member is of the form: uri:path, that is uri and path delimited by :.

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
a set of XPaths that exist in the expression tree of the specified constraint (row), each set member is of the form: uri:path, that is uri and path delimited by :.

getNetworkNodes

public java.util.HashSet getNetworkNodes(int rowIdx)
Get a set of network nodes that are referred in the expression tree of the specified constraint (row), each set member is of the form: nodeName:propertyName, that is nodeName and property name delimited :.

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
a set of network nodes that are referred in the expression tree of the specified constraint (row), each set member is of the form: nodeName:propertyName, that is nodeName and property name delimited :.

getNetworkArcs

public java.util.HashSet getNetworkArcs(int rowIdx)
Get a set of network arcs that are referred in the expression tree of the specified constraint (row), each set member is of the form: arcName:propertyName, that is arcName and property name delimited :.

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
a set of network arcs that are referred in the expression tree of the specified constraint (row), each set member is of the form: arcName:propertyName, that is arcName and property name delimited :.

getNumberOfComplementsOperator

public int getNumberOfComplementsOperator(int rowIdx)
Get the number of the complements operator in the expression tree of the specified constraint (row).

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
the number of the complements operator in the expression tree of the specified constraint (row).

getNumberOfProbOperator

public int getNumberOfProbOperator(int rowIdx)
Get the number of the probability operator (usually in chance constraint) in the expression tree of the specified constraint (row).

Parameters:
rowIdx - holds the row number to which the function belongs. if negative, it is an objective function.
Returns:
Get the number of the probability operator (usually in chance constraint) in the expression tree of the specified constraint (row).

getXMLDataElement

public org.w3c.dom.Element getXMLDataElement()
Get the xmlData element.

Returns:
the xmlData element.

getXMLDataString

public java.lang.String getXMLDataString()
Get the xmlData in a string.

Returns:
the xmlData in a string.

main

public static void main(java.lang.String[] argv)
main for test purposes.

Parameters:
argv - command line arguments.