Inter-Scenario Data Access
You can also initialize your data structures with values from external scenarios using the mminsight.scenariodata I/O driver with a standard Mosel initializations-from block. For example, the following model initializes the array "Distances" from an array called "CityDrivingDistances" in a scenario "USDrivingDistances" in an app named "DrivingDistancesModel"
model RoutePlanner
uses "mmxprs" ! Load the Xpress-Optimizer
uses "mminsight" ! Load the Insight interface
public declarations
Cities: set of string
Distances: array(Cities,Cities) of real
TrafficLevels: array(Cities,Cities) of real
routetaken: array(Cities,Cities) of mpvar
end-declarations
! Procedure to build and solve optimization problem
procedure runproblem
! Populate 'Distances' array
if insightgetmode <> INSIGHT_MODE_NONE then
! Populate 'Distances' array from the remote scenario
initializations from "mminsight.scenariodata:/DrivingDistancesModel/USDrivingDistances"
Distances as "CityDrivingDistances"
end-initializations
else
! Model is running outside of Insight, so populate driving distances from local file
initializations from "/Users/me/myfiles/distances.dat"
Distances
end-initializations
end-if
! Perform optimization
buildproblem
optimizeproblem
end-procedure
case insightgetmode of
INSIGHT_MODE_LOAD: do
loaddata
end-do
INSIGHT_MODE_RUN: do
insightpopulate
runproblem
end-do
INSIGHT_MODE_NONE: do
loaddata
runproblem
end-do
else
writeln("Unknown execution mode")
end-case
end-model For clarity, the implementation of the loaddata, buildproblem and optimizeproblem procedures have been omitted from the example.
