XPRDModel
- java.lang.Object
-
- com.dashoptimization.XPRDModel
-
public class XPRDModel extends java.lang.ObjectA model loaded onto a remote instance
-
-
Field Summary
Modifier and Type Field and Description java.lang.StringexecParamsExecution parameters.static intF_APPENDCode for opening the file in append mode (output stream).static intF_ERRORCode for error stream.static intF_INPUTCode for input stream.static intF_LINBUFCode for enabling line buffering (output stream).static intF_OUTPUTCode for output stream.static intRT_BREAKExecution status: execution interrupted on a breakpoint.static intRT_DETACHEDExecution status: remote instance detached itself.static intRT_ERRORExecution status: run time error.static intRT_FDCLOSEDExecution status: connection with server lost.static intRT_IOERRExecution status: I/O error.static intRT_LICERRExecution status: licensing error.static intRT_MATHERRExecution status: mathematical error.static intRT_NIFCTExecution status: execution interrupted during a native function call.static intRT_NOTINITExecution status: model is not initialised (unloaded?).static intRT_NULLExecution status: NULL reference error.static intRT_OKExecution status: normal termination.static intRT_RUNNINGExecution status: model is running.static intRT_STOPExecution status: execution interrupted.
-
Method Summary
Modifier and Type Method and Description voidchangeStatus(XPRDSlot slot, int status)Called when execution finishes.voidclearExecParams()Clear the execution parameters string.intgetExecStatus()Get execution status.intgetExitCode()Get the result of the execution of the model.XPRDMoselgetMosel()Get the Mosel instance on which this model is loaded.intgetNumber()Get model number.intgetRemoteId()Get model remote ID.intgetResult()Get the result of the execution of the model.booleanisLoaded()Check whether this model is loaded onto an instance.voidreset()Reset model.voidresetExecParam(java.lang.String name)Remove the value associated to an execution parameter.voidrun()Run the model.voidsendEvent(int cls, double val)Send an event to the model during its execution.voidsetControl(java.lang.String name, java.lang.String val)Set a Mosel instance control parameter for the model.voidsetDefaultStream(int wmd, java.lang.String fileName)Set default input/output streams.voidsetExecParam(java.lang.String name, boolean value)Add or update the value associated to an execution parameter.voidsetExecParam(java.lang.String name, double value)Add or update the value associated to an execution parameter.voidsetExecParam(java.lang.String name, int value)Add or update the value associated to an execution parameter.voidsetExecParam(java.lang.String name, java.lang.String value)Add or update the value associated to an execution parameter.voidstop()Interrupt execution.
-
-
-
Field Detail
-
F_INPUT
public static final int F_INPUT
Code for input stream.
-
F_OUTPUT
public static final int F_OUTPUT
Code for output stream.
-
F_ERROR
public static final int F_ERROR
Code for error stream.
-
F_LINBUF
public static final int F_LINBUF
Code for enabling line buffering (output stream).
-
F_APPEND
public static final int F_APPEND
Code for opening the file in append mode (output stream).
-
RT_OK
public static final int RT_OK
Execution status: normal termination.- See Also:
-
getExecStatus(), Constant Field Values
-
RT_MATHERR
public static final int RT_MATHERR
Execution status: mathematical error. Execution aborted after an error occurred during evaluation of an expression (for instance division by zero).- See Also:
-
getExecStatus(), Constant Field Values
-
RT_ERROR
public static final int RT_ERROR
Execution status: run time error.- See Also:
-
getExecStatus(), Constant Field Values
-
RT_IOERR
public static final int RT_IOERR
Execution status: I/O error. An error occurred when performing a stream operation (like trying to open a file that does not exist).- See Also:
-
getExecStatus(), Constant Field Values
-
RT_BREAK
public static final int RT_BREAK
Execution status: execution interrupted on a breakpoint. Execution has been interrupted because of a breakpoint.- See Also:
-
getExecStatus(), Constant Field Values
-
RT_NIFCT
public static final int RT_NIFCT
Execution status: execution interrupted during a native function call. Execution has been interrupted when a native function was running.- See Also:
-
getExecStatus(), Constant Field Values
-
RT_NULL
public static final int RT_NULL
Execution status: NULL reference error. The model is trying to access an object that has not been initialised.- See Also:
-
getExecStatus(), Constant Field Values
-
RT_LICERR
public static final int RT_LICERR
Execution status: licensing error. Execution has been aborted because no Xpress license was available.- See Also:
-
getExecStatus(), Constant Field Values
-
RT_STOP
public static final int RT_STOP
Execution status: execution interrupted. Execution has been explicitly interrupted by a call tostop().- See Also:
-
getExecStatus(), Constant Field Values
-
RT_DETACHED
public static final int RT_DETACHED
Execution status: remote instance detached itself. The remote model now runs independently. Connection has been closed.- See Also:
-
getExecStatus(), Constant Field Values
-
RT_FDCLOSED
public static final int RT_FDCLOSED
Execution status: connection with server lost. The network connection to the remote instance has been lost.- See Also:
-
getExecStatus(), Constant Field Values
-
RT_NOTINIT
public static final int RT_NOTINIT
Execution status: model is not initialised (unloaded?).- See Also:
-
getExecStatus(), Constant Field Values
-
RT_RUNNING
public static final int RT_RUNNING
Execution status: model is running.- See Also:
-
getExecStatus(), Constant Field Values
-
execParams
public java.lang.String execParams
Execution parameters. This string is used to initialise model parameters when execution of the model starts. It consists in a list of assignments of the formnma=valueseparated by commas. The routinessetExecParam(java.lang.String, int)can be used to help building this string.
-
-
Method Detail
-
isLoaded
public boolean isLoaded()
Check whether this model is loaded onto an instance.- Returns:
-
trueif the model is loaded onto an instance
-
setExecParam
public void setExecParam(java.lang.String name, int value)Add or update the value associated to an execution parameter. This routine adds or replace the assignmentname=valuein the execution parameter string (execParams).- Parameters:
-
name- parameter name -
value- parameter value
-
setExecParam
public void setExecParam(java.lang.String name, double value)Add or update the value associated to an execution parameter. This routine adds or replace the assignmentname=valuein the execution parameter string (execParams).- Parameters:
-
name- parameter name -
value- parameter value
-
setExecParam
public void setExecParam(java.lang.String name, boolean value)Add or update the value associated to an execution parameter. This routine adds or replace the assignmentname=valuein the execution parameter string (execParams).- Parameters:
-
name- parameter name -
value- parameter value
-
setExecParam
public void setExecParam(java.lang.String name, java.lang.String value)Add or update the value associated to an execution parameter. This routine adds or replace the assignmentname=valuein the execution parameter string (execParams).- Parameters:
-
name- parameter name -
value- parameter value
-
resetExecParam
public void resetExecParam(java.lang.String name)
Remove the value associated to an execution parameter. This routine removes the assignmentname=valuefrom the execution parameters string (execParams). No operation is performed if the parameter does not appear in the string.- Parameters:
-
name- parameter name
-
clearExecParams
public void clearExecParams()
Clear the execution parameters string.
-
run
public void run() throws java.io.IOExceptionRun the model. This method starts the execution of the model. The model parameters are initialised usingexecParams. Execution may be interrupted by callingstop(). After this function returns, execution status may be retrieved usinggetExecStatus()and result can be obtained withgetExitCode()( i.e. the parameter value of the Moselexitprocedure). The object is notified when the execution terminates.- Throws:
-
java.io.IOException- in case of IO error
-
changeStatus
public void changeStatus(XPRDSlot slot, int status)Called when execution finishes. This method is for internal use only.
-
stop
public void stop()
Interrupt execution.
-
reset
public void reset()
Reset model. Restore the state of the model before it was executed: all data is released, problems are cleared.
-
getNumber
public int getNumber()
Get model number. An order number is assigned to the model when it is loaded into memory.- Returns:
- model number
-
getRemoteId
public int getRemoteId()
Get model remote ID. Model number on the remote instance.- Returns:
- remote model number
-
getMosel
public XPRDMosel getMosel()
Get the Mosel instance on which this model is loaded.- Returns:
-
Mosel instance associated to this model or
nullif the model is not loaded.
-
getResult
public int getResult()
Get the result of the execution of the model. This method returns the result of the execution of a model ( i.e. the parameter value of theexitprocedure) with methodrun().- Returns:
-
Result as an integer. If procedure
exithas not been called in the model, the default value of 0 is returned.
-
getExitCode
public int getExitCode()
Get the result of the execution of the model. This method returns the result of the execution of a model ( i.e. the parameter value of theexitprocedure) with methodrun().- Returns:
-
Result as an integer. If procedure
exithas not been called in the model, the default value of 0 is returned.
-
getExecStatus
public int getExecStatus()
Get execution status. The execution status indicates whether the execution terminated normally.- Returns:
-
Execution status as an integer:
RT_OKnormal terminationRT_RUNNINGstill runningRT_FDCLOSEDconnection to server lostRT_STOPinterruptedRT_IOERRI/O errorRT_MATHERRmathematical errorRT_ERRORgeneral run time error- Other values indicate an internal error
-
setDefaultStream
public void setDefaultStream(int wmd, java.lang.String fileName) throws java.io.IOExceptionSet default input/output streams. This method defines the default streams that are opened when execution of the model starts. Using an empty string as the file name implies resetting to the corresponding original default stream (defined usingXPRDMosel.setDefaultStream(int, java.lang.String)).- Parameters:
-
wmd- stream to be set: -
fileName- extended file name to be used for the stream. - Throws:
-
java.io.IOException- If the stream cannot be set. - See Also:
-
XPRDMosel.setDefaultStream(int, java.lang.String)
-
setControl
public void setControl(java.lang.String name, java.lang.String val) throws java.io.IOExceptionSet a Mosel instance control parameter for the model.- Parameters:
-
name- name of the parameter. -
val- value. - Throws:
-
java.io.IOException- If the control cannot be set (invalid name or value).
-
sendEvent
public void sendEvent(int cls, double val)Send an event to the model during its execution. This function has no effect if the model cannot receive events ( e.g. it is not running or does not listen to events)- Parameters:
-
cls- event class: it must be a positive value greater than1 -
val- event value as a double (real)
-
-
