XPRDModel
- java.lang.Object
-
- com.dashoptimization.XPRDModel
-
public class XPRDModel extends java.lang.Object
A model loaded onto a remote instance
-
-
Field Summary
Modifier and Type Field and Description java.lang.String
execParams
Execution parameters.static int
F_APPEND
Code for opening the file in append mode (output stream).static int
F_ERROR
Code for error stream.static int
F_INPUT
Code for input stream.static int
F_LINBUF
Code for enabling line buffering (output stream).static int
F_OUTPUT
Code for output stream.static int
RT_DETACHED
Execution status: remote instance detached itself.static int
RT_ERROR
Execution status: run time error.static int
RT_FDCLOSED
Execution status: connection with server lost.static int
RT_IOERR
Execution status: I/O error.static int
RT_LICERR
Execution status: licensing error.static int
RT_MATHERR
Execution status: mathematical error.static int
RT_NIFCT
Execution status: execution interrupted during a native function call.static int
RT_NOTINIT
Execution status: model is not initialised (unloaded?).static int
RT_NULL
Execution status: NULL reference error.static int
RT_OK
Execution status: normal termination.static int
RT_RUNNING
Execution status: model is running.static int
RT_STOP
Execution status: execution interrupted.
-
Method Summary
Modifier and Type Method and Description void
changeStatus(XPRDSlot slot, int status)
Called when execution finishes.void
clearExecParams()
Clear the execution parameters string.int
getExecStatus()
Get execution status.int
getExitCode()
Get the result of the execution of the model.XPRDMosel
getMosel()
Get the Mosel instance on which this model is loaded.int
getNumber()
Get model number.int
getRemoteId()
Get model remote ID.int
getResult()
Get the result of the execution of the model.boolean
isLoaded()
Check whether this model is loaded onto an instance.void
reset()
Reset model.void
resetExecParam(java.lang.String name)
Remove the value associated to an execution parameter.void
run()
Run the model.void
sendEvent(int cls, double val)
Send an event to the model during its execution.void
setControl(java.lang.String name, java.lang.String val)
Set a Mosel instance control parameter for the model.void
setDefaultStream(int wmd, java.lang.String fileName)
Set default input/output streams.void
setExecParam(java.lang.String name, boolean value)
Add or update the value associated to an execution parameter.void
setExecParam(java.lang.String name, double value)
Add or update the value associated to an execution parameter.void
setExecParam(java.lang.String name, int value)
Add or update the value associated to an execution parameter.void
setExecParam(java.lang.String name, java.lang.String value)
Add or update the value associated to an execution parameter.void
stop()
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_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=value
separated 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:
-
true
if 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=value
in 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=value
in 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=value
in 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=value
in 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=value
from 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.IOException
Run 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 Moselexit
procedure). 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
null
if 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 theexit
procedure) with methodrun()
.- Returns:
-
Result as an integer. If procedure
exit
has 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 theexit
procedure) with methodrun()
.- Returns:
-
Result as an integer. If procedure
exit
has 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_OK
normal terminationRT_RUNNING
still runningRT_FDCLOSED
connection to server lostRT_STOP
interruptedRT_IOERR
I/O errorRT_MATHERR
mathematical errorRT_ERROR
general run time error- Other values indicate an internal error
-
setDefaultStream
public void setDefaultStream(int wmd, java.lang.String fileName) throws java.io.IOException
Set 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.IOException
Set 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)
-
-
© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.