org.optimizationservices.oscommon.representationparser
Class OSrLWriter

java.lang.Object
  extended by org.optimizationservices.oscommon.representationparser.OSgLWriter
      extended by org.optimizationservices.oscommon.representationparser.OSrLWriter

public class OSrLWriter
extends OSgLWriter

The OSrLWriter class is used to construct an instance that follows the OSrL format.

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.OSgLWriter
m_document
 
Constructor Summary
OSrLWriter()
          constructor.
 
Method Summary
 boolean addOtherResult(java.lang.String name, java.lang.String value, java.lang.String description)
          Add an otherResult element.
static void main(java.lang.String[] argv)
          main for test purposes.
 boolean setAvailableDiskSpace(double availableDiskSpace)
          Set the available disk space.
 boolean setAvailableMemory(double availableMemory)
          Set the available memory (in bytes).
 boolean setConstraintNumber(int constraintNumber)
          Set the constraint number.
 boolean setCurrentJobCount(int currentJobCount)
          Set the current job count.
 boolean setCurrentState(java.lang.String currentState)
          Set the current state.
 boolean setDualVariableValues(int solIdx, double[] values)
          Set the [i]th optimization solution's dual variable values, where i equals the given solution index.
 boolean setGeneralMessage(java.lang.String message)
          Set the general message.
 boolean setGeneralStatus(GeneralStatus status)
          Set the general status
 boolean setGeneralStatusDescription(java.lang.String description)
          Set the general status description.
 boolean setGeneralStatusType(java.lang.String type)
          Set the general status type, which can be: success, error, warning.
 boolean setInstanceName(java.lang.String instanceName)
          Set instance name.
 boolean setJobID(java.lang.String jobID)
          Set job id.
 boolean setJobStatistics(JobStatistics[] jobStatistics)
          Set the statistics of all jobs.
 boolean setObjectiveNumber(int objectiveNumber)
          Set the objective number.
 boolean setObjectiveValues(int solIdx, double[] objectiveValues)
          Set the [i]th optimization solution's objective values, where i equals the given solution index.
 boolean setOSAnalysis(OSAnalysis osAnalysis)
          Set the optimization analysis.
 boolean setOSResult(OSResult osResult)
          set the OSResult, a standard os result interface.
 boolean setOtherConstraintResults(int solIdx, OtherConstraintResult[] otherConstraintResults)
          Set the [i]th optimization solution's other (non-standard/solver specific)constraint-related results, where i equals the given solution index.
 boolean setOtherObjectiveResults(int solIdx, OtherObjectiveResult[] otherObjectiveResults)
          Set the [i]th optimization solution's other (non-standard/solver specific)objective-related results, where i equals the given solution index.
 boolean setOtherOptimizationResults(int solIdx, OtherOptimizationResult[] otherOptimizationResults)
          Set the [i]th optimization solution's other (non-standard/solver specific)optimization-related results, where i equals the given solution index.
 boolean setOtherResults(java.lang.String[] names, java.lang.String[] values, java.lang.String[] descriptions)
          Set all the otherResult related elements.
 boolean setOtherVariableResults(int solIdx, OtherVariableResult[] otherVariableResults)
          Set the [i]th optimization solution's other (non-standard/solver specific)variable-related results, where i equals the given solution index.
 boolean setPrimalVariableStringValues(int solIdx, java.lang.String[] x)
          Set the [i]th optimization solution's primal variable string values, where i equals the given solution index.
 boolean setPrimalVariableValues(int solIdx, double[] x)
          Set the [i]th optimization solution's primal variable values, where i equals the given solution index.
 boolean setProcessStatistics(ProcessStatistics processStatistics)
          Set the process statistics.
 boolean setResultTime(java.util.GregorianCalendar time)
          Set time of the result.
 boolean setServiceName(java.lang.String serviceName)
          Set service name.
 boolean setServiceURI(java.lang.String serviceURI)
          Set service uri.
 boolean setServiceUtilization(double serviceUtilization)
          Set the service utilization.
 boolean setSolution(int solIdx, OptimizationSolution solution)
          Set the [i]th optimization solution, where i equals the given solution index.
 boolean setSolutionMessage(int solIdx, java.lang.String solutionMessage)
          Set the [i]th optimization solution message, where i equals the given solution index.
 boolean setSolutionNumber(int solutionNumber)
          set the number of solutions.
 boolean setSolutionObjectiveIndex(int solIdx, int objectiveIdx)
          Set the [i]th optimization solution's objective index, where i equals the given solution index.
 boolean setSolutionStatus(int solIdx, OptimizationSolutionStatus status)
          Set the [i]th optimization solution status, where i equals the given solution index.
 boolean setSolutionStatus(int solIdx, java.lang.String type, java.lang.String description, OptimizationSolutionSubstatus[] subStatuses)
          Set the [i]th optimization solution status, where i equals the given solution index.
 boolean setTimeLastJobEnded(java.util.GregorianCalendar timeLastJobEnded)
          Set the time last job ended.
 boolean setTimeLastJobTook(double timeLastJobTook)
          Set the time last job took.
 boolean setTimeServiceStarted(java.util.GregorianCalendar timeServiceStarted)
          Set the time the service started.
 boolean setTotalJobsSoFar(int totalJobsSoFar)
          Set the total jobs received so far.
 boolean setVariableNumber(int variableNumber)
          Set the variable number.
 
Methods inherited from class org.optimizationservices.oscommon.representationparser.OSgLWriter
getDocument, setDocument, writeToFile, writeToSring, writeToStandardOutput
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OSrLWriter

public OSrLWriter()
constructor.

Method Detail

setOSResult

public boolean setOSResult(OSResult osResult)
                    throws java.lang.Exception
set the OSResult, a standard os result interface.

Parameters:
osResult - holds the standard os result interface.
Returns:
whether the OSResult is set successfully.
Throws:
java.lang.Exception

setGeneralStatus

public boolean setGeneralStatus(GeneralStatus status)
Set the general status

Parameters:
status - holds the general status.
Returns:
whether the general status is set successfully.

setGeneralStatusType

public boolean setGeneralStatusType(java.lang.String type)
Set the general status type, which can be: success, error, warning.

Parameters:
type - holds the general status type
Returns:
whether the general status type is set successfully or not.

setGeneralStatusDescription

public boolean setGeneralStatusDescription(java.lang.String description)
Set the general status description.

Parameters:
description - holds the general status description.
Returns:
whether the general status description is set successfully or not.

setServiceURI

public boolean setServiceURI(java.lang.String serviceURI)
Set service uri.

Parameters:
serviceURI - holds the uri of the service.
Returns:
whether the service uri is set successfully.

setServiceName

public boolean setServiceName(java.lang.String serviceName)
Set service name.

Parameters:
serviceName - holds the name of the service.
Returns:
whether the service name is set successfully.

setInstanceName

public boolean setInstanceName(java.lang.String instanceName)
Set instance name.

Parameters:
instanceName - holds the name of the instance.
Returns:
whether the instance name is set successfully.

setJobID

public boolean setJobID(java.lang.String jobID)
Set job id.

Parameters:
jobID - holds the job id.
Returns:
whether the job id is set successfully.

setResultTime

public boolean setResultTime(java.util.GregorianCalendar time)
Set time of the result.

Parameters:
time - holds the time of the result.
Returns:
whether result time is set successfully.

setGeneralMessage

public boolean setGeneralMessage(java.lang.String message)
Set the general message.

Parameters:
message - holds the general message.
Returns:
whether process message is set successfully.

setProcessStatistics

public boolean setProcessStatistics(ProcessStatistics processStatistics)
Set the process statistics.

Parameters:
processStatistics - holds the process statistics.
Returns:
whether the process statistics is set successfully.

setCurrentState

public boolean setCurrentState(java.lang.String currentState)
Set the current state.

Parameters:
currentState - holds the current state, which can be: "busy", "busyButAccepting", "idle", "idleButNotAccepting" or "noResponse".
Returns:
whether the current state is set successfully.

setAvailableDiskSpace

public boolean setAvailableDiskSpace(double availableDiskSpace)
Set the available disk space.

Parameters:
availableDiskSpace - holds the available disk space (in bytes).
Returns:
whether the available disk space is set successfully.

setAvailableMemory

public boolean setAvailableMemory(double availableMemory)
Set the available memory (in bytes).

Parameters:
availableMemory - holds the available memory.
Returns:
whether the available memory is set successfully.

setCurrentJobCount

public boolean setCurrentJobCount(int currentJobCount)
Set the current job count.

Parameters:
currentJobCount - holds the current job count.
Returns:
whether the current job count is set successfully.

setTotalJobsSoFar

public boolean setTotalJobsSoFar(int totalJobsSoFar)
Set the total jobs received so far.

Parameters:
totalJobsSoFar - holds the total jobs received so far.
Returns:
whether the total jobs so far is set successfully.

setTimeLastJobEnded

public boolean setTimeLastJobEnded(java.util.GregorianCalendar timeLastJobEnded)
Set the time last job ended.

Parameters:
timeLastJobEnded - holds the time last job ended.
Returns:
whether the time last job ended is set successfully.

setTimeLastJobTook

public boolean setTimeLastJobTook(double timeLastJobTook)
Set the time last job took.

Parameters:
timeLastJobTook - holds the time last job took (in seconds).
Returns:
whether the time last job took is set successfully.

setTimeServiceStarted

public boolean setTimeServiceStarted(java.util.GregorianCalendar timeServiceStarted)
Set the time the service started.

Parameters:
timeServiceStarted - holds the time the service started.
Returns:
whether the time the service started is set successfully.

setServiceUtilization

public boolean setServiceUtilization(double serviceUtilization)
Set the service utilization.

Parameters:
serviceUtilization - holds the service utilization ([0, 1]).
Returns:
whether the time last job took is set successfully.

setJobStatistics

public boolean setJobStatistics(JobStatistics[] jobStatistics)
Set the statistics of all jobs.

Parameters:
jobStatistics - holds an array of jobStatistics with each member corresponding to one job.
Returns:
whether the job statistics are set successfully.

setOtherResults

public boolean setOtherResults(java.lang.String[] names,
                               java.lang.String[] values,
                               java.lang.String[] descriptions)
Set all the otherResult related elements.

Parameters:
names - holds the names of all the other result information. It is required.
values - holds the values of all the other result information, empty String "" if no value for one otherResult element.
descriptions - holds the descriptions of all the other result information, empty String "" if no value for one otherResult, null for the entire array if none of the otherResult elements have descriptions.
Returns:
whether the otherResult elements are set successfully.

addOtherResult

public boolean addOtherResult(java.lang.String name,
                              java.lang.String value,
                              java.lang.String description)
Add an otherResult element.

Parameters:
name - holds the name of the otherResult element. It is required.
value - holds the value of the otherResult element, empty String "" if none.
description - holds the description of the otherResult element, empty String "" if none.
Returns:
whether the otherResult element is added successfully.

setVariableNumber

public boolean setVariableNumber(int variableNumber)
Set the variable number.

Parameters:
variableNumber - holds the number of variables
Returns:
whether the variable number is set successfully or not.

setObjectiveNumber

public boolean setObjectiveNumber(int objectiveNumber)
Set the objective number.

Parameters:
objectiveNumber - holds the number of objectives
Returns:
whether the objective number is set successfully or not.

setConstraintNumber

public boolean setConstraintNumber(int constraintNumber)
Set the constraint number.

Parameters:
constraintNumber - holds the number of constraints
Returns:
whether the constraint number is set successfully or not.

setSolutionNumber

public boolean setSolutionNumber(int solutionNumber)
set the number of solutions. This method must be called before setting other optimization solution related results. Before this method is called, the setVariableNumber(int), setObjectiveNumber(int), setConstraintNumber(int) methods have to be called first.

Parameters:
solutionNumber - holds the number of solutions to set.
Returns:
whether the solution number is set successfully.
See Also:
setVariableNumber(int), setObjectiveNumber(int), setConstraintNumber(int)

setSolution

public boolean setSolution(int solIdx,
                           OptimizationSolution solution)
Set the [i]th optimization solution, where i equals the given solution index. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
solIdx - holds the solution index to set the solution.
solution - holds the optimization solution to set.
Returns:
whether the optimization solution is set successfully or not.
See Also:
OptimizationSolution, setSolutionNumber(int)

setSolutionStatus

public boolean setSolutionStatus(int solIdx,
                                 OptimizationSolutionStatus status)
Set 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. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
solIdx - holds the solution index to set the solution status.
status - holds the optimization solution status to set.
Returns:
whether the optimization solution status is set successfully or not.
See Also:
OptimizationSolutionStatus, setSolutionNumber(int)

setSolutionStatus

public boolean setSolutionStatus(int solIdx,
                                 java.lang.String type,
                                 java.lang.String description,
                                 OptimizationSolutionSubstatus[] subStatuses)
Set 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. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
solIdx - holds the solution index to set the solution status.
type - holds the optimization solution status type to set; it is required. The solution status type can be: unbounded, globallyOptimal, locallyOptimal, optimal, bestSoFar, feasible, infeasible, stoppedByLimit, unsure, error, other
description - holds the optimization solution status description to set, null or empty string if none.
subStatus - holds an array of optimization solution subStatuses to set, null if none.
Returns:
whether the optimization solution status is set successfully or not.
See Also:
OptimizationSolutionStatus, org.optimizationservices.oscommon.datastructure.osresult.OptimizationSolutionSubStatus, setSolutionNumber(int)

setSolutionMessage

public boolean setSolutionMessage(int solIdx,
                                  java.lang.String solutionMessage)
Set the [i]th optimization solution message, where i equals the given solution index. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
solIdx - holds the solution index to set the solution message.
solutionMessage - holds the solution message to set.
Returns:
whether the optimization solution message is set successfully or not.
See Also:
setSolutionNumber(int)

setSolutionObjectiveIndex

public boolean setSolutionObjectiveIndex(int solIdx,
                                         int objectiveIdx)
Set 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. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
solIdx - holds the solution index to set the objective index.
objectiveIdx - holds the objective index to set. All the objective indexes are negative starting from -1 downward.
Returns:
whether the optimization objective index is set successfully or not.
See Also:
setSolutionNumber(int)

setPrimalVariableValues

public boolean setPrimalVariableValues(int solIdx,
                                       double[] x)
Set the [i]th optimization solution's primal variable values, where i equals the given solution index. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
solIdx - holds the solution index to set the primal variable values.
x - holds a double dense array of variable values to set; it could be null if all variables are 0.
Returns:
whether primal variable values are set successfully or not.
See Also:
setSolutionNumber(int)

setPrimalVariableStringValues

public boolean setPrimalVariableStringValues(int solIdx,
                                             java.lang.String[] x)
Set the [i]th optimization solution's primal variable string values, where i equals the given solution index. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
solIdx - holds the solution index to set the primal variable string values.
x - holds a dense string array of variable string values to set.
Returns:
whether primal variable string values are set successfully or not.
See Also:
setSolutionNumber(int)

setOtherVariableResults

public boolean setOtherVariableResults(int solIdx,
                                       OtherVariableResult[] otherVariableResults)
Set the [i]th optimization solution's other (non-standard/solver specific)variable-related results, where i equals the given solution index. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
otherVariableResults - holds 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.
Returns:
whether the other variable results are set successfully or not.
See Also:
OtherVariableResult, OtherVarResult, setSolutionNumber(int)

setObjectiveValues

public boolean setObjectiveValues(int solIdx,
                                  double[] objectiveValues)
Set 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. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
solIdx - holds the solution index to set the objective values.
objectiveValues - holds a double dense array of objective values to set. 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.
Returns:
whether objective values are set successfully or not.
See Also:
setSolutionNumber(int)

setOtherObjectiveResults

public boolean setOtherObjectiveResults(int solIdx,
                                        OtherObjectiveResult[] otherObjectiveResults)
Set the [i]th optimization solution's other (non-standard/solver specific)objective-related results, where i equals the given solution index. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
solIdx - holds the solution index to set the other objective results.
otherObjectiveResults - holds 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), an optional string value.
Returns:
whether the other objective results are set successfully or not.
See Also:
OtherObjectiveResult, OtherObjResult, setSolutionNumber(int)

setDualVariableValues

public boolean setDualVariableValues(int solIdx,
                                     double[] values)
Set the [i]th optimization solution's dual variable values, where i equals the given solution index. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
solIdx - holds the solution index to set the dual variable values.
values - holds a double dense array of variable dual values to set; it could be null if all values are 0.
Returns:
whether dual variable values are set successfully or not.
See Also:
setSolutionNumber(int)

setOtherConstraintResults

public boolean setOtherConstraintResults(int solIdx,
                                         OtherConstraintResult[] otherConstraintResults)
Set the [i]th optimization solution's other (non-standard/solver specific)constraint-related results, where i equals the given solution index. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
otherConstraintResults - holds 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 OtherConstraint for each constraint. The OtherConResult contains a constraint idx (required), and an optional string value.
Returns:
whether the other constraint results are set successfully or not.
See Also:
OtherConstraintResult, OtherConResult, setSolutionNumber(int)

setOtherOptimizationResults

public boolean setOtherOptimizationResults(int solIdx,
                                           OtherOptimizationResult[] otherOptimizationResults)
Set 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. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
otherOptimizationResults - holds 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).
Returns:
whether the other optimization results are set successfully or not.
See Also:
OtherOptimizationResult, setSolutionNumber(int)

setOSAnalysis

public boolean setOSAnalysis(OSAnalysis osAnalysis)
Set the optimization analysis. Before this method is called, the setSolutionNumber(int) method has to be called first.

Parameters:
osAnalysis - holds 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, setSolutionNumber(int)

main

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

Parameters:
argv - command line arguments.