|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.optimizationservices.oscommon.representationparser.FMLWriter
public class FMLWriter
The FMLWriter
class is used to output different parts of
a linear program (e.g. data and solutions) to a document object model (DOM) that follows
FML Schema. Each element declared in the FML Schema has a corresponding protected element creation
method (e.g. createEl for creation of element el). User do not have direct access to any of these
protected methods. They get to manipulate the output of FML construction through a group of higher level
optimization related public "set" methods (e.g. setConstraints). Each "set" method has a corresponding
opposite "on" method in the FMLReader
class, which has
exactly the same set of arguments. Each method checks within itself the argument consistency against FML Schema.
There is no specific sequence the user should follow to invoke these set methods. User can call the
same set methods several times. If the parameters are different, old values will be replaced by new ones.
User should, though, make sure values submitted through different "set" methods are consistent. For example
if variableCount in setDescription
is set to 2, then the variableLbs array in
setVariables
has to have a length 2.
The FMLWriter class also provides auxiliary facilities to write the xml to different output.
FMLReader
Constructor Summary | |
---|---|
FMLWriter()
constructor |
Method Summary | |
---|---|
static void |
main(java.lang.String[] argv)
main for test purposes. |
boolean |
setAMatrix(boolean isColumnMajor,
double[] nonzeroValues,
int[] nonzeroIndexes,
int[] endIndexes,
int[] numberOfNonzeros)
Set the AMatrix related elements. |
boolean |
setConstraints(java.lang.String[] constraintNames,
double[] constraintLhs,
double[] constraintRhs)
Set the constraint related elements. |
boolean |
setDescription(java.lang.String source,
int variableCount,
int constraintCount)
Set the linearProgramDescription related elements. |
boolean |
setDualSolution(java.lang.String[] dualNames,
double[] dualValues,
int[] dualIndexes)
Set the dual solution related elements. |
boolean |
setObjective(boolean isMinimization,
double objectiveConstant,
double[] ObjectiveCoefficients)
Set the objective function related elements. |
boolean |
setOption(java.lang.String[] optionNames,
java.lang.String[] optionValues)
Set the option related elements. |
boolean |
setPrimalSolution(java.lang.String[] primalNames,
double[] primalValues,
int[] primalIndexes)
Set the primal solution related elements. |
boolean |
setSolution(java.lang.String statusId,
java.lang.String status,
java.lang.String solverMessage,
double optimalValue)
Set the objective solution related elements. |
boolean |
setVariables(java.lang.String[] variableNames,
double[] variableLbs,
double[] variableUbs,
char[] variableDomains)
Set the variable related elements. |
boolean |
writeToFile(java.lang.String fileName)
Write the xml file from the internally constructed DOM tree structure that contains the FML linear program instance (data and/or solution) to a file. |
java.lang.String |
writeToSring()
Write the xml file from the internally constructed DOM tree structure that contains the FML linear program instance (data and/or solution) to a string to be returned. |
boolean |
writeToStandardOutput()
Write the xml file from the internally constructed DOM tree structure that contains the FML linear program instance (data and/or solution) to the standard output (e.g. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FMLWriter()
Method Detail |
---|
public boolean writeToFile(java.lang.String fileName)
fileName
- holds the xml filename to write out the file to.
public boolean writeToStandardOutput()
public java.lang.String writeToSring()
public boolean setDescription(java.lang.String source, int variableCount, int constraintCount)
source
- holds the source information of the optimization problem.variableCount
- holds the number of columns, i.e. variable number.constraintCount
- holds the number of rows, i.e. constraint number.
public boolean setOption(java.lang.String[] optionNames, java.lang.String[] optionValues)
optionNames
- holds the names of all the options.optionValues
- holds the values of all the options corresponding to the names.
public boolean setVariables(java.lang.String[] variableNames, double[] variableLbs, double[] variableUbs, char[] variableDomains)
variableNames
- holds the names of all the columns, i.e. variable names. It may be empty.variableLbs
- holds the values of lower bounds for the variables. It may be empty.variableUbs
- holds the values of upper bounds for the variables. It may be empty.variableDomains
- holds the types of all the variables, (e.g. 'C' for continuous
type, 'I' for integer type, and 'B' for binary type). It may be empty.
public boolean setConstraints(java.lang.String[] constraintNames, double[] constraintLhs, double[] constraintRhs)
The constraint information contains all the information about the linear constraints
except for the AMatrix, which is to be set in the setAMatrix
method.
constraintNames
- holds the names of all the rows, i.e. constraint names. It may be empty.constraintLhs
- holds the values of the lower bounds for the constraints. It may be empty.constraintRhs
- holds the values of the upper bounds for the constraints. It may be empty.
public boolean setAMatrix(boolean isColumnMajor, double[] nonzeroValues, int[] nonzeroIndexes, int[] endIndexes, int[] numberOfNonzeros)
The AMatrix stores all the information in the A part of the linear constraints lhs<=AX<=rhs
isColumnMajor
- holds the value of whether the AMatrix holding linear program data is stored
by column. If false, the matrix is stored by row.nonzeroValues
- holds the values of the vector element nonz in AMatrix, which contains nonzero elements.nonzeroIndexes
- holds the values of the vector element rowIdx or colIdx in AMatrix. If the matrix is
stored by column (row), rowIdx (colIdx) is the vector of row (column) indexes.endIndexes
- holds the values of the vector element pntANonz in AMatrix, which points to the end of a
column (row) of nonzero elements in AMatrix.numberOfNonzeros
- holds the values of the vector element numNonz in AMatrix. The vector numNonz, if
present, stores the number of nonzero elements in the column (row). If numNonz is not present, then nonz
stores the columns (rows) in matrix order. If the matrix is stored by column (row), rowIdx (colIdx) is
the vector of row (column) indexes.
public boolean setObjective(boolean isMinimization, double objectiveConstant, double[] ObjectiveCoefficients)
isMinimization
- holds whether the objective is minimization or not.objectiveConstant
- holds the value of objective function constant.ObjectiveCoefficients
- holds the values of the objective function coefficients. It may be empty.
public boolean setSolution(java.lang.String statusId, java.lang.String status, java.lang.String solverMessage, double optimalValue)
The objective solution does not include primal and dual solutions which are to be set
in the setPrimalSolution
and setDualSolution
methods.
statusId
- holds the information of optimization solution status id.status
- holds the status message of the optimization solution.solverMessage
- holds the value of solver message.optimalValue
- holds the value of the optimal solution.
setPrimalSolution(java.lang.String[], double[], int[])
,
setDualSolution(java.lang.String[], double[], int[])
public boolean setPrimalSolution(java.lang.String[] primalNames, double[] primalValues, int[] primalIndexes)
priamlNames
- holds the names of primal variable solutions. It may be empty.primalValues
- holds the values of primal variable solutions corresponding to the primalIndexes.primalIndexes
- holds the indexes of primal variable solutions corresponding to the primalValues.
public boolean setDualSolution(java.lang.String[] dualNames, double[] dualValues, int[] dualIndexes)
dualNames
- holds the names of dual variable solutions. It may be empty.dualValues
- holds the values of dual variable solutions corresponding to the primalIndexes.dualIndexes
- holds the indexes of dual variable solutions corresponding to the primalValues.
public static void main(java.lang.String[] argv)
argv
- command line arguments.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |