|
|
|
| Risk Solver Engine makes
available a hierarchy of objects for describing Monte
Carlo simulation problems, pictured to the right. This object
model is a simplified subset of the object hierarchy offered by
Frontline’s Solver Platform SDK,
which is used to build custom applications in C/C++, Visual
Basic, VB.NET, Java or MATLAB.
The Problem object represents the whole
problem, and the Model object represents the internal
structure of the model, which in Risk Solver Engine is defined
by your formulas on the spreadsheet. The Solver object
represents the Monte Carlo process -- you call its Simulate
method to perform a simulation. The Engine object
represents the Monte Carlo simulation engine -- its parameters
include the sampling method, for example. A Variable
object represents a range of one or more contiguous cells that
contains uncertain variables, while a Function object
represents a range of cells that contains uncertain functions.
You may have a collection of Variable objects, and a collection
of Function objects in one Problem. |

Click on Risk Solver object model
diagram to see it full size. |
Using Risk Solver Engine Objects
You use the Risk Solver Engine object model by
first creating an instance of a Problem, and initializing
it with the simulation model defined in your Excel workbook.
Once you have an initialized Problem object, you can for example:
 | Set Solver and Engine parameters such as the
number of trials per simulation, the sampling method, and the
random seed. |
 | Perform a simulation, using either the
high-speed PSI Interpreter or the Excel Interpreter for the
trials. |
 | Get results of the simulation, by accessing
properties of the Variable and Function objects, and of their
child Statistics objects. |
Below is a simple example that could be linked to
a command button on the worksheet:
Private Sub
CommandButton3_Click()
Dim prob As New
Problem
prob.Init ActiveWorkbook
prob.Solver.NumTrials = 5000
prob.Engine.Params("SamplingMethod") = 2
prob.Solver.Simulate
For i = 0 To
prob.Functions.Count – 1
MsgBox prob.Functions(i).Statistics.Mean(0)
Next i
Set prob =
Nothing
End Sub
The first two lines create an instance of a
Problem, and initialize it with the simulation model defined in your
Excel workbook. The next two lines set the number of trials in the
simulation to 5000, and the sampling method to Latin Hypercube. The
fifth line performs a simulation.
The for-loop in the next three lines will step
through the Function objects – assuming, for simplicity here,
that each Function object represents just one cell – and display the
Mean property of the child Statistics object (the mean or
average value of the function across all trials) for each one.
Back to Risk Solver Engine Product
Overview
|