In this section the example project is extended with the addition of a custom execution mode.
The new execution mode is the same as INSIGHT_MODE_LOAD, except that it is invoked from a user interface button.
- At the top of foliodata.mos, add a line so that it now reads:
model "Portfolio optimization with LP"
! Mandatory for Xpress Insight
uses "mminsight"
! Use Xpress-Optimizer
uses "mmxprs"
!@insight.execmodes.RELOADBASEDATA.clearinput true
...
The new
!@insight.execmodes.RELOADBASEDATA.clearinput true statement declares the new execution mode -
RELOADBASEDATA - and assigns its
clearinput attribute to be the boolean
true, which states that data should be loaded directly from the underlying model, rather than the
Xpress Insight server.
- Change the case statement that drives the mode-specific logic so that it now reads:
case insightgetmode of
INSIGHT_MODE_LOAD: do
datainput
exit(0)
end-do
INSIGHT_MODE_RUN:
insightpopulate
"RELOADBASEDATA": do
datainput
exit(0)
end-do
else
datainput
end-case
Note the addition of a
RELOADBASEDATA branch that behaves exactly like the
LOAD branch. This new mode is invoked via the following user interface change which ties its use to a user interface button, rather than a drop-down menu on the shelf.
- In foliodata.vdl, add two lines underneath <vdl-execute-button caption="Run scenario"></vdl-execute-button> so that it now reads:
...
<vdl-execute-button caption="Run scenario"></vdl-execute-button>
<span> </span>
<vdl-execute-button caption="RELOAD BASE DATA" mode="RELOADBASEDATA"></vdl-execute-button>
...
A
<span> element adds some clearance between the original execute button captioned
Run scenario, and a new execute button captioned
Reload Base Data. Note how its
mode attribute has been set to
RELOADBASEDATA. When clicked, the
RELOADBASEDATA branch in
foliodata.mos is executed.
- Republish your app to Xpress Insight, (re)load and run Scenario 1. Edit the ROI field for a number of share types using the drop-down box, and click Run Scenario.
Depending on your choices, a new result appears.
- Click the Reload Base Data button and click Load Data in the subsequent Loading Input Data dialog.
The scenario loads data directly from the model, resetting all input data.
- Click Run Scenario one last time.
The scenario executes against the original data, producing the expected result of
14.07.
This short exercise has illustrated how to control model flow logic with a simple custom execution mode. Execution modes are capable of far more complex processing and by associating a custom execution mode with an existing execution service, you can also route
Xpress Insight jobs to an appropriately provisioned server. These use cases are covered in more detail elsewhere in the
Xpress Insight documentation.
© 2001-2020 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.