Using Custom Execution Modes from the Model
Within a model you can call insightgetmode to get the execution mode.
You can use this in a switch statement to determine which branch of code to run. As a minimum you must check for the LOAD and RUN execution modes using the constants INSIGHT_MODE_LOAD and INSIGHT_MODE_RUN respectively.
In the example below there are two custom execution modes:
model mymodel
uses "mminsight"
uses "mmxprs"
!@insight.execmodes.LOAD_ALL.preferredservice=BACKGROUND_SERVICE
(!@insight.execmodes.LOAD_ALL.descr=Long running background task to load complete data set from
external datasource !)
!@insight.execmodes.LOAD_ALL.clearinput=true
!@insight.execmodes.EVALUATE_SEGMENTS.threads=1
!@insight.execmodes.EVALUATE_SEGMENTS.preferredservice=FAST_SERVICE
(!@insight.execmodes.EVALUATE_SEG MENTS.descr=Quick job to evaluate segments. Does not perform any
optimization !)
!@mc.flush
forward procedure datainput
case insightgetmode of
INSIGHT_MODE_LOAD: do
datainput
exit(0)
end-do
"LOAD_ALL": do
writeln("load all data from external data source")
exit(0)
end-do
"EVALUATE_SEGMENTS": do
writeln("evaluate segments")
end-do
INSIGHT_MODE_RUN: do
insightpopulate
end-do
else
datainput
end-case
! load input data
procedure datainput
writeln("loading data")
end-procedure
! create model constraints
! optimize
! post-process results
end-model
