org.optimizationservices.oscommon.representationparser
Class OSrLReader

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

public class OSrLReader
extends OSgLReader

The OSrLReader class parses an OSrL instance into a DOM tree and provides a set of "get" methods that can be used to retrieve different pieces of information of the instance.

Since:
OS 1.0
Version:
1.0, 03/14/2004
Author:
Robert Fourer, Jun Ma, Kipp Martin

Field Summary
 
Fields inherited from class org.optimizationservices.oscommon.representationparser.OSgLReader
m_document
 
Constructor Summary
OSrLReader()
          Default constructor.
OSrLReader(boolean validate)
          constructor.
 
Method Summary
 double getAvailableDiskSpace()
          Get the available disk space (in bytes).
 double getAvailableMemory()
          Get the available memory (in bytes).
 int getConstraintNumber()
          Get constraint number.
 int getCurrentJobCount()
          Get the current job count.
 java.lang.String getCurrentState()
          Get the current state, , which can be: "busy", "busyButAccepting", "idle", "idleButNotAccepting" and "noResponse".
 double[] getDualVariableValues(int solIdx)
          Get the [i]th optimization solution's dual variable values, where i equals the given solution index.
 java.lang.String getGeneralMessage()
          Get the general message.
 GeneralStatus getGeneralStatus()
          Get the general status.
 java.lang.String getGeneralStatusDescription()
          Get the general status description.
 java.lang.String getGeneralStatusType()
          Get the general status type, which can be: success, error, warning.
 java.lang.String getInstanceName()
          Get instance name.
 java.lang.String getJobID()
          Get the job id.
 JobStatistics[] getJobStatistics()
          Get the statistics of all the jobs.
 int getObjectiveNumber()
          Get objective number.
 double[] getObjectiveValues(int solIdx)
          Get the [i]th optimization solution's objective values, where i equals the given solution index.
 double[] getOptimalDualVariableValues(int objIdx)
          Get one solution of optimal dual variable values.
 java.lang.String[] getOptimalPrimalVariableStringValues(int objIdx)
          Get one solution of optimal primal variable string values.
 double[] getOptimalPrimalVariableValues(int objIdx)
          Get one solution of optimal primal variable values.
 OSAnalysis getOSAnalysis()
          Get the optimization analysis in the standard OSAnalysis data structure.
 OSResult getOSResult()
          get the standard OSResult, a local interface for storing Optimization Services result.
 OtherConstraintResult[] getOtherConstraintResults(int solIdx)
          Get the [i]th optimization solution's other (non-standard/solver specific)constraint-related results, where i equals the given solution index.
 OtherObjectiveResult[] getOtherObjectiveResults(int solIdx)
          Get the [i]th optimization solution's other (non-standard/solver specific)objective-related results, where i equals the given solution index.
 OtherOptimizationResult[] getOtherOptimizationResults(int solIdx)
          Get the [i]th optimization solution's other (non-standard/solver specific)optimization-related results, where i equals the given solution index.
 java.lang.String getOtherResultDescriptionByName(java.lang.String name)
          Get the String value from the other info hash map.
 java.lang.String[] getOtherResultDescriptions()
          Get the descriptions of all other result information.
 java.lang.String[] getOtherResultNames()
          Get the names of all other result information.
 int getOtherResultNumber()
          Get the number of other result information.
 java.util.HashMap<java.lang.String,java.lang.String> getOtherResults()
          Get the hash map of other result information.
 java.lang.String getOtherResultValueByName(java.lang.String name)
          Get the String value from the other info hash map.
 java.lang.String[] getOtherResultValues()
          Get the values of all other result information.
 OtherVariableResult[] getOtherVariableResults(int solIdx)
          Get the [i]th optimization solution's other (non-standard/solver specific)variable-related results, where i equals the given solution index.
 ProcessStatistics getProcessStatistics()
          Get the process statistics.
 java.util.GregorianCalendar getResultTime()
          Get time of the result.
 java.lang.String getServiceName()
          Get service name.
 java.lang.String getServiceURI()
          Get service uri.
 double getServiceUtilization()
          Get the service utilization ([0, 1]).
 OptimizationSolution getSolution(int solIdx)
          Get the [i]th optimization solution, where i equals the given solution index.
 java.lang.String getSolutionMessage(int solIdx)
          Get the [i]th optimization solution message, where i equals the given solution index.
 int getSolutionNumber()
          get the number of solutions.
 int getSolutionObjectiveIndex(int solIdx)
          Get the [i]th optimization solution's objective index, where i equals the given solution index.
 OptimizationSolutionStatus getSolutionStatus(int solIdx)
          Get the [i]th optimization solution status, where i equals the given solution index.
 java.lang.String getSolutionStatusDescription(int solIdx)
          Get the [i]th optimization solution status description, where i equals the given solution index.
 java.lang.String getSolutionStatusType(int solIdx)
          Get the [i]th optimization solution status type, where i equals the given solution index.
 OptimizationSolutionSubstatus[] getSolutionSubStatuses(int solIdx)
          Get the [i]th optimization solution subStatuses, where i equals the given solution index.
 VariableValues getSparseVariableValues(int solIdx)
          Get the [i]th optimization solution's variable values in a sparse data structure, where i equals the given solution index.
 java.util.GregorianCalendar getTimeLastJobEnded()
          Get the time last job ended.
 double getTimeLastJobTook()
          Get the time last job took (in seconds).
 java.util.GregorianCalendar getTimeServiceStarted()
          Get the time the service started.
 int getTotalJobsSoFar()
          Get the total jobs received so far.
 int getVariableNumber()
          Get variable number.
 java.lang.String[] getVariableStringValues(int solIdx)
          Get the [i]th optimization solution's variable string values, where i equals the given solution index.
 double[] getVariableValues(int solIdx)
          Get the [i]th optimization solution's variable values, where i equals the given solution index.
static void main(java.lang.String[] argv)
          main for test purposes.
 
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

OSrLReader

public OSrLReader(boolean validate)
constructor.

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

OSrLReader

public OSrLReader()
Default constructor.

Method Detail

getOSResult

public OSResult getOSResult()
                     throws java.lang.Exception
get the standard OSResult, a local interface for storing Optimization Services result.

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

getGeneralStatus

public GeneralStatus getGeneralStatus()
Get the general status.

Returns:
the general status.

getGeneralStatusType

public java.lang.String getGeneralStatusType()
Get the general status type, which can be: success, error, warning.

Returns:
the general status type, null if none.

getGeneralStatusDescription

public java.lang.String getGeneralStatusDescription()
Get the general status description.

Returns:
the general status description, null or empty string if none.

getServiceURI

public java.lang.String getServiceURI()
Get service uri.

Returns:
the service uri.

getServiceName

public java.lang.String getServiceName()
Get service name.

Returns:
the service name.

getInstanceName

public java.lang.String getInstanceName()
Get instance name.

Returns:
the instance name.

getJobID

public java.lang.String getJobID()
Get the job id.

Returns:
the job id.

getResultTime

public java.util.GregorianCalendar getResultTime()
Get time of the result.

Returns:
the time of the result.

getGeneralMessage

public java.lang.String getGeneralMessage()
Get the general message.

Returns:
the general message.

getProcessStatistics

public ProcessStatistics getProcessStatistics()
Get the process statistics.

Returns:
the process statistics.

getJobStatistics

public JobStatistics[] getJobStatistics()
Get the statistics of all the jobs.

Returns:
the statistics of all the jobs, which is an array of jobStatistics with each member corresponding to one job; null if none.

getCurrentState

public java.lang.String getCurrentState()
Get the current state, , which can be: "busy", "busyButAccepting", "idle", "idleButNotAccepting" and "noResponse".

Returns:
the current status, "noResponse" if none.

getAvailableDiskSpace

public double getAvailableDiskSpace()
Get the available disk space (in bytes).

Returns:
the available disk space, Double.NaN if none.

getAvailableMemory

public double getAvailableMemory()
Get the available memory (in bytes).

Returns:
the available memory, Double.NaN if none.

getCurrentJobCount

public int getCurrentJobCount()
Get the current job count.

Returns:
the current job count, -1 if none.

getTotalJobsSoFar

public int getTotalJobsSoFar()
Get the total jobs received so far.

Returns:
the total jobs received so far, -1 if none.

getTimeLastJobEnded

public java.util.GregorianCalendar getTimeLastJobEnded()
Get the time last job ended.

Returns:
the time last job ended. If none, it returns unix creation time: GregorianCalendar(1970, 0, 1, 0, 0, 0).

getTimeLastJobTook

public double getTimeLastJobTook()
Get the time last job took (in seconds).

Returns:
the the time last job took, Double.NaN if none.

getTimeServiceStarted

public java.util.GregorianCalendar getTimeServiceStarted()
Get the time the service started.

Returns:
the time last job ended. If none, it returns unix creation time: GregorianCalendar(1970, 0, 1, 0, 0, 0).

getServiceUtilization

public double getServiceUtilization()
Get the service utilization ([0, 1]).

Returns:
the the time last job took, Double.NaN if none.

getOtherResults

public java.util.HashMap<java.lang.String,java.lang.String> getOtherResults()
Get the hash map of other result information.

Returns:
the hash map of other result information.

getOtherResultNumber

public int getOtherResultNumber()
Get the number of other result information.

Returns:
the number of other result information.

getOtherResultValueByName

public java.lang.String getOtherResultValueByName(java.lang.String name)
Get the String value from the other info hash map.

Parameters:
name - holds the name of the other info to get.
Returns:
String value from the other info hash map, null if none.

getOtherResultDescriptionByName

public java.lang.String getOtherResultDescriptionByName(java.lang.String name)
Get the String value from the other info hash map.

Parameters:
name - holds the name of the other info to get.
Returns:
String value from the other info hash map, null if none.

getOtherResultNames

public java.lang.String[] getOtherResultNames()
Get the names of all other result information.

Returns:
the names of all other result information.

getOtherResultValues

public java.lang.String[] getOtherResultValues()
Get the values of all other result information.

Returns:
the values of all other result information.

getOtherResultDescriptions

public java.lang.String[] getOtherResultDescriptions()
Get the descriptions of all other result information.

Returns:
the descriptions of all other result information.

getVariableNumber

public int getVariableNumber()
Get variable number.

Returns:
variable number, -1 if no information.

getObjectiveNumber

public int getObjectiveNumber()
Get objective number.

Returns:
objective number, -1 if no information.

getConstraintNumber

public int getConstraintNumber()
Get constraint number.

Returns:
constraint number, -1 if no information.

getSolutionNumber

public int getSolutionNumber()
get the number of solutions.

Returns:
the number of solutions, 0 if none.

getOptimalPrimalVariableValues

public double[] getOptimalPrimalVariableValues(int objIdx)
Get one solution of optimal primal variable values.

Parameters:
objIdx - holds the objective index the optimal value corresponds to.
Returns:
a double dense array of the optimal values, null if no optimal value.

getOptimalPrimalVariableStringValues

public java.lang.String[] getOptimalPrimalVariableStringValues(int objIdx)
Get one solution of optimal primal variable string values.

Parameters:
objIdx - holds the objective index the optimal value corresponds to.
Returns:
a string dense array of the optimal string values, null if no optimal value.

getOptimalDualVariableValues

public double[] getOptimalDualVariableValues(int objIdx)
Get one solution of optimal dual variable values.

Parameters:
objIdx - holds the objective index the optimal value corresponds to.
Returns:
a double dense array of the optimal dual values, null if no optimal value.

getSolution

public OptimizationSolution getSolution(int solIdx)
Get the [i]th optimization solution, where i equals the given solution index.

Parameters:
solIdx - holds the solution index to get the solution.
Returns:
the optimization solution that corresponds to solIdx, null if none.

getSolutionStatus

public OptimizationSolutionStatus getSolutionStatus(int solIdx)
Get the [i]th optimization solution status, where i equals the given solution index. The solution status includes the status type, optional descriptions and possibly substatuses.

Parameters:
solIdx - holds the solution index to get the solution status.
Returns:
the optimization solution status that corresponds to solIdx, null if none.
See Also:
OptimizationSolutionStatus

getSolutionStatusType

public java.lang.String getSolutionStatusType(int solIdx)
Get the [i]th optimization solution status type, where i equals the given solution index. The solution status type can be: unbounded, globallyOptimal, locallyOptimal, optimal, bestSoFar, feasible, infeasible, stoppedByLimit, unsure, error, other

Parameters:
solIdx - holds the solution index to get the solution status type.
Returns:
the optimization solution status type that corresponds to solIdx, null or empty string if none.

getSolutionStatusDescription

public java.lang.String getSolutionStatusDescription(int solIdx)
Get the [i]th optimization solution status description, where i equals the given solution index.

Parameters:
solIdx - holds the solution index to get the solution status description.
Returns:
the optimization solution status description that corresponds to solIdx, null or empty string if none.

getSolutionSubStatuses

public OptimizationSolutionSubstatus[] getSolutionSubStatuses(int solIdx)
Get the [i]th optimization solution subStatuses, where i equals the given solution index.

Parameters:
solIdx - holds the solution index to get the solution substatuses.
Returns:
an array optimization solution subStatuses that corresponds to solIdx, null or empty string if none.
See Also:
org.optimizationservices.oscommon.datastructure.osresult.OptimizationSolutionSubstatus;

getSolutionMessage

public java.lang.String getSolutionMessage(int solIdx)
Get the [i]th optimization solution message, where i equals the given solution index.

Parameters:
solIdx - holds the solution index to get the solution message.
Returns:
the optimization solution message that corresponds to solIdx, null or empty if none.

getSolutionObjectiveIndex

public int getSolutionObjectiveIndex(int solIdx)
Get the [i]th optimization solution's objective index, where i equals the given solution index. The first objective's index should be -1, the second -2, and so on.

Parameters:
solIdx - holds the solution index to get the variable string values.
Returns:
the optimization objective index that corresponds to solIdx, 0 if none. All the objective indexes are negative starting from -1 downward.

getVariableValues

public double[] getVariableValues(int solIdx)
Get the [i]th optimization solution's variable values, where i equals the given solution index.

Parameters:
solIdx - holds the solution index to get the variable values.
Returns:
a double dense array of variable values, null if no variable values.

getSparseVariableValues

public VariableValues getSparseVariableValues(int solIdx)
Get the [i]th optimization solution's variable values in a sparse data structure, where i equals the given solution index. The sparse data stucture is of the VariableValues data structure. VariableValues holds var[], an array of VarValues. Each var member contains an idx and a value. If var[] is null, all the variable values are 0.

Parameters:
solIdx - holds the solution index to get the sparse variable values.
Returns:
a sparse variable value data structure in VaribleValues, null if no variable values.
See Also:
VariableValues, VarValue

getVariableStringValues

public java.lang.String[] getVariableStringValues(int solIdx)
Get the [i]th optimization solution's variable string values, where i equals the given solution index.

Parameters:
solIdx - holds the solution index to get the variable string values.
Returns:
a string dense array of variable values, null if no variable values.

getOtherVariableResults

public OtherVariableResult[] getOtherVariableResults(int solIdx)
Get the [i]th optimization solution's other (non-standard/solver specific)variable-related results, where i equals the given solution index.

Parameters:
solIdx - holds the solution index to get the other variable results.
Returns:
an array of other variable results in OtherVariableResult[] array data structure, null if none. Each other variable result contains the name (required), an optional description (string) and an optional value (string). Each other variable result can also optionally contain an array OtherVarResult for each variable. The OtherVarResult contains a variable idx (required), and an optional string value.
See Also:
OtherVariableResult, OtherVarResult

getObjectiveValues

public double[] getObjectiveValues(int solIdx)
Get the [i]th optimization solution's objective values, where i equals the given solution index. Usually one of the objective is what the solution was solved for (or based on). Its index should be indicated in the solution's objectiveIdx attribute. Based on this objective's solution, the rest of the objective values are (optionally) calculated.

Parameters:
solIdx - holds the solution index to get the objective values.
Returns:
a double dense array of objective values, null if null if no objective values. Possibly only the objective that the solution is based on has the value, and the rest of the objective values all get a Double.NaN value, meaning that they are not calculated.

getOtherObjectiveResults

public OtherObjectiveResult[] getOtherObjectiveResults(int solIdx)
Get the [i]th optimization solution's other (non-standard/solver specific)objective-related results, where i equals the given solution index.

Parameters:
solIdx - holds the solution index to get the other objective results.
Returns:
an array of other objective results in OtherObjectiveResult[] array data structure, null if none. Each other objective result contains the name (required), an optional description (string) and an optional value (string). Each other objective result can also optionally contain an array OtherObjResult for each objective. The OtherObjResult contains an objective idx (required) and an optional string value.
See Also:
OtherObjectiveResult, OtherObjResult

getDualVariableValues

public double[] getDualVariableValues(int solIdx)
Get the [i]th optimization solution's dual variable values, where i equals the given solution index.

Parameters:
solIdx - holds the solution index to get the dual variable values.
Returns:
a double dense array of the dual variable values, null if none.

getOtherConstraintResults

public OtherConstraintResult[] getOtherConstraintResults(int solIdx)
Get the [i]th optimization solution's other (non-standard/solver specific)constraint-related results, where i equals the given solution index.

Parameters:
solIdx - holds the solution index to get the other constraint results.
Returns:
an array of other constraint results in OtherConstraintResult[] array data structure, null if none. Each other constraint result contains the name (required), an optional description (string) and an optional value (string). Each other constraint result can also optionally contain an array OtherConResult for each constraint. The OtherConResult contains a constraint idx (required), and an optional string value.
See Also:
OtherConstraintResult, OtherConResult

getOtherOptimizationResults

public OtherOptimizationResult[] getOtherOptimizationResults(int solIdx)
Get the [i]th optimization solution's other (non-standard/solver specific)optimization-related results, where i equals the given solution index. These other results are usually on the general optimization, not specifically on the variables, objective, or constraints.

Parameters:
solIdx - holds the solution index to get the other optimization results.
Returns:
an array of other optimization results in OtherOptimizationResult[] array data structure, null if none. Each other optimization result contains the name (required), an optional description (string) and an optional value (string).
See Also:
OtherOptimizationResult

getOSAnalysis

public OSAnalysis getOSAnalysis()
Get the optimization analysis in the standard OSAnalysis data structure.

Returns:
the optimization analysis in the standard OSAnalysis data structure, null if none.
See Also:
OSAnalysis

main

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

Parameters:
argv - command line arguments.