...

RISKOpt.PDF

by user

on
Category: Documents
8

views

Report

Comments

Transcript

RISKOpt.PDF
Guide to
RISKOptimizer
Simulation Optimization for
Microsoft Excel
Windows Version
Release 1.0
October, 2004
Palisade Corporation
31 Decker Road
Newfield, NY USA 14867
(607) 277-8000
(607) 277-8001 (fax)
http://www.palisade.com (website)
[email protected] (e-mail)
Copyright Notice
Copyright © 2004, Palisade Corporation.
Trademark Acknowledgments
Microsoft, Excel and Windows are registered trademarks of Microsoft,
Inc.
Lotus and 1-2-3 are registered trademarks of Lotus Development
Corporation
IBM is a registered trademark of International Business Machines, Inc.
Palisade, RISKOptimizer, TopRank, BestFit and RISKview are
registered trademarks of Palisade Corporation.
RISK is a trademark of Parker Brothers, Division of Tonka
Corporation and is used under license.
ii
Table Of Contents
Chapter 1: Introduction
1
Introduction ................................................................................................. 3
Why RISKOptimizer?.................................................................................... 3
Before You Begin .......................................................................................... 7
What the Package Includes ......................................................................... 7
Registration ................................................................................................... 7
Working with your Operating Environment............................................ 8
If You Need Help ......................................................................................... 8
RISKOptimizer System Requirements ...................................................... 10
Installation Instructions .......................................................................... 11
General Installation Instructions .............................................................. 11
The DecisionTools Suite ............................................................................ 12
Setting Up the RISKOptimizer Icons or Shortcuts................................... 13
Other RISKOptimizer Information .......................................................... 14
Learning RISKOptimizer ............................................................................ 14
Chapter 2: Background
15
What Is RISKOptimizer?.......................................................................... 17
How does RISKOptimizer work? .............................................................. 18
What Is Optimization?............................................................................... 19
Why Build Excel Models? ......................................................................... 20
Modeling Uncertainty in Excel Models................................................... 21
Using Simulation to Account for Uncertainty........................................ 21
Why Use RISKOptimizer? .......................................................................... 22
Traditional Optimization vs. Simulation Optimization ................... 25
Traditional Spreadsheet Optimization Process...................................... 25
Simulation Optimization Process............................................................. 26
Each Step of an Optimization with RISKOptimizer................................ 28
Chapter 3: RISKOptimizer: Step-by-Step
33
Introduction ............................................................................................... 35
Chapter 1: Introduction
iii
The RISKOptimizer Tour........................................................................ 37
Starting RISKOptimizer .............................................................................. 37
Describing Uncertainty in the Model....................................................... 39
The RISKOptimizer Settings Dialog .......................................................... 41
Selecting the Statistic for the Target Cell................................................. 41
Adding Adjustable Cells ........................................................................... 42
Constraints .................................................................................................. 45
Other RISKOptimizer Options ................................................................... 49
Running the Optimization ........................................................................ 51
Chapter 4: Example Applications
57
Introduction ............................................................................................... 59
Budget Allocation ..................................................................................... 61
Capacity Planning..................................................................................... 63
Class Scheduler ......................................................................................... 65
Hedging with Futures .............................................................................. 67
Job Shop Scheduling................................................................................ 69
Portfolio Balancing ................................................................................... 71
Portfolio Mix.............................................................................................. 75
Portfolio Risk............................................................................................. 77
Salesman Problem .................................................................................... 79
Yield Management.................................................................................... 81
Chapter 5: Complete Reference
83
RISKOptimizer Settings Dialog ............................................................. 87
Find the ........................................................................................................ 88
Of the............................................................................................................ 88
By Adjusting the Cells ............................................................................... 90
The Adjustable Cells Dialog...................................................................... 91
Solving Methods......................................................................................... 92
Adjust the Cells......................................................................................... 100
Use The Options ....................................................................................... 102
Operators................................................................................................... 104
iv
Subject to The Constraints....................................................................... 106
Options ...................................................................................................... 112
Macros ....................................................................................................... 118
Sampling.................................................................................................... 120
RISKOptimizer Toolbar ......................................................................... 123
RISKOptimizer Watcher ........................................................................ 127
RISKOptimizer Watcher Toolbar............................................................. 128
RISKOptimizer Watcher - Menu Items ............................................... 135
Population Menu...................................................................................... 135
Create Menu.............................................................................................. 136
Window Menu.......................................................................................... 136
Chapter 6: Optimization
137
Introduction ............................................................................................. 139
Optimization Methods............................................................................. 139
About Hill Climbing Algorithms ........................................................... 141
Excel Solver.............................................................................................. 145
Types of Problems.................................................................................... 146
Chapter 7: Genetic Algorithms
151
Introduction ............................................................................................. 153
History ...................................................................................................... 153
Evolution Theory...................................................................................... 153
A Biological Example............................................................................... 156
A Digital Example .................................................................................... 157
Chapter 8: Simulation and Risk Analysis
161
Introduction ............................................................................................. 163
What is Risk? ........................................................................................... 163
Characteristics of Risk ............................................................................. 164
The Need for Risk Analysis .................................................................... 165
Assessing and Quantifying Risk ............................................................ 166
Describing Risk with a Probability Distribution .................................. 167
Chapter 1: Introduction
v
Modeling Uncertainty in RISKOptimizer .......................................... 169
Variables .................................................................................................... 169
Analyzing a Model with Simulation................................................... 171
Simulation ................................................................................................. 171
How Simulation Works ........................................................................... 172
Chapter 9: Probability Distribution Functions
173
Introduction ............................................................................................. 175
Table of Available Functions ............................................................... 183
Reference: Distribution Functions ...................................................... 191
RiskBeta ..................................................................................................... 191
RiskBetaGeneral ....................................................................................... 191
RiskBetaGeneralAlt .................................................................................. 192
RiskBetaSubj.............................................................................................. 192
RiskBinomial ............................................................................................. 193
RiskChiSq .................................................................................................. 193
RiskCumul................................................................................................. 194
RiskCumulD.............................................................................................. 195
RiskDiscrete............................................................................................... 196
RiskDUniform........................................................................................... 196
RiskErf........................................................................................................ 197
RiskErlang ................................................................................................. 197
RiskExpon.................................................................................................. 197
RiskExponAlt ............................................................................................ 198
RiskExtValue............................................................................................. 198
RiskExtValueAlt ....................................................................................... 198
RiskGamma ............................................................................................... 199
RiskGammaAlt ......................................................................................... 199
RiskGeneral ............................................................................................... 200
RiskGeomet ............................................................................................... 201
RiskHistogrm ............................................................................................ 202
RiskHypergeo ........................................................................................... 203
RiskIntUniform ......................................................................................... 203
RiskInvgauss ............................................................................................. 204
RiskInvgaussAlt........................................................................................ 204
RiskLogistic ............................................................................................... 204
RiskLogisticAlt.......................................................................................... 205
RiskLogLogistic ........................................................................................ 205
RiskLogLogisticAlt................................................................................... 205
RiskLognorm............................................................................................. 206
RiskLognormAlt ....................................................................................... 206
vi
RiskLognorm2........................................................................................... 207
RiskNegbin................................................................................................ 207
RiskNormal ............................................................................................... 208
RiskNormalAlt.......................................................................................... 208
RiskPareto ................................................................................................. 208
RiskParetoAlt ............................................................................................ 209
RiskPareto2 ............................................................................................... 209
RiskPareto2Alt .......................................................................................... 209
RiskPearson5............................................................................................. 210
RiskPearson5Alt ....................................................................................... 210
RiskPearson6............................................................................................. 210
RiskPert...................................................................................................... 211
RiskPertAlt ................................................................................................ 211
RiskPoisson ............................................................................................... 211
RiskRayleigh ............................................................................................. 212
RiskRayleighAlt........................................................................................ 212
RiskSimtable.............................................................................................. 212
RiskStudent ............................................................................................... 213
RiskTriang ................................................................................................. 213
RiskTriangAlt............................................................................................ 213
RiskTrigen ................................................................................................. 214
RiskUniform.............................................................................................. 214
RiskUniformAlt ........................................................................................ 215
RiskWeibull............................................................................................... 215
RiskWeibullAlt ......................................................................................... 215
Reference: Distribution Property Functions...................................... 217
RiskCollect................................................................................................. 217
RiskCorrmat.............................................................................................. 218
RiskDepC................................................................................................... 220
RiskFit ........................................................................................................ 222
RiskIndepC................................................................................................ 223
RiskLock .................................................................................................... 224
RiskName .................................................................................................. 224
RiskShift..................................................................................................... 224
RiskTruncate ............................................................................................. 225
Reference: Output Functions................................................................ 227
RiskOutput ................................................................................................ 228
Reference: Statistics Functions............................................................. 229
RiskData .................................................................................................... 230
RiskKurtosis .............................................................................................. 231
RiskMax ..................................................................................................... 231
RiskMean................................................................................................... 231
Chapter 1: Introduction
vii
RiskMin...................................................................................................... 232
RiskMode................................................................................................... 232
RiskPercentile............................................................................................ 232
RiskRange.................................................................................................. 233
RiskSkewness............................................................................................ 233
RiskStdDev................................................................................................ 233
RiskTarget.................................................................................................. 234
RiskVariance ............................................................................................. 234
Reference: Supplemental Functions.................................................... 235
RiskCurrentIter ......................................................................................... 235
RiskCurrentSim ........................................................................................ 235
Chapter 11: RISKOptimizer Extras
237
Adding Constraints ................................................................................ 239
Range Constraints .................................................................................... 239
Hard Constraints - customized............................................................... 240
Iteration vs. Simulation Constraints ...................................................... 241
Soft Constraints......................................................................................... 241
Multiple Goal Problems........................................................................... 246
Improving Speed..................................................................................... 249
How RISKOptimizer's Optimization is Implemented..................... 251
Appendix A: Controlling RISKOptimizer with VBA
255
Overview .................................................................................................. 259
The Organization of this Chapter........................................................... 259
Example Application ............................................................................... 259
Using the VBA Functions ........................................................................ 259
VBA and RISKOptimizer Settings ....................................................... 261
Public Variable Types Used for RISKOptimizer Settings..................... 261
Defining RISKOptimizer Settings Using Code ...................................... 262
Using VBA to Control an Optimization ............................................. 265
VBA Reference - Public RISKOptimizer Variables .......................... 267
Description of EvSettingsType ............................................................... 267
Variables in EVSettingsType ............................................................... 269
WB .............................................................................................................. 269
CellToOptimize......................................................................................... 269
viii
OutputFunction ........................................................................................ 269
OutputFunctionParameter ...................................................................... 270
OptimizationGoal..................................................................................... 270
TargetValue............................................................................................... 270
NumAdjustableGroups ........................................................................... 270
AdjustableGroups().................................................................................. 271
NumConstraints ....................................................................................... 271
Constraints().............................................................................................. 271
StopOnTrials ............................................................................................. 271
StopTrials................................................................................................... 272
StopOnMinutes......................................................................................... 272
StopMinutes .............................................................................................. 272
StopOnChange.......................................................................................... 273
StopChangeTrials ..................................................................................... 273
StopChangeMagnitude............................................................................ 273
StopChangeIsPercent............................................................................... 274
StopOnFormula ........................................................................................ 274
StopFormula.............................................................................................. 274
PopulationSize .......................................................................................... 274
UpdateDisplay.......................................................................................... 274
GraphProgress .......................................................................................... 275
PauseOnError ........................................................................................... 275
GenerateLog.............................................................................................. 275
RandomlyGenerateSeed.......................................................................... 275
SeedValue.................................................................................................. 275
SimStopMode............................................................................................ 276
SimMaxIters .............................................................................................. 276
SimConvergenceTolerance...................................................................... 276
SimsUseSameSeed.................................................................................... 277
SamplingType........................................................................................... 277
StandardRecalc ......................................................................................... 277
RunStartMacro.......................................................................................... 278
StartMacro................................................................................................. 278
RunBeforeSimMacro................................................................................ 278
BeforeSimMacro ....................................................................................... 278
RunBeforeRecalcMacro ........................................................................... 279
BeforeRecalcMacro................................................................................... 279
RunAfterRecalcMacro ............................................................................. 279
AfterRecalcMacro..................................................................................... 279
RunAfterSimMacro .................................................................................. 280
AfterSimMacro ......................................................................................... 280
RunAfterStorageMacro ........................................................................... 280
AfterStorageMacro................................................................................... 280
RunFinishMacro ....................................................................................... 281
FinishMacro .............................................................................................. 281
Chapter 1: Introduction
ix
EvAdjustableGroupType ...................................................................... 282
Listing of EvAdjustableGroupType....................................................... 282
Variables in EvAdjustableGroupType ............................................... 282
Description ................................................................................................ 282
SolvingMethod ......................................................................................... 282
CrossoverRate ........................................................................................... 283
MutationRate ............................................................................................ 283
NumTimeBlocks ....................................................................................... 283
ConstRange ............................................................................................... 283
NumInputRanges ..................................................................................... 284
InputRanges()............................................................................................ 284
EvInputRangeType................................................................................. 285
Listing of EvInputRangeType................................................................. 285
Variables in EvInputRangeType ......................................................... 285
Reference ................................................................................................... 285
MinValue ................................................................................................... 285
MaxValue .................................................................................................. 286
ExcludeMinValue ..................................................................................... 286
ExcludeMaxValue .................................................................................... 286
IsInteger ..................................................................................................... 286
EvConstraintType ................................................................................... 287
Listing of EvConstraintType................................................................... 287
Variables in EvConstraintType............................................................ 287
ConstraintType ......................................................................................... 287
EntryMode................................................................................................. 288
Formula...................................................................................................... 288
PenaltyFunction........................................................................................ 289
RiskOptEvalTime ..................................................................................... 289
Description ................................................................................................ 289
Status Variables Available During an Optimization....................... 291
VBA Reference - Public RISKOptimizer Functions.......................... 293
EvCopyAdjustableGroup........................................................................ 293
EvCopySettings ........................................................................................ 294
EvError....................................................................................................... 294
EvGetListOfSolvingMethods .................................................................. 295
EvOptimize ............................................................................................... 295
EvReadSettings ......................................................................................... 298
EvReadSettingsDefaults .......................................................................... 298
EvReadSettingsFromSummary .............................................................. 299
x
EvRestoreValuesFromSummary ............................................................ 300
EvShowSettingsDlg.................................................................................. 301
EvWriteSettings ........................................................................................ 301
Appendix B: Troubleshooting / Q&A
303
Troubleshooting / Q&A......................................................................... 305
Appendix C: Additional Resources
307
Books.......................................................................................................... 309
Articles....................................................................................................... 310
Magazines & Newsletters ....................................................................... 311
Introduction to Simulation...................................................................... 312
Technical References to Simulation and Monte Carlo Techniques.... 313
Technical References to Latin Hypercube Sampling Techniques ...... 313
Examples and Case Studies Using Simulation..................................... 314
Glossary
315
Index
325
Chapter 1: Introduction
xi
xii
Chapter 1: Introduction
Introduction ................................................................................................. 3
Why RISKOptimizer?.................................................................................... 3
Traditional Optimization Problems................................................... 3
Optimization of Uncertain Models.................................................... 4
Modeling Uncertainty ......................................................................... 4
Optimization Using Simulation ......................................................... 5
Simulation Results ............................................................................... 5
Custom Applications Using RISKOptimizer.................................... 6
Applications of Simulation Optimization Using RISKOptimizer . 6
Before You Begin .......................................................................................... 7
What the Package Includes ......................................................................... 7
Registration ................................................................................................... 7
Working with your Operating Environment............................................ 8
If You Need Help ......................................................................................... 8
Before Calling ....................................................................................... 8
Contacting Palisade ............................................................................. 9
Student Versions .................................................................................. 9
RISKOptimizer System Requirements ...................................................... 10
Installation Instructions .......................................................................... 11
General Installation Instructions .............................................................. 11
Authorizing Your Copy of RISKOptimizer.................................... 11
Removing RISKOptimizer from Your Computer .......................... 12
The DecisionTools Suite ............................................................................ 12
The DecisionTools Toolbar ............................................................... 12
Setting Up the RISKOptimizer Icons or Shortcuts................................... 13
Macro Security Warning Message on Startup........................................ 13
Other RISKOptimizer Information .......................................................... 14
RISKOptimizer Read Me................................................................... 14
RISKOptimizer Tutorial .................................................................... 14
RISKOptimizer Watcher ................................................................... 14
Learning RISKOptimizer ............................................................................ 14
Chapter 1: Introduction
1
Chapter 1: Introduction
2
Introduction
RISKOptimizer combines simulation and optimization to allow the
optimization of models that contain uncertain factors. RISKOptimizer,
through the application of powerful genetic algorithm-based
optimization techniques and Monte Carlo simulation, can find
optimal solutions to problems which are "unsolvable" for standard
linear and non-linear optimizers. RISKOptimizer combines the
simulation technology of @RISK, Palisade’s risk analysis add-in, and
Evolver, Palisade’s genetic algorithm – based solver. Users familiar
with @RISK and either Evolver or Excel’s built in Solver should be
able to use RISKOptimizer with little difficulty.
RISKOptimizer is available with complete support for Excel versions
97 and higher. RISKOptimizer is offered in two versions - standard
and industrial - to allow you to select the optimizer with the capacity
you need.
Your RISKOptimizer package includes the following:
The RISKOptimizer User’s Guide, which you are reading now, offers
an introduction to RISKOptimizer and the principles behind it, then
goes on to show several example applications of RISKOptimizer’s
unique genetic algorithm and simulation technologies. This complete
manual may also be used as a fully-indexed reference guide, with a
description and illustration of each RISKOptimizer feature.
Why RISKOptimizer?
RISKOptimizer opens up a whole new spectrum of problems to
optimization. With RISKOptimizer, optimal solutions can be found
when problems contain variables outside your control whose values
are not known. Current optimizers such as Solver (a linear and nonlinear optimizer included with Excel) and Evolver (a genetic
algorithm-based optimizer from Palisade Corporation) cannot find
optimal solutions when ranges of possible values are entered for
uncertain factors in a model.
Traditional
Optimization
Problems
Traditional Excel-based optimization problems analyzed using Solver
or Evolver are comprised of:
•
An output or “target” cell that you wish to minimize or maximize
•
A set of input or “adjustable cells” whose values you control
•
A set of constraints that need to be met, often specified using
expressions such as COSTS<100 or A11>=0
Chapter 1: Introduction
3
During an optimization in Solver or Evolver, the adjustable cells are
changed across allowable ranges you specify. For each possible set of
adjustable cell values the model is recalculated, and a new value for
the target cell is generated. When the optimization is complete, an
optimal solution (or combination of adjustable cell values) is found.
This solution is the combination of adjustable cell values which yields
the best (i.e., minimum or maximum) value for the target cell while
satisfying the constraints you’ve entered.
Optimization of
Uncertain
Models
When a model has uncertain elements, however, both Solver and
Evolver cannot generate optimal solutions. In the past, many
optimization models just ignored uncertainty, making models
unrealistic but optimizable. If an attempt was made to find optimal
values by using simulation, a "brute-force" approach was employed to
search possible adjustable cell values on an iterative basis. This
involved running an initial simulation, changing one or more values,
rerunning the simulation, and repeating this process until what
looked like an optimal solution was found. This is a lengthy process,
and it is usually not clear how to change the values from one
simulation to the next.
With RISKOptimizer the uncertainty present in a model may be
included and reliable optimal solutions which take that uncertainty
into account can be generated. RISKOptimizer uses simulation (from
@RISK) to deal with the uncertainty present in the model and uses
genetic algorithms (from Evolver) to generate possible values for the
adjustable cells. The result of this “simulation optimization” is the
combination of values for the adjustable cells which minimizes or
maximizes a statistic for the simulation results for the target cell. You
may, for example, wish to find the combination of adjustable cell
values which maximizes the mean of the target cell’s probability
distribution, or minimizes the standard deviation.
Modeling
Uncertainty
4
For modeling uncertainty, RISKOptimizer allows you to describe the
possible values for any spreadsheet element using any of the
probability distribution functions available in @RISK. A value of 10,
for example, in a spreadsheet cell could be replaced with the @RISK
function =RiskNormal(10,2). This would specify that the possible
values for the cell are described by a probability distribution with a
mean of 10 and a standard deviation of 2. As in @RISK, probability
distributions can be correlated using @RISK functions such
RiskCorrmat and DepC.
Introduction
Optimization
Using
Simulation
When optimizing, RISKOptimizer runs a full simulation for each
possible trial solution that is generated by the GA-based optimizer. In
each iteration of a trial solution's simulation, probability distribution
functions in the spreadsheet are sampled and a new value for the
target cell is generated. At the end of a simulation, the result for the
trial solution is the statistic for the distribution of the target cell which
you wish to minimize or maximize. This value is then returned to the
optimizer and used by the genetic algorithms to generate new and
better trial solutions. For each new trial solution, another simulation
is run and another value for the target statistic is generated.
As in traditional optimizers, constraints that need to be met can be
entered in RISKOptimizer. Constraints can be checked either each
iteration of a simulation (an “iteration” constraint) or at the end of
each simulation (a “simulation” constraint). Iterations constraints are
typically tradional Solver or Evolver style constraints, such as
A11>1000. Simulation constraints are constraints that reference a
statistic on the distribution of simulation results for any cell in your
model you specify. A typical simulation constraint could be “Mean of
A11>1000” or the mean of the distribution of simulation results for
cell A11 must be less than 1000. As in Evolver, constraints can be
hard or soft, and a violated hard constraint causes a trial solution to be
rejected.
As large numbers of simulations are being run by RISKOptimizer, two
important techniques are used to minimize runtimes and generate
optimal solutions as quickly as possible. First, RISKOptimizer uses
convergence monitoring to determine when a sufficient number of
iterations have been run (but not too many). This insures that the
resulting statistic from the target cell’s probability distribution is
stable, and that any statistics from output distributions referenced in
constraints are stable. Secondly, RISKOptimizer uses Evolver’s genetic
operators to generate trial solutions that move toward an optimal
solution as quickly as possible.
Simulation
Results
RISKOptimizer comes with a set of simulation statistics functions
which can be used to return simulation results directly to your
spreadsheet. The function RiskMean(cell reference), for example,
returns the mean of the simulated distribution for the entered cell
directly to a worksheet cell or formula. In addition, any model built in
RISKOptimizer can be directly simulated in @RISK, Palisade
Corporation's risk analysis and simulation add-in for Excel, when you
want to get detailed graphics and statistics on the best model solution
found by RISKOptimizer. Because RISKOptimizer's simulation is
Chapter 1: Introduction
5
based on @RISK, no changes to a RISKOptimizer model are required to
simulate it in @RISK!
Custom
Applications
Using
RISKOptimizer
RISKOptimizer comes with a complete macro language for building
custom applications which use RISKOptimizer's capabilities.
RISKOptimizer's custom macro functions can be used in Visual Basic
for Applications (VBA) programs for setting up and running
optimizations and displaying the results from optimizations. For
more information on controlling RISKOptimizer from VBA, see
Appendix A: Controlling RISKOptimizer with VBA.
Applications of
Simulation
Optimization
Using
RISKOptimizer
The availability of optimization for uncertain models allows the
solution of many previously "unoptimizable" problems. As a rule,
any model that has uncertain elements can be optimized through the
combination of simulation and optimization, including:
6
♦
Selection of optimal production and capacity levels for new
products with uncertain market conditions
♦
Identification of optimal inventory levels with uncertain demand
♦
Portfolio allocation for risk minimization
♦
Identification of optimal product mix from a factory where
product markets are geographically distributed and demand
levels are uncertain
♦
Determining optimal levels for options purchases when hedging
♦
Yield management when the same product is sold at different
prices under different restrictions
♦
Scheduling with uncertain task times
Introduction
Before You Begin
Before you install and begin working with RISKOptimizer, make sure
that your RISKOptimizer package contains all the required items, and
check that your computer meets the minimum requirements for
proper use.
What the Package Includes
The RISKOptimizer software diskettes or CD-ROM contain the
RISKOptimizer Excel add-in, RISKOptimizer Watcher™, several
RISKOptimizer examples, and a fully-indexed RISKOptimizer on-line
help system. Your complete RISKOptimizer package should include:
•
1 RISKOptimizer User’s Guide
•
1 Program CD-ROM
•
1 RISKOptimizer registration card
NOTE: If anything is missing please immediately contact Palisade, or
the dealer from which you bought your RISKOptimizer package.
Registration
Please complete and return your RISKOptimizer Registration Card to
become a fully registered RISKOptimizer user. Once you register your
copy you will qualify for free customer support and special upgrade
offers. You will also be notified of any product enhancements and
related announcements.
Chapter 1: Introduction
7
Working with your Operating Environment
This User’s Guide assumes that you have a general knowledge of the
Windows operating system and Excel. In particular:
♦
You are familiar with your computer and using the mouse.
♦
You are familiar with terms such as icons, click, double-click, menu,
window, command and object.
♦
You understand basic concepts such as directory structures and file
naming.
If You Need Help
Technical support is provided free of charge for all registered users of
RISKOptimizer with a current maintenance plan, or is available on a
per incident charge. To ensure that you are a registered user of
RISKOptimizer, please register online at
www.palisade.com/html/register.html.
If you contact us by telephone, please have your serial number and
User’s Guide ready. We can offer better technical support if you are
in front of your computer and ready to work.
Before Calling
8
Before contacting technical support, please review the following
checklist:
•
Have you referred to the on-line help?
•
Have you checked this User's Guide and reviewed the on-line
multimedia tutorial?
•
Have you read the README.WRI file? It contains current information
on RISKOptimizer that may not be included in the manual.
•
Can you duplicate the problem consistently? Can you duplicate the
problem on a different computer or with a different model?
•
Have you looked at our site on the World Wide Web? It can be found at
http://www.palisade.com. Our Web site also contains the latest FAQ
(a searchable database of tech support questions and answers) and
RISKOptimizer patches in our Technical Support section. We
recommend visiting our Web site regularly for all the latest information
on RISKOptimizer and other Palisade software.
Introduction
Contacting
Palisade
Palisade Corporation welcomes your questions, comments or
suggestions regarding RISKOptimizer. Contact our technical support
staff using any of the following methods:
•
E-mail us at [email protected]
•
Telephone us at (607) 277-8000 any weekday from 9:00 AM to 5:00
PM, EST. Press 2 on a touch-tone phone to reach technical support.
•
Fax us at (607) 277-8001.
•
Mail us a letter at:
Technical Support
Palisade Corporation
31 Decker Road
Newfield, NY 14867 USA
If you want to contact Palisade Europe:
•
E-mail us at [email protected]
•
Telephone us at +44 (0)207 426 9950 (UK).
•
Fax us at +44 (0)207 375 1229 (UK).
•
Mail us a letter at:
Palisade Europe
Technical Support
The Blue House, Unit 1
30 Calvin Street
London E1 6NW UK
Regardless of how you contact us, please include the product name,
version and serial number.
Student
Versions
Telephone support is not available with the student version of
RISKOptimizer. If you need help, we recommend the following
alternatives:
Chapter 1: Introduction
♦
Consult with your professor or teaching assistant.
♦
Log-on to our site on the World Wide Web for answers to frequently
asked questions.
♦
Contact our technical support department via e-mail or fax.
9
RISKOptimizer System Requirements
System requirements for RISKOptimizer include:
10
•
Pentium PC or faster with a hard disk.
•
Microsoft Windows 98 or higher or Windows NT 4.0 or higher.
•
32 MB installed memory.
•
Microsoft Excel Version 97 or higher.
Introduction
Installation Instructions
RISKOptimizer is an add-in program to Microsoft Excel. By adding
additional commands to the Excel menu bars, RISKOptimizer enhances
the functionality of the spreadsheet program.
General Installation Instructions
The Setup program copies the RISKOptimizer system files into a
directory you specify on your hard disk. Setup asks you for the
location of the Excel directory on your hard disk, so please note this
information before running Setup. Setup and RISKOptimizer require
Microsoft Windows to run, so be sure to start Windows before
running these programs.
To run the Setup program in Windows 98 or higher:
1) Insert the RISKOptimizer CD-ROM in your CD-ROM drive
2) Click the Start button, click Settings and then click Control Panel
3) Double-click the Add/Remove Programs icon
4) On the Install/Uninstall tab, click the Install button
5) Follow the Setup instructions on the screen
If you encounter problems while installing RISKOptimizer, verify that
there is adequate space on the drive to which you’re trying to install.
After you’ve freed up adequate space, try rerunning the installation.
Authorizing
Your Copy of
RISKOptimizer
Within 30 days of installing RISKOptimizer you need to authorize
your copy of RISKOptimizer.
Authorization can be done over the Internet by clicking the Authorize
Now button and following the prompts on the screen. Alternatively,
you can contact Palisade or Palisade Europe during normal business
hours and authorize your copy of RISKOptimizer over the phone.
An authorized copy of RISKOptimizer is licensed for use on a single
computer only. If you wish to move your copy of RISKOptimizer to a
different computer, please contact Palisade for instructions.
Chapter 1: Introduction
11
Removing
RISKOptimizer
from Your
Computer
Setup creates the file INSTALL.LOG in your RISKOptimizer directory.
This file lists the names and locations of all installed files. If you wish
to remove RISKOptimizer from your computer, use the Control Panel’s
Add/Remove Programs utility and select the entry for RISKOptimizer.
The DecisionTools Suite
RISKOptimizer can be used with the DecisionTools Suite, a set of
products for risk and decision analysis available from Palisade
Corporation. The default installation procedure of RISKOptimizer
puts RISKOptimizer in a subdirectory of a main Program
Files\Palisade directory. This is quite similar to how Excel is often
installed into a subdirectory of a Microsoft Office directory.
One subdirectory of the Program Files\Palisade directory will be the
RISKOptimizer directory (by default called RISKOPT). This directory
contains the RISKOptimizer add-in program file (RISKOPT.XLA) plus
example models and other files necessary for RISKOptimizer to run.
Another subdirectory of Program Files\Palisade is the SYSTEM
directory which contains files needed by every program in the
DecisionTools Suite, including common help files and program
libraries.
The
DecisionTools
Toolbar
12
When you launch one of the elements of the Suite from its desktop
icon, Excel will load a “DecisionTools Suite” toolbar which contains
one icon for each program of the Suite. This allows you to launch any
of the other products in the suite directly from Excel.
Installation Instructions
Setting Up the RISKOptimizer Icons or
Shortcuts
In Windows, setup automatically creates an RISKOptimizer command
in the Programs menu of the Taskbar. However, if problems are
encountered during Setup, or if you wish to do this manually another
time, follow the following directions.
1) Click the Start button, and then point to Settings.
2) Click Taskbar, and then click the Start Menu Programs tab.
3) Click Add, and then click Browse.
4) Locate the file RISKOPT.EXE and double click it.
5) Click Next, and then double-click the menu on which you want the
program to appear.
6) Type the name “RISKOptimizer”, and then click Finish.
Macro Security Warning Message on Startup
Microsoft Office provides several security settings (under
Tools>Macro>Security) to keep unwanted or malicious macros from
being run in Office applications. A warning message appears each
time you attempt to load a file with macros, unless you use the lowest
security setting. To keep this message from appearing every time you
run a Palisade add-in, Palisade digitally signs their add-in files. Thus,
once you have specified Palisade Corporation as a trusted source,
you can open any Palisade add-in without warning messages. To do
this:
•
Chapter 1: Introduction
Click Always trust macros from this source when a Security
Warning dialog (such as the one below) is displayed when
starting RISKOptimizer.
13
Other RISKOptimizer Information
Additional information on RISKOptimizer can be found in the
following sources:
RISKOptimizer
Read Me
This file contains a quick summary of RISKOptimizer, as well as any
late-breaking news or information on the latest version of your
software. Double-click the Read Me icon to open Windows Write. It
is a good idea to read over this text file before using RISKOptimizer.
RISKOptimizer
Tutorial
The RISKOptimizer tutorial is a stand-alone Windows program that
provides first-time users with a quick slide-show introduction of
RISKOptimizer and genetic algorithms. The presentation takes only a
few minutes to view. Double-click on the “RISKOptimizer Tutorial”
icon anytime to start the tutorial.
RISKOptimizer
Watcher
RISKOptimizer Watcher is a stand-alone Windows program that can
monitor and control all RISKOptimizer activity in your computer.
When RISKOptimizer is running the RISKOptimizer Watcher Toolbar
can be called up to view RISKOptimizer’s progress, create reports and
graphs, and even change parameters such as crossover and mutation
rates. RISKOptimizer Watcher is most often accessed by pressing the
magnifying glass icon from the RISKOptimizer Toolbar while
RISKOptimizer is running, but you can also open RISKOptimizer
Watcher anytime by double-clicking on this icon.
Learning RISKOptimizer
The quickest way to become familiar with RISKOptimizer is by
running the RISKOptimizer Tutorial by double-clicking on its icon in
the RISKOptimizer program group. This slide-show will demostrate
how RISKOptimizer looks and works within your Excel worksheet.
14
Installation Instructions
Chapter 2: Background
What Is RISKOptimizer?.......................................................................... 17
How does RISKOptimizer work? .............................................................. 18
Genetic Algorithms............................................................................ 18
Probability Distributions and Simulation....................................... 18
What Is Optimization?............................................................................... 19
Why Build Excel Models? ......................................................................... 20
Modeling Uncertainty in Excel Models................................................... 21
Using Simulation to Account for Uncertainty........................................ 21
Why Use RISKOptimizer? .......................................................................... 22
More Accurate, More Meaningful ................................................... 22
More Flexible ...................................................................................... 23
Easier to Use ....................................................................................... 23
Traditional Optimization vs. Simulation Optimization ................... 25
Traditional Spreadsheet Optimization Process...................................... 25
Simulation Optimization Process............................................................. 26
Figure 2-1 ............................................................................................ 27
Each Step of an Optimization with RISKOptimizer................................ 28
Entering Probability Distributions................................................... 28
Identify the Target Cell and Statistic............................................... 29
Entering Adjustable Cells ................................................................. 29
Entering Constraints.......................................................................... 30
Setting the Optimization and Simulation Options ........................ 30
Running the Optimization ................................................................ 31
Chapter 2: Background
15
16
What Is RISKOptimizer?
The RISKOptimizer software package provides users with an easy way
to find optimal solutions to models that include uncertainty. Simply
put, RISKOptimizer finds the best inputs that produce a desired
simulation output. You can use RISKOptimizer to find the right mix,
order, or grouping of variables that produces the highest expected
value for profits, the lowest risk (i.e., the minimum variance) for
profits, or the largest expected value for goods from the least amount
of materials. RISKOptimizer is an add-in to the Microsoft Excel
spreadsheet program; users set up a model of their problem in Excel,
then call up RISKOptimizer to solve it.
You must first model your problem in Excel, then describe it to the RISKOptimizer addin.
Excel provides all of the formulas, functions, graphs, and macro
capabilities that most users need to create realistic models of their
problems. RISKOptimizer provides the interface to describe the
uncertainty in your model and what you are looking for, and provides
the engines that will find it. Together, they can find optimal solutions
to virtually any problem that can be modeled.
Chapter 2: Background
17
How does RISKOptimizer work?
RISKOptimizer uses a proprietary set of genetic algorithms to search for
optimum solutions to a problem, along with probability distributions
and simulation to handle the uncertainty present in your model.
Genetic
Algorithms
Genetic algorithms are used in RISKOptimizer to find the best solution
for your model. Genetic algorithms mimic Darwinian principles of
natural selection by creating an environment where hundreds of
possible solutions to a problem can compete with one another, and
only the “fittest” survive. Just as in biological evolution, each solution
can pass along its good “genes” through “offspring” solutions so that
the entire population of solutions will continue to evolve better
solutions.
As you may already realize, the terminology used when working with
genetic algorithms is often similar to that of its inspiration. We talk
about how “crossover” functions help focus the search for solutions,
“mutation” rates help diversify the “gene pool”, and we evaluate the
entire “population” of solutions or “organisms”. To learn more about
how RISKOptimizer’s genetic algorithm works, see Chapter 7 - Genetic
Algorithms.
Probability
Distributions
and Simulation
18
Probability distributions and simulation are used in RISKOptimizer to
handle the uncertainty present in the variables in your model. These
capabilities are taken from @RISK, Palisade Corporation's risk analysis
add-in for Excel. Probability distributions are used to describe the
range of possible values for uncertain elements in your model and are
entered using probability distribution functions such as
RiskTriang(10,20,30). This would specify that a variable in your model
could take a minimum value of 10, a most likely value of 20 and a
maximum value of 30. Simulation is then used to generate a
distribution of possible outcomes for each possible trial solution that is
generated by the optimizer.
What Is RISKOptimizer?
What Is Optimization?
Optimization is the process of trying to find the best solution to a
problem that may have many possible solutions. Most problems
involve many variables that interact based on given formulas and
constraints. For example, a company may have three manufacturing
plants, each manufacturing different quantities of different goods.
Given the cost for each plant to produce each good, the costs for each
plant to ship to each store, and the limitations of each plant, what is
the optimal way to adequately meet the demand of local retail stores
while minimizing the transportation costs? This is the sort of question
that optimization tools are designed to answer.
Optimization often deals with searching for the
combination that yields the most from given resources.
In the example above, each proposed solution would consist of a
complete list of what goods made by what manufacturing plant get
shipped in what truck to what retail store. Other examples of
optimization problems include finding out how to produce the
highest profit, the lowest cost, the most lives saved, the least noise in a
circuit, the shortest route between a set of cities, or the most effective
mix of advertising media purchases. An important subset of
optimization problems involves scheduling, where the goals may
include maximizing efficiency during a work shift or minimizing
schedule conflicts of groups meeting at different times. To learn more
about optimization, see Chapter 6 - Optimization.
When a problem includes uncertainty, traditional solvers will fail
because they have no capabilities for dealing with the uncertainty
present in a model. In the above example, what if the demand of local
retail stores is uncertain - that is, you don't know exactly what
quantities of products will be demanded by each store? With a
Chapter 2: Background
19
traditional solver, you would just assume a quantity for demand from
each store. This would allow the model to be optimized; however, the
assumed demand levels would make your model an inaccurate
depiction of what will actually occur. With RISKOptimizer, you don't
have to assume a level for demand. You describe the possible values
for demand using a probability distribution and then use
RISKOptimizer's built-in simulation capabilities to include all possible
values for demand in your optimization results.
When RISKOptimizer is used, the best solution generated by the
optimizer is not a single maximum or minimum value for the
objective or "target cell" in the model you are trying to optimize, but a
maximum or minimum simulation statistic for the objective. Each
simulation run by RISKOptimizer generates a distribution of possible
results for your objective. This distribution has a variety of statistics,
such as a mean, standard deviation, minimum, etc. In the above
example, you might want to find the combination of inputs that
maximizes the mean of the distribution for profit or minimizes its
standard deviation.
To learn more about simulation, see Chapter 8 - Simulation.
Why Build Excel Models?
To increase the efficiency of any system, we must first understand
how it behaves. This is why we construct a working model of the
system. Models are necessary abstractions when studying complex
systems, yet in order for the results to be applicable to the “realworld,” the model must not oversimplify the cause-and-effect
relationships between variables. Better software and increasingly
powerful computers allow economists to build more realistic models
of the economy, scientists to improve predictions of chemical
reactions, and business people to increase the sensitivity of their
corporate models.
In the last few years computer hardware and software programs such
as Microsoft Excel, have advanced so dramatically that virtually
anyone with a personal computer can create realistic models of
complex systems. Excel’s built-in functions, macro capabilities and
clean, intuitive interface allow beginners to model and analyze
sophisticated problems. To learn more about building a model, see
Chapter 11 - RISKOptimizer Extras.
20
What Is RISKOptimizer?
Modeling Uncertainty in Excel Models
Variables are the basic elements in your Excel models that you have
identified as being important ingredients to your analysis. If you are
modeling a financial situation, your variables might be things like
Sales, Costs, Revenues or Profits. If you are modeling a geologic
situation, your variables might be things like Depth to Deposit,
Thickness of Coal Seam, or Porosity. Each situation has its own
variables, identified by you.
In some cases, you may know the values your variables will take in
the time frame of your model — they are certain or what statisticians
call "deterministic". Conversely, you may not know the values they
will take — they are uncertain, or "stochastic". If your variables are
uncertain you will need to describe the nature of their uncertainty.
This is done with probability distributions, which give both the range
of values that the variable could take (minimum to maximum), and
the likelihood of occurrence of each value within the range. In
RISKOptimizer, uncertain variables and cell values are entered as
probability distribution functions, for example:
RiskNormal(100,10)
RiskUniform(20,30)
RiskExpon(A1+A2)
RiskTriang(A3/2.01,A4,A5)
These "distribution" functions can be placed in your worksheet cells
and formulas just like any other Excel function.
Using Simulation to Account for Uncertainty
RISKOptimizer uses simulation, sometimes called Monte Carlo
simulation, to do a Risk Analysis on each possible solution generated
during an optimization. Simulation in this sense refers to a method
whereby the distribution of possible outcomes is generated by letting
a computer recalculate your worksheet over and over again, each time
using different randomly selected sets of values for the probability
distributions in your cell values and formulas. In effect, the computer
is trying all valid combinations of the values of input variables to
simulate all possible outcomes. This is just as if you ran hundreds or
thousands of "what-if" analyses on your worksheet, all in one sitting.
Chapter 2: Background
21
In each iteration of the simulation, probability distribution functions
in the spreadsheet are sampled and a new value for the target cell is
generated. At the end of a simulation, the result for the trial solution
is the statistic which you wish to minimize or maximize for the
distribution of the target cell. This value is then returned to the
optimizer and used by the genetic algorithms to generate new and
better trial solutions. For each new trial solution, another simulation
is run, and another value for the target statistic is generated.
Why Use RISKOptimizer?
When you are dealing with large numbers of interacting variables,
and you are trying to find the best mix, the right order, or the
optimum grouping of those variables, you may be tempted to just take
an “educated guess”. A surprising number of people assume that any
kind of modeling and analysis beyond guessing will require
complicated programming, or confusing statistical or mathematical
algorithms. A good optimized solution might save millions of dollars,
thousands of gallons of scarce fuel, months of wasted time, etc. Now
that powerful desktop computers are increasingly affordable, and
software like Excel and RISKOptimizer are readily available, there is
little reason to guess at solutions, or waste valuable time trying out
many scenarios by hand.
More Accurate,
More Meaningful
22
RISKOptimizer allows you to use the entire range of Excel formulas
and probability distributions to build more realistic models of any
system. When you use RISKOptimizer, you do not have to
“compromise” the accuracy of your model because the algorithm you
are using can not handle real world complexities. Traditional “baby”
solvers (statistical and linear programming tools) force users to make
assumptions about the way the variables in their problem interact,
thereby forcing users to build over-simplified, unrealistic models of
their problem. They force them to assume values for uncertain
variables because the optimizer cannot handle ranges of possible
values for uncertain model components. By the time users have
simplified a system enough that these solvers can be used, the
resulting solution is often too abstract to be practical. Any problems
involving large amounts of variables, non-linear functions, lookup
tables, if-then statements, database queries, or stochastic (random)
elements cannot be solved by these methods, no matter how simply
you try to design your model.
What Is RISKOptimizer?
More Flexible
There are many solving algorithms which do a good job at solving
small, simple linear and non-linear types of problems, including hillclimbing, baby-solvers, and other mathematical methods. Even when
offered as spreadsheet add-ins, these general-purpose optimization
tools can only perform numerical optimization. For larger or more
complex problems, you may be able to write specific, customized
algorithms to get good results, but this may require a lot of research
and development. Even then, the resulting program would require
modification each time your model changed.
Not only can RISKOptimizer handle numerical problems, it is the only
commercial program in the world that can solve most combinatorial
problems. These are problems where the variables must be shuffled
around (permuted) or combined with each other. For example,
choosing the batting order for a baseball team is a combinatorial
problem; it is a question of swapping players’ positions in the lineup.
Complex scheduling problems are also combinatorial. The same
RISKOptimizer can solve all these types of problems and many more
that nothing else can solve. RISKOptimizer’s unique genetic algorithm
and simulation technology allows it to optimize virtually any type of
model; any size and any complexity.
Easier to Use
In spite of its obvious power and flexibility advantages, RISKOptimizer
remains easy to use because an understanding of the complex genetic
algorithm techniques it uses is completely unnecessary.
RISKOptimizer doesn’t care about the “nuts and bolts” of your
problem; it just needs a spreadsheet model that can evaluate how
good different scenarios are. Just select the spreadsheet cells that
contain the variables and tell RISKOptimizer what you are looking for.
RISKOptimizer intelligently hides the difficult technology, automating
the “what-if” process of analyzing a problem.
Although there have been many commercial programs developed for
mathematical programming and model-building, spreadsheets are by
far the most popular, with literally millions being sold each month.
With their intuitive row and column format, spreadsheets are easier to
set up and maintain than other dedicated packages. They are also
more compatible with other programs such as word processors and
databases, and offer more built-in formulas, formatting options,
graphing, and macro capabilities than any of the stand-alone
packages. Because RISKOptimizer is an add-in to Microsoft Excel,
users have access to the entire range of functions and development
tools to easily build more realistic models of their system.
Chapter 2: Background
23
24
Traditional Optimization vs. Simulation Optimization
Traditional Optimization vs.
Simulation Optimization
RISKOptimizer combines simulation and optimization to allow the
optimization of models with uncertain factors. The optimizer uses the
results from successive runs of the simulation model to guide its
search for better, more optimal solutions. This section provides
background information on how simulation and optimization work
together in RISKOptimizer.
Traditional Spreadsheet Optimization Process
In the traditional process for optimizing a spreadsheet using an
optimization add-in such as Solver or Evolver, the following steps are
undertaken:
1) An output or “target” cell that you wish to minimize or
maximize is identified.
2) A set of input or “adjustable” cells whose values you control are
identified, and ranges of possible values for those cells are
described.
3) A set of constraints that need to be met, often specified using
expressions such as COSTS<100 or A11>=0 are entered.
4) An optimization is run, in which the spreadsheet is recalculated
successive times using different possible values for the
adjustable cells.
5) During this process:
a) Each recalculation generates a new "answer" or value for the
target cell.
b) The optimizer uses this new target cell value to select the next
set of values for the adjustable cells it will try.
c)
Another recalculation is performed, providing another new
answer that the optimizer can use for identifying a new set of
values for the adjustable cells.
This process in 5) repeats over and over again, as the optimizer moves
towards identifying an optimal solution - that is, the set of values for
the adjustable cells that minimizes or maximizes the target cell value.
Chapter 2: Background
25
Simulation Optimization Process
Simulation optimization using RISKOptimizer follows many of the
same steps as the traditional spreadsheet optimization process
outlined here. However, changes are made to 1) allow uncertainty to
be entered in the spreadsheet and 2) to use simulation, instead of a
simple recalculation of the spreadsheet, to provide the new target
cell "answer" that provides feedback to the optimizer for guiding its
selection of a new set of values for the adjustable cells.
The new process for simulation optimization using RISKOptimizer is
described below, with differences from traditional spreadsheet
optimization shown in bold:
1) Probability distribution functions are used to describe the
range of possible values for the uncertain elements in the
model.
2) An output or “target” cell is identified and the simulation
statistic (mean, standard deviation, etc.) for the cell that you
wish to minimize or maximize is selected.
3) A set of input or “adjustable” cells whose values you control are
identified and ranges of possible values for those cells are
described.
4) A set of constraints that need to be met, often specified using
expresssions such as COSTS<100 or A11>=0 are entered.
Additional constraints based on simulation statistics (i.e., 95th
Percentile of A11>1000) can also be entered.
5) An optimization is run, in which the spreadsheet is simulated
successive times, with each simulation using different possible
values for the adjustable cells. During this process:
a) Each simulation generates a new distribution of possible
values for the target cell. The statistic you wish to
minimize or maximize is calculated from this distribution.
b) The optimizer uses this new statistic for the target cell to
select the next set of values for the adjustable cells it will try.
c)
Another simulation is performed, providing another new
statistic that the optimizer can use for identifying a new set
of values for the adjustable cells
This process in 5) repeats over and over again, as the optimizer moves
towards identifying an optimal solution - that is, the set of values for
the adjustable cells that minimizes or maximizes the statistic for the
simulation results for the target cell. Figure 2-1 outlines both the
traditional optimization and simulation optimization process.
26
Traditional Optimization vs. Simulation Optimization
Figure 2-1
Chapter 2: Background
27
Each Step of an Optimization with
RISKOptimizer
Each step in the simulation optimization process used by
RISKOptimizer is detailed here:
Entering
Probability
Distributions
Probability distributions are used in RISKOptimizer to describe the
uncertainty present in the components of a model. For example, you
could enter RiskUniform(10,20) to a cell in your worksheet. This
specifies that the values for the cell will be generated by a uniform
distribution with a minimum of 10 and a maximum of 20. This range
of values replaces the single "fixed" value required by Excel. In
traditional spreadsheet optimization, no uncertainty can be added to a
model so probability distributions are not used.
In RISKOptimizer, a simulation of your model is run for each possible
combination of input values generated by the optimizer. Distribution
functions are used by RISKOptimizer during these simulations for
sampling sets of possible values. Each iteration of a simulation uses a
new set of values sampled from each distribution function in your
worksheet. These values are then used in recalculating your
worksheet and generating a new value for your target cell.
As with Excel functions, distribution functions contain two elements,
a function name and argument values which are enclosed in
parentheses. A typical distribution function is:
RiskNormal(100,10)
Like Excel functions, distribution functions may have arguments
which are references to cells or expressions. For example:
RiskTriang(B1,B2*1.5,B3)
In this case the cell value would be specified by a triangular
distribution with a minimum value taken from cell B1, a most likely
value calculated by taking the value for cell B2 and multiplying it by
1.5 and a maximum value taken from cell B3.
Distribution functions also may be used in cell formulas, just as are
Excel functions. For example, a cell formula could read:
B2: 100+RiskUniform(10,20)+(1.5*RiskNormal(A1,A2))
For more information on entering probability distributions, see
Chapter 9 - Probability Distribution Functions.
28
Traditional Optimization vs. Simulation Optimization
Identify the
Target Cell and
Statistic
In both RISKOptimizer and in a traditional spreadsheet optimization, a
target cell is identified. This is the cell whose value you are trying to
minimize or maximize, or the cell whose value you are trying to make
as close as possible to a pre-set value. Typically this is the "result" of
your model - profit, the model's grand total, etc. - but it can be any cell in
the spreadsheet. The cell needs to have a formula in it that will return
different values as the values in your adjustable cells change.
In RISKOptimizer, you are not minimizing or maximizing the actual
value in the target cell; you are minimizing or maximizing a
"statistic" associated with the simulation results for the target cell.
During an optimization, RISKOptimizer will run successive
simulations, each with a different set of adjustable cell values. Each
simulation generates a distribution of possible outcomes for the target
cell. You are looking for the set of adjustable cell values that, for
example, maximizes the mean of the target cell's distribution, or
minimizes its standard deviation.
In RISKOptimizer you have more options on what to minimize or
maximize (mean, standard deviation, miminum, etc.) because - for each
solution tried by the optimizer - the associated simulation does not
just generate a single answer. The simulation generates a full
distribution of possible outcomes for the target cell, with a minimum
value, a maximum, a mean, a standard deviation and so on. A
traditional optimization generates just one thing - a new target cell
value - for each solution tried by the optimizer and this value is the
only possible selection for minimizing or maximizing.
Entering
Adjustable Cells
Adjustable cells are entered in a similar fashion in both traditional
spreadsheet optimization and RISKOptimizer. For each cell which can
be changed during an optimization, a minimum possible value and a
maximum possible value are entered.
Since the optimizer used by RISKOptimizer is based on Evolver, the
entry of adjustable cells in RISKOptimizer has the same options as in
Evolver. This includes mutation rate, solving method and genetic
operators. For more information on entering adjustable cells, see the
section "By Adjusting the Cells" in Chapter 5: Complete Reference.
Chapter 2: Background
29
Entering
Constraints
In RISKOptimizer, as in traditional spreadsheet optimization, hard
constraints that must be met can be entered. In traditional
spreadsheet optimization, hard constraints are tested for each trial
solution. If they are not met, the solution is discarded.
In RISKOptimizer, a full simulation is run for each trial solution. Each
simulation is comprised of a number of iterations, or individual
recalculations of the spreadsheet using new samples from probability
distributions in the model. A hard constraint can be tested:
♦
Each iteration of each simulation (an iteration constraint). If an
iteration results in values which violate the hard constraint, the
simulation is stopped (and trial solution rejected) and the next
trial solution and its associated simulation begins.
♦
At the end of the simulation (a simulation constraint). This type of
constraint is specified in terms of a simulation statistic for a
spreadsheet cell; for example the Mean of A11>1000. In this case,
the constraint is evaluated at the end of a simulation. A
simulation constraint, as opposed to an iteration constraint, will
never cause a simulation to be stopped prior to completion.
A second form of constraints - "soft constraints" can also be used in
RISKOptimizer. The resulting penalties from soft constraints are
calculated at the end of a simulation. Any penalty calculated is added
to (or subtracted from) the target statistic which is being minimized or
maximized.
For more information on entering constraints, see the section "Subject
to the Constraints" in Chapter 5: Complete Reference.
Setting the
Optimization
and Simulation
Options
In RISKOptimizer, as in traditional spreadsheet optimization, a variety
of options are available for controlling how long an optimization runs.
However, RISKOptimizer adds new options for controlling how long
each simulation runs for each trial solution.
RISKOptimizer will search for better solutions and run simulations
until the selected optimization stopping options are met. You might
have RISKOptimizer run a specified number of minutes, run until it
has generated a specific number of trial solutions or run until the best
simulation statistic for the target cell has not changed for a given
number of trials.
30
Traditional Optimization vs. Simulation Optimization
You can also specify how long each trial solution's simulation will run.
You may select to have each simulation run a specified number of
iterations or, alternatively, let RISKOptimizer determine when to stop
each simulation. When you select to have RISKOptimizer decide stop
each simulation it will stop simulating when distributions generated
for both 1) the target cell of the optimization and 2) cells referenced in
simulation constraints are stable and the statistics of interest converge.
Running the
Optimization
When RISKOptimizer runs an optimization the spreadsheet is
simulated successive times, with each simulation using different
possible values for the adjustable cells. During this process:
1) The optimizer generates a set of values for the adjustable
cells.
2) The spreadsheet is simulated with the adjustable cells set
to the values generated by the optimizer . In each iteration
of the simulation all distribution functions in the spreadsheet
are sampled and the spreadsheet is recalculated, generating a
new value for the target cell. If any iteration constraints are
not met after an iteration's recalculation, the simulation stops
and the optimizer generates a new trial solution to be
simulated.
3) At the end of each simulation a new distribution of
possible values for the target cell is generated. The
statistic you wish to minimize or maximize is calculated
from this distribution. If any simulation constraints are not
met, the trial solution and simulation results are discarded
and the optimizer generates a new trial solution to be
simulated
4) The optimizer uses the new statistic for the target cell
calculated in the simulation to select the next set of values for
the adjustable cells it will try.
5) Another simulation is performed, providing another new
statistic that the optimizer can use for identifying a new set
of values for the adjustable cells
This process repeats itself over and over again, as the optimizer
moves towards identifying an optimal solution - that is, the set of
values for the adjustable cells that minimizes or maximizes the
statistic for the target cell.
Chapter 2: Background
31
32
Traditional Optimization vs. Simulation Optimization
Chapter 3:
RISKOptimizer: Stepby-Step
Introduction ............................................................................................... 35
The RISKOptimizer Tour........................................................................ 37
Starting RISKOptimizer .............................................................................. 37
The RISKOptimizer Toolbar............................................................. 37
Opening an Example Model............................................................. 37
Describing Uncertainty in the Model ...................................................... 39
The RISKOptimizer Settings Dialog .......................................................... 41
Selecting the Statistic for the Target Cell................................................. 41
Adding Adjustable Cells ........................................................................... 42
Selecting a Solving Method .............................................................. 42
Specifying the Adjustable Cells ....................................................... 43
Entering the Min-Max Range for Adjustable Cells ....................... 44
Constraints .................................................................................................. 45
Iteration and Simulation Constraints .............................................. 45
Adding a Constraint .......................................................................... 46
Simple Range of Values and Formula Constraints........................ 47
Other RISKOptimizer Options ................................................................... 49
Stopping Conditions.......................................................................... 49
Simulation Stopping Conditions...................................................... 50
Logging Simulation Data .................................................................. 51
Running the Optimization ........................................................................ 51
The RISKOptimizer Toolbar............................................................. 51
Starting the RISKOptimizer Watcher .............................................. 52
Stopping the Optimization ............................................................... 53
Summary Files.................................................................................... 53
Placing the Results in Your Model .................................................. 54
Chapter 3: RISKOptimizer: Step-by-Step
33
34
Introduction
In this chapter, we will take you through an entire RISKOptimizer
optimization one step at a time. If you do not have RISKOptimizer
installed on your hard drive, please refer to the installation section of
Chapter 1: Introduction and install RISKOptimizer before you begin
this tutorial.
We will start by opening a pre-made spreadsheet model, and then we
will define the problem to RISKOptimizer using probability
distributions and the RISKOptimizer dialogs. Finally we will oversee
RISKOptimizer’s progress as it is searching for solutions, and explore
some of the many options in the RISKOptimizer Watcher. For
additional information about any specific topic, see the index at the
back of this manual, or refer to Chapter 5: Complete Reference.
NOTE: The screens shown below are from Excel 97. If you are using
other versions of Excel, your windows may appear slightly different
from the pictures.
The problem-solving process begins with a model that accurately
represents your problem. Your model must be able to evaluate a
given set of input values (adjustable cells) and produce a numerical
rating of how well those inputs solve the problem (the evaluation or
“fitness” function). Your model also needs to include probability
distributions that describe the range of possible values for any
uncertain elements. As RISKOptimizer searches for solutions, the
simulation of the fitness function provides feedback, telling
RISKOptimizer how good or bad each guess is, thereby allowing
RISKOptimizer to breed increasingly better guesses. When you create
a model of your problem you must pay close attention to the fitness
function, because RISKOptimizer will be doing everything it can to
maximize (or minimize) the simulation results for this cell.
Chapter 3: RISKOptimizer: Step-by-Step
35
36
Introduction
The RISKOptimizer Tour
Starting RISKOptimizer
To start RISKOptimizer, either:
1) Click the RISKOptimizer icon in your Windows desktop, or select
Palisade DecisionTools then RISKOptimizer in the Windows
Start menu Programs entries. Each of these methods starts both
Microsoft Excel and RISKOptimizer. Alternatively,
2) Start Excel and click the RISKOptimizer button on the
DecisionTools toolbar
The
RISKOptimizer
Toolbar
When RISKOptimizer is loaded, a new RISKOptimizer toolbar is visible
in Excel. This toolbar contains buttons which can be used to specify
RISKOptimizer settings and start, pause, and stop optimizations.
Opening an
Example Model
To review the features of RISKOptimizer, you'll examine an example
model that was installed when you installed RISKOptimizer. To do
this:
1) Open the “AIRLINE.XLS” worksheet from your
“RISKOPT\EXAMPLES” directory.
Chapter 3: RISKOptimizer: Step-by-Step
37
This example sheet contains a yield management model which
identifies the optimal number of full and discount fare seats to sell on
a given flight. It also identifies the optimal number of reservations to
accept in excess of the number of available seats – the classic
“overbooking” problem. There’s just one catch to this standard
optimization problem -- some estimates in the model are uncertain or
"stochastic". This includes the number of passengers that will actually
show up to board the flight, the number of reservations that will be
demanded in each fare category and the cost of bumping a passenger
(i.e., sometimes a $100 travel voucher will suffice, while sometimes a
free roundtrip is necessary). Traditionally, single point estimates are
used for these items, allowing a normal optimization to be performed.
But what if your estimates aren’t right? You might end up taking too
few reservations, sending seats out empty, or overbooking too much.
You could sell too many discount seats – lowering your profit. You
might also set aside too many full fare seats, resulting in half-filled
planes. RISKOptimizer will solve this optimization problem while
allowing you to account for the uncertainty inherent to your model!
With the Airlines example, first you will describe the uncertainty
present in your model using probability distributions. You will then
use the RISKOptimizer dialogs to setup your optimization problem.
Then, RISKOptimizer will run to identify the optimal number of full
and discount fare reservations to maximize profit while keeping risk
at acceptable levels.
38
The RISKOptimizer Tour
Describing Uncertainty in the Model
In RISKOptimizer, probability distributions are used to describe the
range of possible values for the uncertain elements in your model. A
probability distribution specifies the minimum and maximum values
for an uncertain factor and relative probabilities of values between the
minimum and the maximum.
In RISKOptimizer, probability distributions are entered using
probability distribution functions. These are custom RISKOptimizer
functions that can be entered in the cells and formulas in your
spreadsheet just as are standard Excel functions. For example, the
function:
♦
RiskTriang(10,20,30) specifies a triangular distribution with a
minimum possible value of 10, a most likely of 20 and a maximum
of 30.
In the Airlines model there are five uncertain factors, each described
by probability distributions. The first of these is:
♦
Demand for Full Fare Reservations (in cell C8), described by the
probability distribution RiskTriang(3,7,15). This function
specifies that the number of full fare reservations that will be
demanded could be as low as three, as high as 15 with a most
likely value of 7.
To enter this probability distribution:
1) Select cell C8.
2) Enter the formula =ROUND(RiskTriang(3,7,15),0). The Excel
ROUND function simply takes the sample returned by the
RiskTriang function and rounds it to the nearest integer. (You
can't have 5.65 reservations demanded!)
Chapter 3: RISKOptimizer: Step-by-Step
39
The other distributions in the model, listed below, are already entered
in the Airlines.XLS. You can move to the cell where each is located
and review them if you like.
♦
% No Shows - Full Fare reservations (in cell C7). This is
described by RiskNormal(.2,.03), meaning on average 20% of full
fare reservations made do not show up for the flight. The actual
no show percentage will vary around 20% as described by a
normal distribution with a mean of .2 and a standard deviation of
.03.
♦
% No Shows - Discount Fare reservations(in cell C11). This is
described by RiskNormal(.1,.01), meaning on average 10% of
discount fare reservations made do not show up for the flight.
The actual no show percentage will vary around 10% as described
by a normal distribution with a mean of .1 and a standard
deviation of .01. More discount reservations show up as
compared with full fare as there is a $75 charge to change
discount tickets vs. none for fully refundable full fare tickets.
♦
Demand for Discount Fare Reservations(in cell C12), described
by the probability distribution RiskTrigen(12,20,40,10,90)). This
function specifies that the number of discount reservations
demanded is described by a triangular probability distribution
whose 10th percentile is 12, most likely value is 20 and 90th
percentile is 40.
♦
Cost of Bumping (in cell C23), described by the probability
distribution RiskDiscrete({100,150,200,250},{0.1,0.4,0.4,0.1}). This
specifies that the cost per passenger bumped can be $100, $150,
$200 or $250, as sometimes passengers will volunteer to get off an
overbooked flight for a $100 travel voucher, while other times
greater compensation is necessary.
For more information on these and other probability distributions, see
Chapter 9: Probability Distribution Functions.
With probability distributions describing uncertainty entered in your
model, you can now set up the optimization using the RISKOptimizer
dialogs.
40
The RISKOptimizer Tour
The RISKOptimizer Settings Dialog
To set the RISKOptimizer options for this worksheet:
1) Click the RISKOptimizer Settings icon on the RISKOptimizer
toolbar (the one on the far left).
This displays the following RISKOptimizer Settings dialog box:
The RISKOptimizer Settings dialog is designed so users can describe
their problem in a simple, straightforward way. In our tutorial
example, we are trying to find the number of reservations for full fare
and discount seats that should be accepted in order to maximize
overall total profit.
Selecting the Statistic for the Target Cell
"Profit" in cell C27 in the Airlines.XLS model is what's known as the
target cell. This is the cell whose simulation statistic you are trying to
minimize or maximize, or the cell whose simulation statistic you are
trying to make as close as possible to a pre-set value. To specify the
simulation statistic for the target cell:
1) Set the “Find the...” option to “Maximum Value.”
2) Select "Mean" from the dropdown list to select the Mean as the
simulation statistic to maximize.
3) Enter the target cell, $C$27, in the “of cell...” field.
Chapter 3: RISKOptimizer: Step-by-Step
41
Cell references can be entered in RISKOptimizer dialog fields two
ways: 1) You may click in the field with your cursor, and type the
reference directly into the field, or 2) with your cursor in the selected
field, you may click on the worksheet cell(s) directly with the mouse.
To select the cells underneath the dialog, drag the dialog to one side,
and click on the target cell directly.
Adding Adjustable Cells
Now you must specify the location of the cells that contain values
which RISKOptimizer can adjust to search for solutions. These
variables are added and edited one block at a time through the
Adjustable Cells Dialog. The number of cells you can enter in the
Adjustable Cells dialog depends on the version of RISKOptimizer you
are using.
1) Click the “Add” button in the "By Adjusting the Cells" section.
When you “Add” or “Edit” adjustable cells RISKOptimizer displays
the Adjustable Cells dialog box.
The Adjustable Cells Dialog prompts the user to select the
variables and choose how they should be juggled.
Selecting a
Solving Method
42
When defining adjustable cells, first you will specify a solving method
to be used. Different types of adjustable cells are handled by different
solving methods. Often you'll use the default “recipe” solving
method where each cell’s value can be changed independently of the
The RISKOptimizer Tour
others. Since this is selected as the default method, you don't have to
change it.
The “recipe” and “order” solving methods are the most popular and
they can be used together to solve complex combinatorial problems.
Specifically, the “recipe” solving method treats each variable as an
ingredient in a recipe, trying to find the “best mix” by changing each
variable’s value independently. In contrast, the “order” solving
method swaps values between variables, shuffling the original values
to find the “best order.”
Specifying the
Adjustable Cells
In our tutorial example, we have two cells that we want
RISKOptimizer to adjust. These cells contain the values for the
maximum number of reservations accepted and the percentage of
those reservations that will be allocated to full fare seats.
1) Drag the Adjustable Cells dialog box to the right.
Move the dialog to one side so you can click on the cells directly on the sheet.
2) With your cursor in the Adjustable Cell Range field, you can
either type in the first adjustable cell by hand (C14), or you can
click on the actual worksheet cell and the cell will be entered in
the Adjustable Cell Range field automatically.
Your Adjustable Cell Range field should now read $C$14 as in the
screen above.
Chapter 3: RISKOptimizer: Step-by-Step
43
Entering the
Min-Max Range
for Adjustable
Cells
Most of the time you'll want to restrict the possible values for an
adjustable cell range to a specific minimum-maximum range. In
RISKOptimizer this is known as a "range" constraint. You can quickly
enter this min-max range when you select the set of cells to be
adjusted. For the Airlines example, the minimum possible value for
reservations accepted in this range is 19 and the maximum is 30. To
enter this range constraint:
1) Enter 19 in the Min text box and 30 in the Max text box.
2) Click "Integer Values Only".
3) Click the Add button.
4) Type "Maximum Reservations Accepted" as the description for
this constraint.
5) Click OK.
Now, enter a second cell to be adjusted:
1) Click Add to enter a second adjustable cell.
2) Click in the Cell Range field and select cell C15.
3) Enter 0 as the Min and 1 as the Max.
4) Type "% Full Fare Seats" as the description for this constraint.
5) Click OK.
This specifies the last adjustable cell, C15, representing the percentage
of total reservations that will be allotted to full fare seats.
NOTE: Your range constaints are also displayed in the Subject to the
Constraints section of the main RISKOptimizer dialog.
You will notice that the adjustable cells you selected, along with the
solving method to use on those cells, are now listed in the By Adjusting
the Cells section of the RISKOptimizer Settings dialog box.
If there were additional variables in this problem, we would continue
to add sets of adjustable cells. In RISKOptimizer, you may create an
unlimited number of groups of adjustable cells in the Industrial
version and up to 80 adjustable cells in the Standard version. To add
more cells, click the “Add” button once again, and you will see a new
Adjustable Cells dialog box appear, which allows you to choose new
44
The RISKOptimizer Tour
adjustable cells and a new solving method to apply to those cells.
Here click “Cancel” to return to the RISKOptimizer Settings dialog
box.
Later, you may want to check the adjustable cells or change some of
their settings. To do this, simply click on the group of adjustable cells
you would like to inspect (the group will appear highlighted in
inverse type), and click the “Edit” button. You may also select a set of
cells and delete it by clicking the “Delete” button.
Constraints
RISKOptimizer allows you to enter constraints which are conditions
that must be met for a solution to be valid. In this example model
there are two additional constraints that must be met for a possible set
of values for maximum number of reservations accepted and % full fare
seats to be valid. These are in addition to the range constraints we
already entered for the adjustable cells. They are:
♦
Profit must always be >0.
♦
Standard deviation of the simulation results for profit must be
<400.
Each time RISKOptimizer generates a possible solution to your model
it will run a simulation for that solution. Each simulation will involve
hundreds or thousands of iterations or recalculations of the
spreadsheet. In each iteration, a value is sampled from each
probability distribution in the model, the model is recalculated using
these new sampled values and a new value for the target cell is
generated. At the end of a trial solution's simulation a probability
distribution for the target cell is generated using target cell values
calculated for each iteration.
Iteration and
Simulation
Constraints
RISKOptimizer can check your constraints either:
♦
After each iteration of a simulation (an "iteration" constraint)
♦
At the end of each simulation (a "simulation" constraint)
In the Airlines model, "Profit must always be >0" is an iteration
constraint, while "Standard deviation of the simulation results for
profit must be <400" is a simulation constraint. In other words, after
each iteration of a simulation RISKOptimizer will check to insure that
Profit is greater than 0; if it is not the trial solution will be discarded.
If a simulation completes successfully (i.e., Profit > 0 for all iterations)
the standard deviation of the probability distribution for profit will be
checked to insure that it is less than 400; if it is not the trial solution
will be discarded.
Chapter 3: RISKOptimizer: Step-by-Step
45
Constraints are displayed in the bottom Subject to the Constraints
section of the main RISKOptimizer dialog box. Three types of
constraints can be specified in RISKOptimizer:
Adding a
Constraint
♦
Range. These are minimum and maximum possible values for
each of the adjustable cell ranges you have entered (i.e., a range
constraint could be 10<=C20<=100; where C20 is an adjustable
cell that can be changed to different values in the range between
10 and 100).
♦
Hard. These are conditions that must be met for a solution to be
valid (i.e., a hard iteration constraint could be C10<=A4; in this
case, if a solution generates a value for C10 that is greater than the
value of cell A4, the solution will be thrown out)
♦
Soft. These are conditions which we would like to be met as much
as possible, but which we may be willing to compromise for a big
improvement in fitness or target cell result. (i.e., a soft constraint
could be C10<100. In this case, C10 could go over 100, but when
that happens the calculated value for the target cell would be
decreased according to the penalty function you have entered).
To add a constraint:
1) Click the Add button in the Subject to the Constraints section of
the main RISKOptimizer dialog.
This displays the Constraint Definition dialog box, where you enter
the constraints for your model.
46
The RISKOptimizer Tour
Simple Range of
Values and
Formula
Constraints
Two formats – Simple Range of Values and Excel formula – can be used
for entering constraints. The Simple Range of Values format allows
constraints to be entered using simple <,<=, >, >= or = relations. A
typical Simple Range of Values constraint would be 0<Value of A1<10,
where A1 is entered in the Cell Range box, 0 is entered in the Min box
and 10 is entered in the Max box. The operator desired is selected
from the drop down list boxes. With a Simple Range of Values format
constraint, you can enter just a Min value, just a Max or both.
A formula constraint, on the other hand, allows you to enter any valid
Excel formula as a constraint, such as A19<(1.2*E7)+E8. For each
possible solution RISKOptimizer will check whether the entered
formula evaluates to TRUE or FALSE to see if the constraint has been
met. If you want to use a boolean formula in a worksheet cell as a
constraint, simply reference that cell in the Formula field of the
Constraint Definition dialog box.
To enter the constraints for the Airlines model you'll specify two new
constraints. First, enter the Simple Range of Values format hard
constraint for Profit > 0:
1) In the Cell Range box, enter C27.
2) Select the > operator to the right of the Cell Range.
3) Clear the default value of 0 in the Max box
4) Enter "Profit > 0" in the description box.
5)
Click "Every Iteration of Each Simulation" and click OK. This
specifies that you must always insure that Profit is greater than
0, no matter how many reservations are taken.
Now, enter the simulation constraint:
1) Click Add to display the Constraint Definition dialog box again.
2) Click "Only at the End of Each Simulation".
3) Click the Statistic dropdown list and select "StdDev".
Chapter 3: RISKOptimizer: Step-by-Step
47
4) In the Cell Range box, enter C27.
5) Select the <= operator to the right of the Cell Range.
6) Enter 400 in the Max box.
7) Clear the default value of 0 in the Min box.
8) Enter "StdDev of Profit <400" in the description box.
9) Clear the default value of 0 in the Max box
10) Click OK.
Your complete constraints section should look like this.
48
The RISKOptimizer Tour
Other RISKOptimizer Options
Options such as Update Display, Random Number Seed, Optimization
Stopping Conditions and Simulation Stopping Conditions are available to
control how RISKOptimizer operates during an optimization. Let's
specify some stopping conditions and update display settings.
Stopping
Conditions
RISKOptimizer will run an optimization as long as you wish. The
stopping conditions allow RISKOptimizer to automatically stop when
either: a) a certain number of scenarios or “trials” have been examined, b) a
certain amount of time has elapsed, c) no improvement has been found in the
last n scenarios or d) the entered Excel formula evaluates to TRUE. To
view and edit the stopping conditions:
1) Click the Options button in the main RISKOptimizer dialog.
In the Options dialog you can select any combination of these four
optimization stopping conditions, or none at all. If you select more
than one stopping condition, RISKOptimizer will stop when any one of
the selected conditions are met. If you do not select any stopping
conditions, RISKOptimizer will run forever, until you stop it manually
by pressing the “stop” button in the RISKOptimizer toolbar.
Chapter 3: RISKOptimizer: Step-by-Step
49
Simulations
Minutes
Change in Last
Formula is True
This option sets the
number of
simulations that
you would like
RISKOptimizer to
run. RISKOptimizer
runs a simulation
for one complete set
of variables or one
possible solution to
the problem.
RISKOptimizer will
stop after the
specified amount of
time has elapsed.
This number can be
a fraction (4.25).
This stopping
condition is the
most popular
because it keeps
track of the
improvement and
allows
RISKOptimizer to
run until the rate of
improvement has
decreased. For
example,
RISKOptimizer
could stop if 100
simulations have
passed and we still
haven’t had any
change in the best
scenario found so
far.
RISKOptimizer will
stop if the entered
Excel formula
evaluates to TRUE
in a simulation.
1) Set Minutes = 5 to allow RISKOptimizer to run for five minutes.
Simulation
Stopping
Conditions
RISKOptimizer runs a full simulation of your model for each trial
solution it generates. You can specify how long to run each of these
simulations using Simulation Stopping Conditions. You can run each
simulation for a fixed number of iterations, or, alternatively, let
RISKOptimizer determine when to stop each simulation.
Run XXXX Iterations
Stop on Actual
Convergence
Stop on Projected
Convergence
This option allows you to
run each simulation for a
fixed number of iterations.
In this case, RISKOptimizer
will run the specified
number of iterations for
each simulation that is
performed for each trial
solution generated by
RISKOptimizer (unless
stopped prematurely when
an iteration constraint is not
met).
This option instructs
RISKOptimizer to stop
each simulation when the
distributions generated
for both 1) the target cell
of the optimization and
2) cells referenced in
simulation constraints are
stable and the statistics of
interest converge. The
amount of variation
allowed in a statistic
when it is marked as
"converged" is set by the
Tolerance option.
This option instructs
RISKOptimizer to stop each
simulation when it can
project internally that the
distributions generated for
both 1) the target cell of the
optimization and 2) cells
referenced in simulation
constraints are stable.
RISKOptimizer projects
convergence based on the
results of prior simulations
that have been run during
the optimization.
1) Set Iterations = 500 to have RISKOptimizer run a quick
simulation for each trial solution.
50
The RISKOptimizer Tour
Logging
Simulation Data
RISKOptimizer can display an ongoing description of each simulation
run during an optimization, including the value of the target statistic
calculated, basic statistics on the simulated distribution of target cell
values, the adjustable cell values used and whether constraints were
met. To view this log during an optimization:
1) Click "Log Simulation Data" in the Options dialog.
2) Click OK to exit the Options dialog.
Running the Optimization
Now, all that remains is to optimize this model to determine the
maximum number of reservations in each fare category which
maximizes your profit. To do this:
1) Click OK to exit the main RISKOptimizer dialog.
The
RISKOptimizer
Toolbar
The RISKOptimizer toolbar in Excel allows you to start, pause and stop
an optimization using a "VCR button" interface:
From here, you may start, pause, then re-start the RISKOptimizer
process by pressing the Run, Pause, then the Run buttons,
respectively. You may also press Stop button at any time to stop the
RISKOptimizer process. To start the optimization:
1) Click the Run button on the RISKOptimizer toolbar.
As RISKOptimizer begins working on your problem, you will see the
current best values for your adjustable cells - total # of reservations
accepted and % of reservations which are full fare - in yellow in your
spreadsheet. The best mean for Profit is shown in blue with an arrow
pointing at the target cell.
During the run, the status bar in Excel displays: 1) the best solution
found so far, 2) the original value for the selected simulation statistic
for the target cell when the RISKOptimizer optimization began, 3) the
number of simulations of your model that have been executed and
number of those simulations which were valid; i.e., all constraints
were met and 4) the time that has elapsed in the optimization.
Chapter 3: RISKOptimizer: Step-by-Step
51
Any time during the run you can press <NumLock> to see a live
updating of the screen during all iterations of each simulation. Press
<NumLock> again to turn off updating.
Starting the
RISKOptimizer
Watcher
RISKOptimizer can also display a running log of the simulations
performed for each trial solution. We can call up this log by pressing
the RISKOptimizer Watcher button while RISKOptimizer is running.
1) Click the RISKOptimizer Watcher button on the RISKOptimizer
toolbar.
This toolbar button with the magnifying glass will open the
RISKOptimizer Watcher, which will allow you to explore and modify
many aspects of your problem as it runs.
2) Click the Log button (first button on the right).
In this report the results of the simulation run for each trial solution is
shown. The column for Result shows by simulation the value of the
target cell's statistic that you are trying to maximize or minimize - in
this case, the mean of Profit in $C$27. Columns for Output Mean,
Output StdDev, Output Min and Output Max describe the probability
distribution for the target cell Profit that was calculated by each
simulation. The columns for $C$14 and $C$15 identify the values used
52
The RISKOptimizer Tour
for your adjustable cells. Columns for StdDev Profit<400 and Profit>0
show whether your constraints were met in each simulation.
Stopping the
Optimization
After five minutes, RISKOptimizer will stop the optimization. You can
also stop the optimization by:
1) Clicking the Stop button from the RISKOptimizer Toolbar.
When the RISKOptimizer process stops, RISKOptimizer displays a
dialog box which offers the following choices:
These same options will automatically appear when any of the
stopping conditions that were set in the RISKOptimizer Options dialog
are met.
Summary Files
RISKOptimizer can create an optimization summary worksheet that
contains a report on the solution you have found. This report contains
information such as date and time of the run, the optimization settings
used, the value calculated for the target cell and the value for each of
the adjustable cells.
Chapter 3: RISKOptimizer: Step-by-Step
53
This report is useful for comparing the results of successive
optimizations. In addition, you can use the Restore button in the log
worksheet to restore your worksheet and optimization settings to
previously used values.
Placing the
Results in Your
Model
To place the new, optimized mix of production levels for the Airlines
to each of the sixteen tasks in your worksheet:
1) Make sure the "Best Values Found so Far" option is selected
2) Click on the “Stop” button.
You will be returned to the “AIRLINE.XLS” spreadsheet, with all of
the new variable values that created the best solution. Remember,
the best solution is a mean of simulation results for Profit and this
is not the same as the value shown for a simple recalculation of
Profit that uses the best variable values. The best mean is shown in
the blue box with the arrow that points at Profit.
54
The RISKOptimizer Tour
IMPORTANT NOTE: Although in our example you can see that
RISKOptimizer found a solution which yielded a total profit of
2236.03, your result may be higher or lower than this. RISKOptimizer
may have also found a different combination of Maximum
Reservations Accepted and Percentage Sold at Full Fare that produced
the same total score. These differences are due to an important
distinction between RISKOptimizer and all other problem-solving
algorithms: it is the random nature of RISKOptimizer’s genetic
algorithm engine that enables it to solve a wider variety of problems,
and find better solutions.
When you save any sheet after RISKOptimizer has run on it (even if
you “restore” the original values of your sheet after running
RISKOptimizer), all of the RISKOptimizer settings in the RISKOptimizer
dialogs will be saved along with that sheet. The next time that sheet is
opened, all of the most recent RISKOptimizer settings load up
automatically. All of the other example worksheets have the
RISKOptimizer settings pre-filled out and ready to be optimized.
NOTE: If you want to take a look at the Airlines model with all
optimization settings pre-filled out, open the example model
AIRYIELD.XLS
Chapter 3: RISKOptimizer: Step-by-Step
55
56
The RISKOptimizer Tour
Chapter 4: Example
Applications
Introduction ............................................................................................... 59
Budget Allocation ..................................................................................... 61
Capacity Planning..................................................................................... 63
Class Scheduler ......................................................................................... 65
Hedging with Futures .............................................................................. 67
Job Shop Scheduling................................................................................ 69
Portfolio Balancing................................................................................... 71
Portfolio Mix.............................................................................................. 75
Portfolio Risk............................................................................................. 77
Salesman Problem .................................................................................... 79
Yield Management ................................................................................... 81
Chapter 4: Example Applications
57
Chapter 4: Example Applications
58
Introduction
This chapter explains how RISKOptimizer can be used in a variety of
applications. These example applications may not include all of the
features you would want in your own models, and are most effective
as idea generators and templates. All examples illustrate how
RISKOptimizer finds solutions by relying on the relationships that
already exist in your worksheet, so it is important that your worksheet
model accurately portrays the problem you are trying to solve.
All Excel worksheet examples can be found within your RISKOPT
directory in a sub-directory called “EXAMPLES". They are listed
alphabetically in this chapter.
Each example comes with all RISKOptimizer settings pre-selected,
including the target cell, adjustable cells, solving methods and
constraints. You are encouraged to examine these dialog settings
before optimizing. By studying the formulas and experimenting with
different RISKOptimizer settings, you can get a better understanding
of how RISKOptimizer is used. The models also let you replace the
sample data with your own “user” data. If you decide to modify or
adapt these example sheets, you may wish to save them with a new
name to preserve the original examples for reference.
Chapter 4: Example Applications
59
60
Introduction
Budget Allocation
A senior executive wants to find the most effective way to distribute
funds among the various departments of the company to maximize
profit. Below is a model of a business and its projected profit for the
next year. The model estimates next year’s profit by examining the
annual budget and making assumptions about, for example, how
advertising affects sales. Uncertain sales estimates include probability
distributions to reflect ranges of possible values This is a simple
model, but it illustrates how you can set up any model and use
RISKOptimizer to feed inputs into it to find the best output.
How The Model
Works
Example file:
budget99.xls
Goal:
Allocate the annual budget among five
departments to maximize next year’s profits.
Solving method:
budget
Similar problems:
Allocate any scarce resource (such as labor,
money, gas, time) to entities that can use them
in different ways or with different
efficiencies.
The file “budget99.xls” models the effects of a company’s budget on
its future sales and profit. Cells C4:C8 (the variables) contain the
amounts to be spent on each of the five departments. These values
total the amount in cell C10, the total annual budget for the company.
This budget is set by the company and is unchangeable.
Chapter 4: Example Applications
61
Cells F6:F10 compute an estimate of the demand for the company’s
product next year, based on the advertising and marketing budgets.
The amount of actual sales is the minimum of the calculated demand
and the supply. The supply is dependent upon the money allocated
to the production and operations departments. The uncertain
estimates in the model are included in probability distributions used
in the sales estimate calculations in cells F6 to F10.
How To Solve It
Maximize the profit in cell I16 by using the “budget” solving method
to adjust the values in cells C4:C8. Set the independent ranges for
each of the adjustable cells for the budget for each department, to
keep RISKOptimizer from trying negative numbers, or numbers which
would not make suitable solutions (e.g., all advertising and no
production) for the departmental budget.
The “budget” solving method works like the “recipe” solving method,
in that it is trying to find the right “mix” of the chosen variables.
When you use the budget method, however, you add the constraint
that all variables must sum up to the same number as they did before
RISKOptimizer started optimizing.
62
Budget Allocation
Capacity Planning
This model uses RISKOptimizer to select the capacity level for a new
plant in order to maximize profits. In the model ZooCo is thinking of
marketing a new drug used to make hippos healthier. A standard
simulation model is used to generate the distribution of NPV for the
production of the new drug. However, it is necessary to decide on
what capacity of plant to build. What capacity level maximizes risk
adjusted NPV?
How The Model
Works
Example file:
capacity.xls
Goal:
Maximize the mean of the simulated distribution for
NPV by changing plant capacity.
Solving method:
recipe
Similar problems:
Business analyses combining traditional simulation
models with user-controlled decision variables.
At the beginning of the current year there are 1,000,000 hippos that
may use the product as shown in cell B11. Each hippo will use the
drug (or a competitor’s drug) at most once a year. The number of
hippos is forecasted to grow by an average of 5% per year, and we are
95% sure that the number of hippos will grow each year by between
3% and 7% (modeled using probability distributions in cells B11 to
Chapter 4: Example Applications
63
F11). We are not sure what use of the drug will be during year 1, but
our worst case guess is 20% use, most likely use is 40% and best case
use is 70% (modeled using probability distribution in cell B12). In later
years, we feel the fraction of hippos using our drug (or a competitor's)
will remain the same, but in the year after a competitor enters, we lose
20% of our share for each competitor who enters. It costs $3.50 to
build one unit of annual capacity and $0.30 per year to operate one
unit of capacity (whether or not we use the capacity to produce the
drug). Any capacity level between 100,000 and 500,000 units can be
built.
How To Solve It
64
Use the recipe solving method for cell G5. Maximize the simulated
mean of B21.
Capacity Planning
Class Scheduler
A university must assign 25 different classes to 6 pre-defined time
blocks. Since the schedule must be developed prior to student
registration, the actual number of students per class is uncertain. Each
class lasts exactly one time block. Normally, this would allow us to
treat the problem with the “grouping” solving method. However,
there are a number of constraints that must be met while the classes
are being scheduled. For example, biology and chemistry should not
occur at the same time so that pre-medical students can take both
classes in the same semester. To meet such constraints, we use the
“schedule” solving method instead. The “schedule” solving method
is like the “grouping” method, only with the constraint that certain
tasks must (or must not) occur before (or after or during) other tasks.
Example file:
classes.xls
Goal:
Assign 25 classes to 6 time periods to minimize the
mean of the simulated distribution for the number of
students who get squeezed out of their classes. Meet a
number of constraints regarding which classes can
meet when.
Solving method:
schedule
Similar problems:
Any scheduling problem where all tasks are the same
length and can be assigned to any of a number of
discrete time blocks. Also, any grouping problem
where constraints exist as to which groups certain
items can be assigned.
Chapter 4: Example Applications
65
How The Model
Works
The “classes.xls” file contains a model of a typical scheduling problem
where many constraints must be met. The range of possible values for
each class is given by the probability distributions entered in the
range D8:D32 labeled "Actual Size". Cells C8:C32 assign the 25 classes
to the 6 time blocks. There are only five classrooms available, so
assigning more than five classes to one time block means that at least
one of the classes cannot meet.
Cells L20:N28 contain the constraints; to the left of the constraints are
English descriptions of the constraints. You can use either the number
code or the english description as the constraint. The list of constraint
codes for scheduling problems can be found in more detail in the
“Solving Methods” section of Chapter 5: Complete Reference.
Each possible schedule is evaluated by calculating both a) the number
of classes which cannot meet, and b) the number of students who
cannot sit at their classes because the classrooms are full. This last
constraint keeps RISKOptimizer from scheduling all the large classes at
the same time. If only one or two large classes meet during a time
block, the larger classrooms can be used for them.
Cells J11:M11 uses the DCOUNT Excel function to count up how
many classes are assigned to each time block. Right below cells
J12:M12 computes how many classes did not get assigned a room for
that time block. All the classes that are without rooms are totaled in
cell L13.
If the number of seats required by a given class exceeds the number of
seats available, cells J15:M15 calculate by how much, and the total
number of students without seats is calculated in cell L16. In cell G9,
this total number of students without seats is added to the average
class size, and multiplied by the number of classes without rooms.
This way, we have one cell which combines all penalties such that a
lower number in this cell always indicates a better schedule.
How To Solve It
66
Minimize the mean of the simulated distribution for the penalties in G9
by changing cells C8:C32. Use the “schedule” solving method. When
this solving method is chosen, you will see a number of related
options appear in the lower “options” section of the dialog box. Set
the number of time blocks to 6, and set the constraints cells to
K17:M25.
Class Scheduler
Hedging with Futures
It is June 8, 2000. GlassCo needs to purchase 500,000 gallons of
heating oil on November 8, 2000. The current spot price of oil is $0.42
per gallon. Oil prices are assumed to follow a Lognormal random
variable with Mean = .08 and StdDev = .30. The risk free rate is 6%.
We are hedging the price risk inherent in our future oil purchase by
buying oil futures that expire on December 8, 2000. How many
futures should we buy?
How The Model
Works
Example file:
oil.xls
Goal:
Find the number of future contracts to buy to
protect against price changes of a future
purchase.
Solving method:
recipe
Similar problems:
Risk minimization models where the
objective is to minimize standard deviation of
the target
The model tries to insure that the cost of purchasing 210,000 gallons of
heating oil five months in the future is as predictable as possible by
using futures contracts to protect against price swings. The uncertain
factors in the model are the future spot price of oil (cell B13) and the
future Oil Futures price (cell B15).
Chapter 4: Example Applications
67
How To Solve It
68
The first thing we need to do is choose an adjustable cell. For this
model we want to adjust cell B12 - the # of future contracts "long" or
purchased - to minimize the standard deviation of total cost in cell B23.
The minimum number of contracts that can be purchased is 0 and the
maximum is 600,000.
Hedging with Futures
Job Shop Scheduling
A metalworking shop needs to find the best way to schedule a set of
jobs that can be broken down into steps that can be run on different
machines. Each job is composed of five tasks, and the tasks must be
completed in order. Each task must be done on a specific machine,
and takes an uncertain amount of time to complete. There are five
jobs and five machines.
Clicking the Draw Schedule button at the top of the sheet will redraw
the bar chart to show when each of the job tasks is scheduled to run.
Example file:
jobshop.xls
Goal:
Assign job pieces (tasks) to machines so total time for
all jobs to finish is minimized.
Solving method:
order
Similar problems:
Scheduling or project-management problems
How The Model
Works
The uncertain length of each task is described by probability
distributions in cells E11 to E35. Cell D5 computes the makespan, or
how much time elapses between the start of the first scheduled task
and the end of the last scheduled task. This total time is what we wish
to minimize. Cells G11:G35 hold the variables (the tasks) to be
shuffled to find the best assignment order. The equations on the sheet
figure out how soon each task can run on the machine that it needs.
How To Solve It
Select a set of adjustable cells G11:G35 and select the order solving
method. Minimize the mean of the simulation results for cell D5.
Chapter 4: Example Applications
69
70
Job Shop Scheduling
Portfolio Balancing
A broker has a list of 80 securities of different types that will be worth
a different and uncertain amount of money in the future. The broker
wants to group these securities into five packages (portfolios) that will
be as close to each other in total value as possible one year from now.
This is an example of a general class of problems called bin packing
problems. Packing the holds of a cargo ship so that each hold weighs
as much as the others is another example. If there are millions of
small items to be packaged into a few groups, such as grains of wheat
into ship holds, a roughly equal distribution can be estimated without
a big difference in weight. However, several dozen packages of
different weights and/or sizes can be packed in very different ways,
and efficient packing can improve the balance that would be found
manually.
Example file:
portbal.xls
Goal:
Break a list of securities up into five different
portfolios whose future values are as close as possible
to each other.
Solving method:
grouping
Similar
problems:
Create teams that have roughly equivalent collective
skills. Pack containers into holds of a ship so that the
weight is evenly distributed.
Chapter 4: Example Applications
71
How The Model
Works
The “portbal.xls” file models a typical grouping assignment. Column
A contains identification numbers to specific securities, and column B
identifies the class of each security (the worksheet SECURITIES gives
information on each class of security). Columns C, D and E give the
current dollar value of each security and the mean and standard
deviation of the return for the next year for the security (as
determined by the security's class). Column F calculates the value of
the security one year from now using a rate of return sampled from a
probability distribution that uses the shown mean and standard
deviation. Column G assigns each security to one of the five
portfolios. When setting a grouping or bin packing type of problem
and using the grouping solving method, you must be sure that before
you start RISKOptimizer each group (1-5) is represented in the current
scenario at least once.
Cells F6:F10 calculate the total value of each of the five portfolios.
This is done with database criteria offscreen (in column I) and
“DSUM()” formulas in cells F6:F10. Thus, cell F6, for example,
calculates DSUM of all the values in column B that have been
assigned to group 5 (in column C).
Cell F12 computes the standard deviation among the total portfolio
values using the “STDEV()” function. This provides a measure of
how close in total value to each other the portfolios are. The graph
shows the total value of each portfolio, with a reference line drawn at
the goal number where each portfolio would be if they were all even.
72
Portfolio Balancing
How To Solve It
Minimize the mean of the simulation results for cell F12 by adjusting
the cells in C5:C104. Use the “grouping” method and make sure the
values 1, 2, 3, 4, and 5 each appear at least once in column C.
The “grouping” solving method tells RISKOptimizer to arrange
variables into x groups, where x is the number of different values in
the adjustable cells at the start of an optimization.
Chapter 4: Example Applications
73
74
Portfolio Balancing
Portfolio Mix
A young couple has assets in many different types of investments,
each with its own yield, potential growth, and risk. Their goal is to
pick the combination of investments that maximizes total return while
keeping risk to an acceptable level.
Example file:
portmix.xls
The Goal:
Find the optimal mix of investments to maximize your
profit, given your current risk/return needs.
Solving method:
budget
How The Model
Works
This is a classic financial model which attempts to balance the risk of
loss against the return on investment. Each asset listed in column A
has an uncertain captial growth % and a fixed yield. Total return
sums the capital growth and yield. The objective is to maximize total
return while keeping the standard deviation of portfolio return less
than 9%.
How To Solve It
The total return in cell C18 reflects the sum of total capital growth and
total yield. We maximize the mean of the simulated distribution for
this cell. A hard simulation constraint is entered that specifies that the
standard deviation of cell C18 must be less than .09.
Chapter 4: Example Applications
75
76
Portfolio Mix
Portfolio Risk
An investor wants to determine the safest way to structure a portfolio
from several investments. Historical data has shown that the returns
on the investments are correlated. The objective is to divide the total
portfolio among the three available investments in order to achieve
the desired 12% return while minimizing the risk, or standard
deviation, of the portfolio return.
How The Model
Works
Example file:
corrmat.xls
Goal:
Minimize the standard deviation of portfolio return
while still achieving the desired return.
Solving method:
budget
Similar problems:
any risk minimization model.
Each of three available investments has an uncertain return that is
modeled using the probability distributions in cells E3 to E5. To
correlate the returns of the three investments the RiskCorrmat
function is used with the correlation matrix located in J9:L12.
RISKOptimizer will adjust the percentage of the portfolio allocated to
each investment. The "budget" solving method is used to insure that
the total % allocated always sums to 100%.
The objective is to minimize the standard deviation of total portfolio
return, while meeting the constraint that total return is greater than or
equal to 12%.
Chapter 4: Example Applications
77
How To Solve It
78
Minimize the standard deviation of simulation results for cell G6.
Enter a hard simulation constraint that the mean of the simulation
results for cell G6 needs to be greater than .12.
Portfolio Risk
Salesman Problem
A salesman is required to visit every city in the assigned territory
once. What is the route with the shortest travel time possible that
visits every city? This is a classic optimization problem with one twist
- the travel time between each city is uncertain - and one that is
extremely difficult for conventional techniques to solve if there are a
large (>50) number of cities involved.
A similar problem might be finding the best order to perform tasks in
a factory. For example, it might be much easier to apply black paint
after applying white paint than the other way around. In
RISKOptimizer, these types of problems can be best solved by the order
solving method.
How The Model
Works
Example file:
salesman.xls
Goal:
Find the route with the shortest travel time among n
cities that visits each city once.
Solving method:
order
Similar problems:
Plan the drilling of circuit board holes in the fastest
way.
The file “salesman.xls” calculates the travel time of a trip to various
cities by looking up the travel times between cities in a table. The
travel times between any two cities is described by a probability
Chapter 4: Example Applications
79
distribution (there are 200 probability distributions in the table).
Column A contains identifying numbers for specific cities. Column B
contains the names that those numbers represent (with a lookup
function). The order in which the cities (and their numbers) appear
from top to bottom represents the order in which the cities are visited.
For example, if you entered a “9” into cell A3, then Ottawa would be
the first city visited. If A4 contained “6” (Halifax), then Halifax would
be the second city visited.
The travel times between cities are represented by probability
distributions in the table beginning at C25. These distributions
reference the table beginning at C48 that contains the actual driving
distance between the cities. The distances in the table are symmetric
(distance from A to B is the same as from B to A). However, more
realistic models may include non-symmetric distances to represent
greater difficulty of traveling in one direction (because of tolls,
available transportation, headwinds, slope, etc.).
A function now must be used to calculate the length of the route
between these cities. The total route length will be stored in cell G2,
the cell we wish to optimize. To do this, we use the “RouteLength”
function. This is a custom VBA function in Salesman.xls.
How To Solve It
Minimize the value in cell G2 by adjusting the cells in A3:A22. Use
the “order” method and make sure the values 1 through 20 exist in the
adjustable cells (A3:A22) before you start optimizing.
The “order” solving method tells RISKOptimizer to rearrange the
chosen variables, trying different permutations of existing variables.
80
Salesman Problem
Yield Management
This is a yield management model which identifies the optimal
number of full and discount fare seats to sell on a given flight. It also
identifies the optimal number of reservations to accept in excess of the
number of available seats – the classic “overbooking” problem.
How The Model
Works
Example file:
airyield.xls
Goal:
Identify the maximum number of
reservations to accept in different fare
categories to maximize profit.
Solving method:
recipe
Similar problems:
Any yield management problem where a
variety of different prices are offered for the
same product
The “airyield.xls” file is a very simple model which illustrates
RISKOptimizer’s use for yield management. Probability distributions
are assigned to a variety of uncertain factors in the model, including
the Demand for Full Fare Reservations (in cell C8), the % No Shows
- Full Fare Reservations (in cell C7), the % No Shows - Discount
Fare Reservations(in cell C11), the Demand for Discount Fare
Reservations(in cell C12), and the Cost of Bumping (in cell C23).
Chapter 4: Example Applications
81
The gross profit from the flight is calculated by calculating the total
revenue from reservations in each fare category, less the cost of
bumping passengers from an overbooked flight.
How To Solve It
82
In this model, the variables to be adjusted are located in cells C14 and
C15. These cells contain the values for the maximum number of
reservations accepted and the percentage of those reservations that
will be allocated to full fare seats. "Profit must always be >0" is an
iteration constraint, while "Standard deviation of the simulation
results for profit must be <400" is a simulation constraint. The
objective is to maximize the mean of the simulated distribution for
profit while minimizing risk as specified by the entered constraints.
Yield Management
Chapter 5: Complete
Reference
RISKOptimizer Settings Dialog ............................................................. 87
Find the........................................................................................................ 88
Of the ........................................................................................................... 88
Selecting the Statistic to Minimize or Maximize............................ 89
By Adjusting the Cells ............................................................................... 90
Add - Adding Groups of Adjustable Cells.................................... 90
How to Group Adjustable Cells....................................................... 90
Delete - deleting groups of adjustable cells.................................... 91
Edit - editing groups of adjustable cells.......................................... 91
The Adjustable Cells Dialog ..................................................................... 91
Solving Methods......................................................................................... 92
Recipe Solving method...................................................................... 92
Order Solving Method ...................................................................... 93
Grouping Solving Method ................................................................ 94
Budget Solving Method .................................................................... 95
Project Solving Method ..................................................................... 96
Schedule Solving Method ................................................................. 97
Adjust the Cells ........................................................................................ 100
Cell Range ......................................................................................... 100
Add Button ....................................................................................... 101
Delete Button .................................................................................... 101
Use The Options ....................................................................................... 102
Overview of Crossover and Mutation Rate.................................. 102
Crossover .......................................................................................... 102
Mutation Rate ................................................................................... 103
Auto-Mutation.................................................................................. 104
# Time Blocks and Constraint Cells............................................... 104
Preceding Tasks................................................................................ 104
Operators................................................................................................... 104
Overview of Genetic Operators ..................................................... 104
Available Operators......................................................................... 105
Chapter 5: Complete Reference
83
Subject to The Constraints....................................................................... 106
Add - Adding Constraints .............................................................. 106
Types of Constraints ........................................................................ 107
Iteration vs. Simulation Constraints .............................................. 107
Simulation Constraints .................................................................... 108
Simple Range of Values and Excel Formula Constraints............ 109
Soft Constraints ................................................................................ 109
Entering a Penalty Function ........................................................... 110
Viewing the Effects of an Entered Penalty Function ................... 110
Viewing the Penalties Applied....................................................... 111
Implementing Soft Constraints in Worksheet Formulas ............ 111
Deleting Constraints ........................................................................ 111
Editing Constraints .......................................................................... 111
Options....................................................................................................... 112
Population Size................................................................................. 112
General Options ............................................................................... 113
Update Display................................................................................. 114
Random Number Seed .................................................................... 114
Optimization Stopping Conditions................................................ 115
Simulation Stopping Conditions.................................................... 116
Tolerance Option.............................................................................. 117
Macros........................................................................................................ 118
The Macros Dialog ........................................................................... 118
Sampling.................................................................................................... 120
Simulation Sampling Type ............................................................. 120
Standard Recalc................................................................................ 120
RISKOptimizer Toolbar ......................................................................... 123
Run..................................................................................................... 123
The Status Bar................................................................................... 123
Pause.................................................................................................. 123
Stop .................................................................................................... 124
Best Values Calculated So Far ........................................................ 124
Original Values................................................................................. 124
Last Calculated Values .................................................................... 124
Stop .................................................................................................... 125
Continue ............................................................................................ 125
Generate Optimization Summary Worksheet.............................. 125
Restore Dialog .................................................................................. 126
RISKOptimizer Watcher ........................................................................ 127
RISKOptimizer Watcher Toolbar............................................................. 128
Population Settings button ............................................................. 128
Progress Graph button .................................................................... 129
Axis Scaling....................................................................................... 129
84
Color Table button .......................................................................... 130
Bar Graph button ............................................................................. 131
Population Table button.................................................................. 131
Population Summary button .......................................................... 132
Optimization Log............................................................................. 133
RISKOptimizer Watcher - Menu Items ............................................... 135
Population Menu...................................................................................... 135
Start, Pause and Stop Optimization .............................................. 135
Settings .............................................................................................. 135
Options .............................................................................................. 135
Create Menu.............................................................................................. 136
Window Menu.......................................................................................... 136
Stay On Top ...................................................................................... 136
Cascade and Tile .............................................................................. 136
Chapter 5: Complete Reference
85
Chapter 5: Complete Reference
86
RISKOptimizer Settings Dialog
The RISKOptimizer Settings Dialog is shown when you click the
Settings icon on the RISKOptimizer toolbar :
The RISKOptimizer Settings Dialog.
The RISKOptimizer Settings Dialog is used to specify or describe an
optimization problem to RISKOptimizer. This dialog starts empty with
each new Excel workbook, but saves its information with each
workbook. That means that when the sheet is opened again, it will be
filled out the same way. Each component of the dialog is described in
this section.
Chapter 5: Complete Reference
87
Find the
The Find the option determines what kind of answer RISKOptimizer is
to search for. If Minimum is selected, RISKOptimizer will look for
variable values that produce the smallest possible value for the
selected statistic of the simulation results for the target cell (all the
way down to -1e300). If Maximum is selected, RISKOptimizer will
search for the variable values that result in the largest possible value
for the selected statistic (up to +1e300).
If Closest Value To is selected, RISKOptimizer will search for variable
values that produce a value for the selected statistic as close as
possible to the value you specify. When RISKOptimizer finds a
solution which produces this result, it will automatically stop. For
example, if you specify that RISKOptimizer should find the mean of
the distribution of simulation results that is closest to 14,
RISKOptimizer might find scenarios that result in a mean such as 13.7
or 14.5. Note that 13.7 is closer to 14 than 14.5; RISKOptimizer does
not care whether the statistic's value is greater or less than the value
you specify, it only looks at how close the value is.
Of the
The Of the section is where you specify the statistic of the simulation
results for your target cell that you wish to minimize, maximize, or set
to a specific value. The actual statistic you wish to minimize,
maximize, or set to a specific value is selected from the dropdown list.
The target cell - entered in the "of cell" text box - contains the output of
your model. A distribution of possible values for this target cell will
be generated (via simulation) for each "trial solution" that
RISKOptimizer generates (i.e., each combination of possible adjustable
cell values). The target cell should contain a formula which depends
(either directly or through a series of calculations) on the adjustable
cells. This formula can be made with standard Excel formulas such as
SUM() or user-defined VBA macro functions. By using VBA macro
functions you can have RISKOptimizer evaluate models that are very
complex.
As RISKOptimizer searches for a solution it uses the statistic for the
simulation results of the target cell as a rating or “fitness function” to
88
RISKOptimizer Settings Dialog
evaluate how good each possible scenario is, and to determine which
variable values should continue cross-breeding, and which should
die. In biological evolution, death is the “fitness function” that
determines what genes continue to flourish throughout the
population. When you build your model, your target cell must reflect
the fitness or “goodness” of any given scenario, so as RISKOptimizer
calculates the possibilities, it can accurately measure its progress.
Selecting the
Statistic to
Minimize or
Maximize
To select the statistic for the target cell which you wish to minimize,
maximize, or set to a specific value, simply select the desired statistic
from the displayed dropdown list. If you wish to select a Percentile or
Target for the target cell's distribution, simply:
1) Select Percentile(x) or Target(x).
2) For Percentile(x), replace the "x" with a value between 0 and 1.
The value that will be to minimized or maximized will be the
value associated with the entered percentile; i.e., Percentile(.99)
will cause RISKOptimizer to identify the combination of adjustable
cell values that minimizes or maximizes the 99th percentile of the
distribution of simulation results for the target cell.
3) For Target(x), replace the "x" with an actual value. The value
that will be to minimized or maximized will be the cumulative
probability associated with the entered value; i.e., Target(1000)
will cause RISKOptimizer to identify the combination of adjustable
cell values that minimizes or maximizes the cumulative
probability of the value 1000 (as calculated using the distribution
of simulation results for the target cell).
Chapter 5: Complete Reference
89
By Adjusting the Cells
The By Adjusting the Cells listbox displays each range which contains
the cells or values that RISKOptimizer can adjust, along with the
description entered for those cells. Each set of adjustable cells is listed
in a horizontal row.
Because the adjustable cells contain the variables of the problem, you
must define at least one group of adjustable cells to use
RISKOptimizer. Most problems will be described with only one group
of adjustable cells, but more complex problems may require different
blocks of variables to be solved with different solving methods
simultaneously. This unique architecture allows for highly complex
problems to be easily built up from many groups of adjustable cells.
Add - Adding
Groups of
Adjustable Cells
Define your adjustable cells by clicking on the “Add” button next to
the Adjustable Cells list box. The RISKOptimizer Adjustable Cells
Dialog will appear in which you can specify which cells are to be
adjusted by RISKOptimizer, and how they are to be adjusted. Once
completed, this information will be displayed in the RISKOptimizer
Settings Dialog. You may continue to define more groups of
adjustable cells by clicking on the “Add” button. All groups will
appear in the variables window of the RISKOptimizer Settings Dialog,
top to bottom, in the order they were created.
How to Group
Adjustable Cells
Each group of adjustable cells can contain multiple cell ranges. This
allows you to build a "hierarchy" of groups of cell ranges that are
related. Within each group, each cell range can have its own Min-Max
range constraint.
NOTE: When creating multiple groups of adjustable cells, check to be
sure that no spreadsheet cell is included in several different groups of
adjustable cells. Each group of adjustable cells should contain unique
adjustable cells because the values in the first group of adjustable
cells would be ignored and overwritten by the values in the second
group of adjustable cells. If you think a problem needs to be
represented by more than one solving method, consider how to break
up the variables into two or more groups.
90
RISKOptimizer Settings Dialog
Delete - deleting
groups of
adjustable cells
Edit - editing
groups of
adjustable cells
The Delete button in the By Adjusting the Cells section of the
RISKOptimizer Settings Dialog deletes the currently selected group of
adjustable cells. You must first click on the group of adjustable cells
(set of variables) that you wish to delete, so that it is highlighted
(white type on black background). You may only delete one group of
adjustable cells at a time.
If at any time you wish to examine or change the settings for a
particular set of variables, you will want to use the Edit button. To
use the Edit button, you must first click on the group of adjustable
cells (set of variables) that you wish to examine. You may only select
and edit one group of adjustable cells at a time.
Clicking the Edit button will bring up the RISKOptimizer Adjustable
Cells Dialog for the selected cells, allowing you to change the
adjustable cells, the solving method used on them, and any options
relating to those variables.
The Adjustable Cells Dialog
The Adjustable Cells Dialog is displayed from the “Add” and “Edit”
buttons in the RISKOptimizer Settings Dialog.
This dialog asks users to select a solving method, adjustable cells, then
specify details about how those cells should be treated. The Cell Range
field must contain an absolute reference to a single, contiguous block
of cells (e.g., $B$4:$D$10). If you change the solving method used,
different solving method options will appear in the Use the Options
section on the lower portion of the dialog.
Chapter 5: Complete Reference
91
Solving Methods
When you select a range of cells to be adjusted by RISKOptimizer, you
are also asked to select what “solving method” you wish to apply
when adjusting those adjustable cells. Each solving method is, in
essence, a completely different genetic algorithm, with its own
optimized selection, crossover and mutation routines. Each solving
method juggles the values of your variables a different way.
The “recipe” solving method, for example, treats each variable
selected as an ingredient in a recipe; each variable’s value can be
changed independently of the others’. In contrast, the “order” solving
method swaps values between the adjustable cells, reordering the
values that were originally there.
Each time you add adjustable cells to RISKOptimizer through the
Adjustable Cells Dialog, you must specify which solving method
should be used to treat those cells. Once you have chosen a solving
method, RISKOptimizer will present you with related options for that
solving method.
There are six solving methods that come with RISKOptimizer. Three of
the solving methods (recipe, order, and grouping) use entirely
different algorithms. The other three are descendants of the first three,
adding additional constraints.
The following section describes the function of each solving method.
To get a better understanding of how each solving method is used,
you are also encouraged to explore the example files included on your
disk (see Chapter 4: Example Applications).
Recipe Solving
method
92
The “recipe” solving method is the most simple and most popular
type of solving method. Use recipe whenever the set of variables that
are to be adjusted can be varied independently of one another. Think
of each variable as the amount of an ingredient in a cake; when you
use the “recipe” solving method, you are telling RISKOptimizer to
generate numbers for those variables in an effort to find the best mix.
The only constraints you place on recipe variables is to set the range
(the highest and lowest value) that those values must fall between.
Set these values in the Min and Max fields in the Adjustable Cells
dialog (e.g. 1 to 100), and also indicate whether or not RISKOptimizer
should be trying integers (1, 2, 7) or real numbers (1.4230024,
63.72442).
Below are examples of a set of variable values as they might be in a
sheet before RISKOptimizer is called, and what two new scenarios
might look like after using the recipe solving method.
Order Solving
Method
Original Set of
Variable Values
One Set of Possible
Recipe Values
Another Set of
Possible Recipe Values
23.472
15.344
37.452
145
101
190
9
32.44
7.073
65,664
14,021
93,572
The “order” solving method is the second most popular type, after
“recipe”. An order is a permutation of a list of items, where you are
trying to find the best way to arrange a set of given values. Unlike
“recipe” and “budget” solving methods, which ask RISKOptimizer to
generate values for the chosen variables, this solving method asks
RISKOptimizer to use the existing values in your model.
An order could represent the order in which to perform a set of tasks.
For example, you might wish to find the order in which to accomplish
five tasks, numbered 1,2,3,4, and 5. The “order” solving method
would scramble those values, so one scenario might be 3,5,2,4,1.
Because RISKOptimizer is just trying variable values from your initial
sheet, there is no Min - Max range entered for adjustable cells when
the Order solving method is used.
There are no Min and Max options when using the Order method.
Chapter 5: Complete Reference
93
The original values to be scrambled must exist in the adjustable cells
before RISKOptimizer starts optimizing. Any numerical values can be
used (for example, 10004, 10006, 10008, etc.).
Below are examples of a set of variable values as they might be in a
sheet before RISKOptimizer is called, and what two new scenarios
might look like after using the order solving method.
Grouping
Solving Method
Original Set of
Variable Values
One Set of Possible
Order Values
Another Set of
Possible Order Values
23.472
145
65,664
145
23.472
9
9
65,664
145
65,664
9
23.472
The “grouping” solving method should be used whenever your
problem involves multiple variables to be grouped together in sets.
The number of different groups that RISKOptimizer creates will be
equal to the number of unique values present in the adjustable cells at
the start of an optimization. Therefore, when you build a model of
your system, be sure that each group is represented at least once.
For example, suppose a range of 50 cells contains only the values 2,
3.5, and 17. When you select the 50 cells and adjust the values using
the “grouping” solving method, RISKOptimizer will assign each of the
fifty cells to one of the three groups, 2, 3.5 or 17. All of the groups are
represented by at least one of the adjustable cells; just like tossing each
of the 50 variables in one of several “bins”, and making sure there is at
least one variable in each bin. Another example would be assigning
1s, and 0s, and -1s to a trading system to indicate buy, sell and hold
positions. Like the “order” solving method, RISKOptimizer is
arranging existing values, so there is no min-max range or integers
option to define.
NOTE: When using the “grouping” solving method, do not leave any
cells blank, unless you would like 0.0 to be considered one of the
groups.
You may realize that the “grouping” solving method could be
approximated by using the “recipe” solving method with the integers
option “on” and the ranges set from 1 to 3 (or whatever number of
groups there are). The difference lies in the way a recipe and a
grouping perform their search. Their selection, mutation and crossover
routines are different; a grouping is much more concerned with the
94
values of all the variables, because it can swap a set of variables from
one group with a set of variables from another group.
Below are examples of a set of variable values as they might be in a
sheet before RISKOptimizer is called, and what two new scenarios
might look like after using the grouping solving method.
Budget Solving
Method
Original Set of
Variable Values
One Set of Possible
Grouping Values
Another Set of
Possible Grouping
Values
6
6
8
7
6
7
8
8
6
8
7
7
A “budget” is similar to a “recipe” except that all of the variables’
values must total to a certain number. That number is the total of the
variables’ values at the time an optimization is started.
For example, you might want to find the best way to distribute an
annual budget among a number of departments. The “budget”
solving method will take the total of the current values for the
departments, and use that sum as the total budget to be optimally
distributed. Below are examples of what two new scenarios might
look like after using the budget solving method.
Original
Set of Budget Values
One Set of
Possible Budget
Values
Another Set of
Possible Budget
Values
200
93.1
223.5
3.5
30
0
10
100
-67
10
.4
67
Many values are being tried, but the sum of all values remains 223.5.
Chapter 5: Complete Reference
95
Project Solving
Method
The “project” solving method is similar to the “order” solving method
except that certain items (tasks) must precede others. The “project”
solving method can be used in project management to rearrange the
order in which tasks are carried out, but the order will always meet
the precedence constraints.
A problem modelled using the Project solving method will be much
easier to work with and understand if the adjustable cells containing
the task order are in a single column, rather than in a row. This is
because the solving method expects the preceding tasks cells to be
arranged vertically rather than horizontally, and it will be easier to
examine your worksheet if the adjustable cells are also vertical.
After you have specified the location of the adjustable cells, you
should specify the location of the preceding tasks cells in the Use the
Options section of the dialog. This is a table of cells that describes
which tasks must be preceded by which other tasks. The solving
method uses this table to rearrange the order of variables in a scenario
until the precedence constraints are met. There should be one row in
the preceding tasks range for each task in the adjustable cells. Starting
in the first column of the preceding tasks range, the identifying
number of each task on which that row’s task depends should be
listed in separate columns.
Example of how to set up precedents for Project solving method.
The precedence tasks range should be specified as being n rows by m
columns, where n is the number of tasks in the project (adjustable
cells), and m is the largest number of preceding tasks that any one task
has.
96
Below are examples of a set of variable values as they might be in a
sheet before RISKOptimizer is called, and what two new scenarios
might look like after using the Project solving method, with the
constraint that 2 must always come after 1, and 4 must always come
after 2.
Schedule
Solving Method
Original Set of
Variable Values
One Set of Possible
Project Values
Another Set of
Possible Project
Values
1
1
1
2
3
2
3
2
4
4
4
3
A schedule is similar to a grouping; it is an assignment of tasks to
times. Each task is assumed to take the same amount of time, much as
classes at a school are all of the same length. Unlike a grouping,
however, the Adjustable Cells Dialog for the “schedule” solving
method lets you directly specify the number of time blocks (or groups)
to be used. Notice when you select the “schedule” method, several
related options appear in the lower portion of the dialog box.
In the Use the Options section, you will notice that you can also have a
constraint cell range attached to it. This range can be of any length,
but must be exactly three columns wide. Eight kinds of constraints
are recognized:
1) (with) The tasks in the 1st & 3rd columns must occur in the same time
block.
2) (not with) The tasks in the 1st & 3rd columns must not occur in the
same time block.
3) (before) The task in the 1st column must occur before the task in the 3rd
column.
4) (at) The task in the 1st column must occur in the time block in the 3rd
column.
5) (not after) The task in 1st column must occur at the same time or before
the task in the 3rd column.
Chapter 5: Complete Reference
97
6) (not before) The task in 1st column must occur at the same time or after
the task in the 3rd column.
7) (not at) The task in the 1st column must not occur in the time block in
the 3rd column.
8) (after) The task in the 1st column must occur after the task in the 3rd
column.
Either a numeric code (1 through 8) or the english description (after,
not at, etc.) can be entered for a constraint. All of the constraints
specified in your problem will be met. To create constraints, find an
empty space on your worksheet and create a table where the left and
right columns represent tasks, and the middle column represents the
type of constraints. A number from 1 to 8 represents the kind of
constraint listed above. The cells in the constraint range must have
the constraint data in them before you start optimizing.
This Task
Constraint
This Task
5
4
2
12
2
8
2
3
1
7
1
5
6
2
4
9
3
1
Below are examples of a set of variable values as they might be in a
sheet before RISKOptimizer is called, and what two new scenarios
might look like after using the Schedule solving method.
98
Original Set of
Variable Values
One Set of Possible
Schedule Values
Another Set of
Possible Schedule
Values
1
1
1
2
1
3
3
3
1
1
1
2
2
2
2
3
3
2
NOTE: When you select the schedule solving method, integers starting
from 1 are always used (1,2,3...), regardless of the original values in
the adjustable cells.
Chapter 5: Complete Reference
99
Adjust the Cells
The Adjust the Cells section of the Adjustable Cells dialog allows the
entry of cell ranges to be adjusted using the selected solving method.
The options in this section will change depending on the solving
method selected.
Cell Range
The reference for the cells to be adjusted is entered in the Cell Range
field. This reference can be entered by selecting the region in the
spreadsheet with the mouse, entering a range name or typing in a
valid Excel reference such as Sheet1!A1:B8. The Cell Range field
appears for all solving methods. For recipe and budget methods,
however, Min, Max and Integers options are shown also to allow the
entry of a range for the adjustable cells.
♦
Min and Max - After you have specified the location of the
adjustable cells, the Min and Max entries set the range of
acceptable values for each adjustable cell. By default, each
adjustable cell takes on a real-number (double-precision floating
point) value between -infinity and +infinity.
Range settings are constraints that are strictly enforced.
RISKOptimizer will not allow any variable to take on a value
outside the set ranges. You are encouraged to set more specific
ranges for your variables whenever possible to improve
RISKOptimizer’s performance. For example, you may know that
the number cannot be a negative, or that RISKOptimizer should
only try values between 50 and 70 for a given variable.
NOTE: By assigning tight ranges to your variables, you can limit
the scope of the search, and speed up RISKOptimizer’s
convergence on a solution. But be careful not to limit the ranges
of your variables too tightly; this may prevent RISKOptimizer
from finding optimal solutions.
100
♦
Integers - The Integers checkbox allows you to specify that
RISKOptimizer should treat all of the variables in the specified
range as integers (e.g., 22), rather than as real numbers (e.g.,
22.395). This option is only available when using the “recipe” and
“budget” solving methods. The default is to treat the variables as
real numbers.
Be sure to turn on the integers setting if your model uses variables
to lookup items from tables (HLOOKUP(), VLOOKUP(), INDEX(),
OFFSET(), etc.). Note that the integers setting affects all of the
variables in the selected range. If you want to treat some of your
variables as reals and some as integers, you can create two groups
of adjustable cells instead of one, and treat one block as integers
and the other block as reals. Simply “Add” a recipe group of
adjustable cells, and leave the integers box unchecked. Next,
“Add” another cell range, this time turning on the integers setting
and selecting only the integer adjustable cells.
Add Button
The Add button adds the new cell range definition to the displayed
list box, and you may continue selecting and adding additional
variables and their ranges. Each added cell range will use the
specified solving method.
Delete Button
The Delete button deletes the selected cell range.
Chapter 5: Complete Reference
101
Use The Options
A variety of options are available which affect how RISKOptimizer
generates values for each adjustable cell range you enter. The options
available change based on the solving method selected. The available
options include:
Overview of
Crossover and
Mutation Rate
♦
Crossover and Mutation Rate - available for all solving methods
♦
# Time Blocks and Constraint Cells - schedule solving method
only
♦
Preceding Tasks - project solving method only
One of the most difficult problems with searching for optimal
solutions, when your problem has seemingly endless possibilities, is in
determining where to focus your energy. In other words, how much
computational time should be devoted to looking in new areas of the
“solution space”, and how much time should be devoted to finetuning the solutions in our population that have already proven to be
pretty good?
A big part of the genetic algorithm success has been attributed to its
ability to preserve this balance inherently. The structure of the GA
allows good solutions to “breed”, but also keeps “less fit” organisms
around to maintain diversity in the hopes that maybe a latent “gene”
will prove important to the final solution.
Crossover and Mutation are two parameters that affect the scope of the
search, and RISKOptimizer allows users to change these parameters
before, and also during the evolutionary process. This way, a
knowledgeable user can help out the GA by deciding where it should
focus its energy. For most purposes, the default crossover and
mutation settings (.5 and .1 respectively) do not need adjustment. In
the event that you wish to fine-tune the algorithm to your problem,
conduct comparative studies, or just to experiment, here is a brief
introduction to these two parameters:
Crossover
102
The crossover rate can be set to between 0.01 and 1.0, and reflects the
likelihood that future scenarios or “organisms” will contain a mix of
information from the previous generation of parent organisms. This
rate can be changed by experienced users to fine-tune RISKOptimizer’s
performance on complex problems.
In other words, a rate of 0.5 means that an offspring organism will
contain roughly 50% of its variable values from one parent and the
remaining values from the other parent. A rate of 0.9 means that
roughly 90% of an offspring organism’s values will come from the
first parent and 10% will come from the second parent. A Crossover
rate of 1 means that no crossover will occur, so only clones of the
parents will be evaluated.
The default rate used by RISKOptimizer is 0.5. Once RISKOptimizer
has started solving a problem, you can change the crossover rate by
using the RISKOptimizer Watcher program (see RISKOptimizer Watcher
section in this chapter).
Mutation Rate
The mutation rate can be set to between 0.0 and 1.0, and reflects the
likelihood that future scenarios will contain some random values. A
higher mutation rate simply means that more mutations or random
“gene” values will be introduced into the population. Because
mutation occurs after crossover, setting the mutation rate to 1 (100%
random values) will effectively prevent the crossover from having any
effect, and RISKOptimizer will generate totally random scenarios.
If all the data of the optimal solution was somewhere in the
population, then the crossover operator alone would be enough to
eventually piece together the solution. Mutation has proven to be a
powerful force in the biological world for many of the same reasons
that it is needed in a genetic algorithm: it is vital to maintaining a
diverse population of individual organisms, thereby preventing the
population from becoming too rigid, and unable to adapt to a
dynamic environment. As in a genetic algorithm, it is often the
genetic mutations in animals which eventually lead to the
development of critical new functions.
For most purposes, the default mutation setting does not need
adjustment, but can, however, be changed by experienced users to
fine-tune RISKOptimizer’s performance on complex problems. The
user may wish to boost the mutation rate if RISKOptimizer’s
population is fairly homogenous, and no new solutions have been
found in the last several hundred trials. Typical setting changes are
from .06 to .2. Once RISKOptimizer has started solving a problem, you
can change the mutation rate dynamically by using the RISKOptimizer
Watcher’s Population Settings command (see RISKOptimizer Watcher
section later in this chapter).
Chapter 5: Complete Reference
103
Auto-Mutation
By selecting Auto from the drop down list in the Mutation rate field,
auto-mutation rate adjustment is selected. Auto-mutation rate
adjustment allows RISKOptimizer to increase the mutation rate
automatically when an organism "ages" significantly; that is, it has
remained in place over an extended number of trials. For many
models, especially where the optimal mutation rate is not known,
selecting Auto can give better results faster.
# Time Blocks
and Constraint
Cells
For more information on these options, see the Schedule Solving
method in the Solving Methods section of this chapter.
Preceding Tasks
For more information on these options, see the Project Solving method
in the Solving Methods section of this chapter.
Operators
RISKOptimizer includes selectable genetic operators. Clicking the
Operators button in the Adjustable Cells dialog allows you to select a
specific genetic operator (such as heuristic crossover or boundary
mutation) to be used when generating possible values for a set of
adjustable cells. In addition, you can have RISKOptimizer
automatically test all available operators and identify the best
performing one for your problem.
Overview of
Genetic
Operators
104
Genetic algorithms use genetic operators to create new members of
the population from current members. Two of the types of genetic
operators RISKOptimizer employs are mutation and crossover. The
mutation operator determines if random changes in “genes”
(variables) will occur and how they occur. The crossover operator
determines how pairs of members in a population swap genes to
produce “offspring” that may be better answers than either of their
“parents”.
Available
Operators
RISKOptimizer includes the following specialized genetic operators:
♦
Linear Operators – Designed to solve problems where the optimal
solution lies on the boundary of the search space defined by the
constraints. This mutation and crossover operator pair is well
suited for solving linear optimization problems.
♦
Boundary Mutation – Designed to quickly optimize variables that
affect the result in a monotonic fashion and can be set to the
extremes of their range without violating constraints.
♦
Cauchy Mutation – Designed to produce small changes in
variables most of the time, but can occasionally generate large
changes.
♦
Non-uniform Mutation – Produces smaller and smaller
mutations as more trials are calculated. This allows
RISKOptimizer to “fine tune” answers.
♦
Arithmetic Crossover – Creates new offspring by arithmetically
combining the two parents (as opposed to swapping genes).
♦
Heuristic Crossover – Uses values produced by the parents to
determine how the offspring is produced. Searches in the most
promising direction and provides fine local tuning.
Depending on the type of optimization problem, different
combinations of mutation and crossover operators may produce better
results than others. In the Genetic Operators dialog box, any number
of operators may be selected. When multiple selections are made,
RISKOptimizer will test valid combinations of the selected operators to
identify the best performing ones for your model. After a run, the
Optimization summary worksheet ranks each of the selected operators by
their performance during the run. For subsequent runs of the same
model, selecting just the top performing operators may lead to faster,
better performing optimizations.
Chapter 5: Complete Reference
105
Subject to The Constraints
RISKOptimizer allows you to enter constraints, or conditions that must
be met for a solution to be valid.
Constraints you have entered are shown in the Subject to the
Constraints list box. By clicking the Hard, Soft, Range or All buttons
you can select the type of constraints shown in the listbox.
Add - Adding
Constraints
106
Clicking the Add button next to the Constraints list box displays the
Constraint dialog box where constraints are entered. Using this
dialog box the type of constraint desired, along with its description,
type, format and parameters can be entered.
Types of
Constraints
Iteration vs.
Simulation
Constraints
Three types of constraints can be specified in RISKOptimizer:
♦
Hard, or conditions that must be met for a solution to be valid
(i.e., a hard constraint could be C10<=A4; in this case, if a solution
generates a value for C10 that is greater than the value of cell A4,
the solution will be thrown out).
♦
Soft, or conditions which we would like to be met as much as
possible, but which we may be willing to compromise for a big
improvement in fitness or target cell result. (i.e., a soft constraint
could be C10<100; however, C10 could go over 100, but when
that happened the calculated value for the target cell would be
decreased based on the penalty function you have entered)
♦
Range, or minimum and maximum possible values for each of the
adjustable cell ranges you have entered (i.e., a range constraint
could be 10<=C20<=100; where C20 is an adjustable cell which
can be changed to different values in the range between 10 and
100). These constraints are entered when you select adjustable
cell ranges in the Adjustable Cells dialog box.
Hard constraints may be evaluated 1) each iteration of a simulation
run for a trial solution (“an iteration constraint”, or 2) at the end of
the simulation run for a trial solution (“an simulation constraint”).
♦
An iteration constraint is a constraint that is evaluated each
iteration of a simulation run for a given trial solution. If an
iteration results in values which violate the hard constraint, the
simulation is stopped (and the trial solution rejected) and the next
trial solution and its associated simulation begins.
♦
A simulation constraint is specified in terms of a simulation
statistic for a spreadsheet cell; for example the Mean of A11>1000.
In this case, the constraint is evaluated at the end of a simulation.
A simulation constraint, as opposed to an iteration constraint, will
never cause a simulation to be stopped prior to completion.
Chapter 5: Complete Reference
107
Simulation
Constraints
A simulation constraint is specified in terms of a simulation statistic for
a spreadsheet cell; for example the Mean of A11>1000. The statistic to
use in the constraint is selected from the available dropdown list:
When a simulation constraint is used, a distribution of possible values
for the Cell Range is generated during each trial solution's simulation.
At the end of each simulation, the constraint is checked to see if it has
been met. If the simulation constraint is a hard constraint and the
constraint is not met, the trial solution is discarded. If the constraint is
a soft constraint and the constraint is not met, the target cell's statistic
that is being minimized or maximized is penalized according to the
entered penalty function (see the next section Soft Constraints).
108
Simple Range of
Values and
Excel Formula
Constraints
Two formats – Simple Range of Values and Excel Formula -- can be
used for entering constraints. The type of information you can enter
for a constraint depends on the format you select. Range constraints
can only be described using the Simple Range of Values format as no
formulas can be used.
♦
Simple Range of Values Format - The Simple Range of Values
format allows constraints to be entered using simple <,<=, >, >=
or = relations where a cell is compared with an entered number.
A typical Simple Range of Values constraint would be:
0<Value of A1<10
where A1 is entered in the Cell Range box, 0 is entered in the Min
box and 10 is entered in the Max box. The operator desired is
selected from the drop down list boxes. With a simple range of
values format constraint, you can enter just a Min value, just a
Max or both. The entered Min and Max values must be numeric
in the simple range of values constraint format.
♦
Soft Constraints
Excel Formula Format - A formula constraint allows you to enter
any valid Excel formula as a constraint, such as A19<(1.2*E7)+E8.
RISKOptimizer will check whether the entered formula evaluates
to TRUE or FALSE to see if the constraint has been met
Soft Constraints are conditions which we would like to be met as
much as possible, but which we may be willing to compromise for a
big improvement in fitness or target cell result. When a soft constraint
is not met it causes a change in the target cell result away from its
optimal value. The amount of change caused by an unmet soft
constraint is calculated using a penalty function that is entered when
you specify the soft constraint.
Chapter 5: Complete Reference
109
Entering a
Penalty
Function
RISKOptimizer has a default penalty function which is displayed when
you first enter a soft constraint. Any valid Excel formula, however,
may be entered to calculate the amount of penalty to apply when the
soft constraint is not met. An entered penalty function should include
the keyword deviation which represents the absolute amount by
which the constraint has gone beyond its limit. At the end of each
simulation for a trial solution RISKOptimizer checks if the soft
constraint has been met; if not, it places the amount of deviation in the
entered penalty formula and then calculates the amount of penalty to
apply to the target cell statistic.
The penalty amount is either added or subtracted from the calculated
from the calculated statistic for the target cell in order to make it less
"optimal". For example, if Maximum is selected in the Find the field in
the RISKOptimizer Settings dialog, the penalty is subtracted from the
calculated statistic for the target cell.
Viewing the
Effects of an
Entered Penalty
Function
RISKOptimizer includes an Excel worksheet PENALTY.XLS which can
be used to evaluate the effects of different penalty functions on
specific soft constraints and target cell results.
PENALTY.XLS allows you to select a soft constraint from your model
whose effects you wish to analyze. You can then change the penalty
function to see how the function will map a specific value for the
unmet soft constraint into a specific penalized target value. For
example, if your soft constraint is A10<100, you could use
PENALTY.XLS to see what the target value would be if a value of 105
was calculated for cell A10.
110
Viewing the
Penalties
Applied
When a penalty is applied to the target cell due to an unmet soft
constraint, the amount of penalty applied along with the value for the
soft constraint cell can be viewed in the RISKOptimizer Watcher. In
addition, when a RISKOptimizer optimization summary worksheet is
created, penalty values applied along with soft constraint values are
placed in the optimization summary worksheet.
NOTE: If you place a solution in your worksheet using the Update
The Spreadsheet options in the Stop dialog, the calculated target cell
result shown in the spreadsheet will not include any penalties applied
due to unmet soft constraints. Check the RISKOptimizer
optimization summary worksheet to see the penalized target cell
result and the amount of penalty imposed due to each unmet soft
constraint.
Implementing
Soft Constraints
in Worksheet
Formulas
Penalty functions can be implemented directly in the formulas in your
worksheet. If soft constraints are implemented directly in the
worksheet they should not be entered in the main RISKOptimizer
dialog. For more information on implementing penalty functions in
your worksheet, see the section Soft Constraints in Chapter 11:
RISKOptimizer Extras.
Deleting
Constraints
Clicking the Delete button next to the Constraints list box in the
RISKOptimizer Settings Dialog deletes the constraint that is
highlighted in the Constraints list box. Range constraints can only be
deleted in the Adjustable Cells dialog box.
Editing
Constraints
Clicking the Edit button next to the Constraints list box in the
RISKOptimizer Settings Dialog displays the currently selected
constraint in the Constraint dialog box. Once displayed, the type of
constraint desired, along with its description, name, format and
parameters can be edited.
If a range constraint is selected for editing, the Adjustable Cells dialog
box is displayed with the selected cell range and range constraint
entered. The range constraint can then be changed as desired.
Chapter 5: Complete Reference
111
Options
The Options dialog displays general RISKOptimizer options along with
settings for population size, display update, random number
generator seed, and optimization and simulation stopping conditions.
Population Size
112
The population size tells RISKOptimizer how many organisms (or
complete sets of variables) should be stored in memory at any given
time. Although there is still much debate and research regarding the
optimal population size to use on different problems, generally we
recommend using 30-100 organisms in your population, depending
on the size of your problem (bigger population for larger problems).
The common view is that a larger population takes longer to settle on
a solution, but is more likely to find a global answer because of its
more diverse gene pool.
General Options
The available general options include:
♦
Pause on Error. This option tells RISKOptimizer to pause
whenever an error occurs in the specified Target cell or if a
constraint or stop formula generates an error. If an error occurs
you can scroll through your worksheet to examine the adjustable
cell values which generated the error.
♦
Graph Progress. This option tells RISKOptimizer Watcher to
create a progress graph window that displays a graph of the best
value found so far for the statistic for the target cell you selected.
This best value is red, and will always increase (or always
decrease if minimizing). In addition to the best solution,
RISKOptimizer keeps a whole “population” of past scenarios in
memory. The average solution in this population is plotted in
black, and will probably oscillate up and down a bit, but overall
will slowly move in the same direction as the best line.
The graph also lists the current best in the lower-left corner of the
window. The horizontal (x) axis shows time (early to the left, late
to the right), and the vertical (y) axis shows the values of the
scenarios.
♦
You may click on the graph with the right mouse button, to get a
menu list of additional options for that graph. To review these
options, see Line Graph in the RISKOptimizer Watcher section of
this chapter.
Chapter 5: Complete Reference
113
Update Display
This option specifies the type of updating of the Excel display that will
take place during an optimization. If selected, RISKOptimizer will
update the display every iteration of each simulation run. If not
selected, RISKOptimizer will display the current best value for
adjustable cells in yellow boxes on top of those cells during the
optimization. The current best for the selected simulation statistic of
the target cell will be displayed in a blue box with an arrow pointing
at the target cell.
NOTE: It is recommended that you leave the Update Display option
off to speed up optimizations except when debugging your model.
Random
Number Seed
114
The Random Number Seed option allows you to set the starting seed
value for the random number generator used in RISKOptimizer. When
the same seed value is used, an optimization will generate the exact
same answers for the same model as long as the model has not been
modified and the Use Same Seed Each Sim option is selected. The
Use Same Seed Each Sim option should be checked to insure that
unecessary randomness from simulation to simulation is not
introduced into optimization results.
Optimization
Stopping
Conditions
Stopping conditions specify how and when RISKOptimizer will stop
during an optimization. Once you click Start button on the
RISKOptimizer toolbar, RISKOptimizer will continuously run,
searching for better solutions and running simulations until the
selected stopping criteria are met. You can turn on any number of
these conditions, or none at all if you want RISKOptimizer to search
indefinitely (until you stop it). When multiple conditions are checked,
RISKOptimizer stops as soon as one of the chosen conditions is met.
You may also override these selections and stop RISKOptimizer at any
time manually using the stop button on the RISKOptimizer toolbar.
Available Optimiztion Stopping Conditions include:
♦
Simulations - This option, when set, stops RISKOptimizer when
the given number of simulations have been executed. A
simulation is run for each trial solution generated by
RISKOptimizer.
The Simulations setting is particularly useful when comparing
RISKOptimizer’s efficiency when trying different modeling
methods. By changing the way you model a problem, or by
choosing a different solving method, you may increase
RISKOptimizer’s efficiency. Having a model run a specified
number of simulations will indicate how efficiently RISKOptimizer
is converging on a solution, regardless of any differences in the
number of variables chosen, the speed of the computer hardware
being used, or the screen re-drawing time. The RISKOptimizer
optimization summary worksheet is also useful in comparing
results between runs. For more information on Optimization
summary worksheets, see the Stop section under RISKOptimizer
Toolbar in this chapter.
♦
Minutes - This option, when set, stops RISKOptimizer from
simulating scenarios after the given number of minutes has
elapsed. The number of minutes can be any positive real number
(600, 5.2, etc.).
♦
Change in last - This option, when set, stops RISKOptimizer from
simulating scenarios when the improvement in the target cell is
less than the specified amount (change criterion). You can
specify, as an integer, the number of simulations over which to
check the improvement. A percentage value - such as 1% - can be
entered as the maximum change value in the Valid Sim(s) is less
than field.
Chapter 5: Complete Reference
115
Suppose that we are trying to maximize the mean of the target
cell, and after 500 simulations, the best answer found so far is
354.8. If the “Change in last...” option is the only stopping
condition selected, RISKOptimizer will pause at simulation #600
and will only continue if it is able to find an answer of at least
354.9 during those last 100 simulations. In other words,
RISKOptimizer’s answers have not improved at least 0.1 over the
last 100 simulations, so it assumes there is little more
improvement to be found, and stops the search. For more
complex problems, you may want to boost the number of
simulations that RISKOptimizer runs through (500) before deciding
whether there is still sufficient improvement to go on.
This is the most popular stopping condition, because it gives the
user an effective way to stop RISKOptimizer after the improvement
rate is slowing down, and RISKOptimizer is not seeming to find
any better solutions. If you are graphing the best results (Graph
Progress option), you will see the graph plateau or flatten out for a
while before this condition is met and RISKOptimizer stops.
“Change in last” is really just an automatic way to do what you
could do yourself with the graph -- let it run until the
improvement levels off (see “show progress graph”).
NOTE: You can also select no stopping conditions, and
RISKOptimizer will run forever until you press the stop button on the
RISKOptimizer toolbar.
Simulation
Stopping
Conditions
116
Simulation stopping conditions specify how RISKOptimizer will
determine when to stop each simulation it runs. You can run each
simulation for a fixed number of iterations, or, alternatively, let
RISKOptimizer determine when to stop each simulation. Available
Simulation Stopping Conditions include:
♦
Run XXXX Iterations - This option allows you to run each
simulation for a fixed number of iterations. In this case,
RISKOptimizer will run the specified number of iterations each
simulation that is performed for each trial solution generated by
RISKOptimizer (unless stopped prematurely when an iteration
constraint is not met).
♦
Stop on Actual Convergence - This option instructs
RISKOptimizer to stop each simulation when the distributions
generated for both 1) the target cell of the optimization and 2)
cells referenced in simulation constraints are stable and the
statistics of interest converge. The amount of variation allowed in
a statistic when it is marked as "converged" is set by the Tolerance
option.
♦
Stop on Projected Convergence - This option instructs
RISKOptimizer to stop each simulation when it can project
internally that the distributions generated for both 1) the target
cell of the optimization and 2) cells referenced in simulation
constraints are stable. RISKOptimizer projects convergence based
on the results of prior simulations that have been run during the
optimization.
Allowing RISKOptimizer to control when to stop is recommended to
insure that enough iterations are run (but not too many!) so that
output statistics returned to the optimizer are stable. You may,
however, wish to limit the iterations run by specifying a fixed number
of iterations to speed your optimizations. This would be done when
models are very large or each Excel recalculation of the model takes a
long time.
Tolerance
Option
The Tolerance option takes a value from 1 to 100 (or auto). This sets
the amount of change allowed when the statistic of interest is said to
be converged. A low setting requires that there be very little change
in the statistic for it to be labelled as “converged”; incomparison, high
settings close to 100 allow much greater variation in converged
statistics. The trade off of low tolerance settings vs. high is the
amount of time required to run an optimization. Many additional
iterations may be required per simulation to achieve convergence with
a low tolerance setting, often with no marked improvement in overall
optimization results. Selecting Auto specifies that RISKOptimizer will
set the convergence tolerance for you.
Chapter 5: Complete Reference
117
Macros
VBA macros can be run at different times during an optimization and
during the simulation run for each trial solution. This allows the
development of custom calculations that will be invoked during an
optimization.
The Macros
Dialog
Macros may be executed at the following times during an
optimization:
118
♦
At the Start of the Optimization - macro runs after the Run icon
is clicked; prior to the first trial solution being generated.
♦
Before Each Simulation Begins - macro runs prior to each
simulation that is executed (a simulation for each trial solution
generated by the optimizer).
♦
Before Each Iteration's Recalc - macro runs prior to each iteration
of each simulation that is executed. Macro is run prior to samples
being drawn from probability distribution functions for the
iteration and subsquent recalculation of the model.
♦
After Each Iteration's Recalc - macro runs after each iteration of
each simulation that is executed. Macro is run after samples are
drawn from probability distribution functions for the iteration
and the recalculation of the model using those samples; but prior
to the value for the target cell being collected.
♦
After Each Simulation Ends - macro runs after each simulation
that is executed, but prior to the statistic that is being optimized
for the target cell's distribution is stored.
♦
After the Output has been Stored - macro runs after each
simulation that is executed and after the statistic that is being
optimized for the target cell's distribution is stored.
♦
At the End of the Optimization - macro runs when the
optimization is completed.
This feature allows calculations which only can be performed through
the use of a macro to be made during an optimization. Examples of
such macro-performed calculations are iterative "looping" calculations
and calculations which require new data from external sources.
The Macro Name defines the macro to be run.
Chapter 5: Complete Reference
119
Sampling
The Sampling options control the sampling of probability distribution
functions that are entered in your worksheet during 1) simulations
run during an optimization and 2) standard Excel recalculations of
your spreadsheet.
Simulation
Sampling Type
Simulation Sampling Type options set the type of sampling used
during each simulation run during an optimization. Sampling types
vary in how they draw samples from across the range of a
distribution. Latin Hypercube sampling will accurately recreate the
probability distributions specified by distribution functions in fewer
iterations when compared with Monte Carlo sampling.
We recommend using Latin Hypercube, the default sampling type
setting, unless your modeling situation specifically calls for Monte
Carlo sampling.
Standard Recalc
120
♦
Monte Carlo -- selects standard Monte Carlo sampling
♦
Latin Hypercube – selects stratified sampling
Specifies how distribution functions are evaluated during a regular
Excel recalculation. When a recalc is executed (such as by selecting
the Excel Options menu Calculate Now command or by pressing
<F9>), distribution functions will return a value for use in worksheet
recalculations. The type of value returned is set by the Standard
Recalc options.
♦
Expected Value — Causes distribution functions to return their
expected or mean value during a regular Excel recalculation. This
setting allows your worksheet values to appear just as they would
without RISKOptimizer with a single expected value displayed in
each cell. The expected value is also known as the best estimate
or average value. This is the default setting for Standard Recalc.
♦
Monte Carlo — Causes distribution functions to return a random
Monte Carlo sample during a regular recalculation. This setting
allows your worksheet values to appear as they would during
execution of a simulation with new samples drawn for
distribution functions each recalculation.
♦
True EV — Causes all distribution functions including discrete
distributions to return their expected or mean value during a
regular Excel recalc. This setting causes the same values to be
returned as the option Standard Recalc Expected Value, except in
the case of discrete distribution types such as DISCRETE,
POISSON and similar distributions. For these distributions the
true expected value will be returned in a Excel recalc even if the
expected value could not occur for the entered distribution i.e., it
is not one of the discrete points in the distribution. For discrete
distributions, the setting Standard Recalc Expected Value returns
the discrete value in the distribution closest to the true expected
value. In most cases Expected Value as opposed to True EV is the
setting that should be used.
Chapter 5: Complete Reference
121
122
RISKOptimizer Toolbar
As soon as RISKOptimizer is running, you will see the following
RISKOptimizer Toolbar. This toolbar can be moved and minimized to
an icon, but will always be the top-most window when an
optimization is running.
Run
Clicking the Run button causes RISKOptimizer to begin searching for a
solution based on the current description in the RISKOptimizer
Settings Dialog. All options, settings, adjustable cell ranges and
stopping conditions that you want to be used in the optimization
should be set before you click on the Run button.
If you pause RISKOptimizer, or even stop RISKOptimizer, you will still
be able to click this Run button to continue the search for better
solutions.
The Status Bar
During an optimization the status bar in Excel displays the current
progress of the analysis.
Best= reports the current best value for the statistic for the target cell
that is being minimized or maximized. Orig.= reports the original
value for the statistic for the target cell as calculated from an initial
simulation run using the existing values in the worksheet for the
adjustable cells. Sims= reports the total number of simulations that
have been executed and ## Valid indicates the number of those
simulations for which all constraints were met. Iters= reports the
number of iterations run in the current simulation.
Pause
If you would like to pause the RISKOptimizer process, just click the
“pause” button, and you temporarily “freeze” the RISKOptimizer
process. While paused, you may wish to make changes, or minimize
your Excel worksheet. More likely, you may wish to open and
explore the RISKOptimizer Watcher and change parameters, look at
the whole population, view a status report, or copy a graph.
Chapter 5: Complete Reference
123
Anytime you are ready, just hit the “run” button to continue the
RISKOptimizer process, or press the “stop” button when you wish to
end the RISKOptimizer process.
Stop
When you click the Stop button, the Stop dialog displays the options
available for updating your worksheet with the best calculated values
for adjustable cells, restoring original values, continuing an
optimization and generating a optimization summary worksheet.
This dialog will also appear if one of the user specified stopping
conditions has been met (number of requested trials have been
evaluated, minutes requested have elapsed, etc.). The stop alert offers
three choices for updating your spreadsheet: Best Values Calculated So
Far, Original Values and Last Calculated Values.
Best Values
Calculated So
Far
This accepts RISKOptimizer’s results and ends RISKOptimizer’s search
for better solutions. When you choose this option, the values of the
best scenario RISKOptimizer has found in its search are placed into the
adjustable cells of your spreadsheet.
IMPORTANT NOTE: After you accept RISKOptimizer’s results and
create a optimization summary worksheet, you can later restore your
original worksheet values by using the optimization summary
worksheet. The Restore button in the optimization summary
worksheet allows you to select the run whose original values you
want to restore.
Original Values
This restores the adjustable cells to their original values before
RISKOptimizer was run, and ends RISKOptimizer’s search for better
solutions.
Last Calculated
Values
This causes RISKOptimizer to place the last calculated values in the
optimization in the worksheet. The Last Calculated Values option is
particularly useful when debugging models.
124
RISKOptimizer Toolbar
Stop
This option destroys RISKOptimizer’s population of solutions and
places the selected values in your spreadsheet. If you wish to save
any information about the RISKOptimizer session, including the
population values, the time and number of trials run, be sure to select
to create an optimization summary worksheet.
Continue
If you click Continue, RISKOptimizer will search for solutions where it
left off, and will stop again when it satisfies your original stopping
conditions again. For example, if you originally told RISKOptimizer
not to stop until “minutes = 5”, RISKOptimizer will run for another 5
minutes if you choose to hit run again.
Generate
Optimization
Summary
Worksheet
RISKOptimizer can generate optimization summary worksheets that
can be used for 1) reporting on the results of a run, 2) comparing the
results between runs and 3) restoring either the original values and
RISKOptimizer settings that existed before a run or the best values
calculated by a run.
Chapter 5: Complete Reference
125
Each run can be summarized into a worksheet automatically created
by RISKOptimizer. All RISKOptimizer settings, original values and
best results for a run are shown in a column in this worksheet. By
clicking the Restore button in the top left of the summary worksheet,
values from the report may be placed back in your worksheet,
including either 1) the original values and RISKOptimizer settings that
existed before the run or 2) the best values calculated by a run.
Restore Dialog
When the Restore button is clicked, you can select which run in the
optimization summary worksheet (i.e., its column) you wish to
restore. If you select to Restore RISKOptimizer Model Settings, all
settings that were used for the run (adjustable cells, constraints,
options, etc.) will be restored to the RISKOptimizer dialogs, replacing
the current settings. Input Cell Values from the report may also be
placed back in your worksheet, replacing the current values. Either
the best values from the optimization or the original values that
existed before the run may be restored.
126
RISKOptimizer Toolbar
RISKOptimizer Watcher
The last icon on the RISKOptimizer Toolbar launches the
RISKOptimizer Watcher. RISKOptimizer Watcher is responsible for
regulating and reporting on all RISKOptimizer activity.
From RISKOptimizer Watcher, you can change parameters and
analyze the progress of the optimization. You can also see real-time
information about the problem and information on RISKOptimizer’s
progress in the status bar across the bottom of RISKOptimizer Watcher.
NOTE: RISKOptimizer Watcher is a stand-alone program designed
for users who want a more detailed look at RISKOptimizer’s
operations. You do not need to use RISKOptimizer Watcher to use
RISKOptimizer.
RISKOptimizer Watcher is a stand-alone application that is linked to
RISKOptimizer. It gives you a real-time look at the data with which
RISKOptimizer is working, and even allows you to examine and
modify the actions of RISKOptimizer as it is optimizing a solution.
Chapter 5: Complete Reference
127
RISKOptimizer Watcher Toolbar
The RISKOptimizer Watcher toolbar contains all the tools found on the
standard RISKOptimizer Toolbar, plus additional tools that graphically
depict the current population, showing you the status of your
problem as it runs.
Population
Settings button
The Population Settings button allows you to change the Crossover and
Mutation rates of the genetic algorithm as the problem is in progress.
Any changes made here will override the original setting of these
parameters in the Adjustable Cells Dialog, and will take place
immediately after clicking OK, affecting the population (or group of
adjustable cells) that was selected in the Settings For field.
We almost always recommend using the default crossover of 0.5. For
mutation, in many models you may turn it up as high as about 0.4 if
you want to find the best solution and are willing to wait longer for it.
Setting the mutation value to 1 (the maximum) will result in
completely random guessing, as RISKOptimizer performs mutation
after it performs crossover. This means that after the two selected
parents are crossed over to create an offspring solution, 100% of that
solution’s “genes” will mutate to random numbers, effectively
rendering the crossover meaningless. (see “crossover rate, what it
does” and “mutation rate, what it does” in the index for more)
128
RISKOptimizer Watcher
Progress Graph
button
This progress graph plots the best solution RISKOptimizer has found
so far with a red line, and also plots the average solution in the
current population in black. This dual line graph gives a better
indication of when the population is converging on a solution. The Y
axis continuously scales to fit the data, allowing you to see subtle
changes as the problem progresses.
The X axis usually updates one data point every 100 trials, but you
may click on the graph once with the right mouse button to get a
menu list of additional options for that graph. To select an item from
this menu, click once on the option with the left mouse button. The
line graph will present the following options:
Freeze Update. This option freezes the updating of the graph.
Axis Scaling
This option allows you to change the scaling of the X and Y axes of the
displayed progress graph, using the following dialog:
Chapter 5: Complete Reference
129
By changing the number of points, you are, in effect, lengthening the x
axis or “time” axis to show more points. The “Trials per point” option
tells RISKOptimizer to plot a point every n trials (default: plot a point
every 20 trials).
The option Adjust Axes Automatically causes RISKOptimizer to
automatically adjust the Y-axis scale values as values changes during
the optimization.
In addition to the traditional line graph with its linear x and linear y
axis plots, we have added the ability to plot the line graph with
logarithmic y axis and linear x axis. Rather than constantly rescaling
the Y axis to show subtle changes in progress, this option keeps the
initial value of your Y axis, allows you to see the progress of the entire
problem from its initial value to its solution.
Copy to Clipboard. This option copies the current graph or table to
the clipboard where it can be pasted into other applications.
Color Table
button
This scatter plot assigns a color to each variable value in the current
population, based on how different it is from the same variables of
other organisms (solutions). This is an indication of the diversity that
exists in the gene pool. For example, in the picture above, a vertical
bar on variable 2 means that variable is consistently the same value
across each organism. The “Freeze Update” option in the pop-up
menu freezes a “snapshot” of the current population data until
“Freeze Update” is selected again.
130
RISKOptimizer Watcher
Bar Graph
button
The bar graph shows the values of only the current population (in
order of worst to best).
Population
Table button
The Population Table button will launch a complete chart showing
each organism in the selected population, including the resulting
“fitness” or evaluation function of each organism. It is from this
population that the other graphs and charts in RISKOptimizer Watcher
are drawn.
The population table is a grid which lists all the variables of each
organism (each possible solution) in the current population. These
organisms (“Org n”) are ranked in order from worst to best. Since this
chart lists all organisms in the population, the “population size”
setting in the main dialog determines how many organisms will be
listed here (default 50). In addition, the first column of the chart
shows the resulting value of the target cell for each organism.
Chapter 5: Complete Reference
131
As with other graphs, the “Freeze Update” option in the pop-up menu
freezes a “snapshot” of the current population data until “Freeze
Update” is selected again.
You may click on the graph once with the right mouse button, to get a
menu list of additional options for that graph. To select an item from
this menu, click once on the option with the left mouse button.
Population
Summary
button
The Population Summary button will generate the following report
window, with complete information on all RISKOptimizer activity.
This form can also be accessed from the “tools” menu in the
RISKOptimizer Watcher toolbar.
This report provides a quick summary of the problem, its methods
and settings, and the results of the RISKOptimizer run. This report is
ideal to print and store solution summaries, compare several
RISKOptimizer runs, or track how long RISKOptimizer took to find its
best answer.
132
RISKOptimizer Watcher
Optimization
Log
The Optimization Log displays information on every trial solution
tested and the simulation associated with each trial solution. Either
information on Every trial solution and simulation can be displayed or
on only those trial solutions and simulations that generate a new Best
value for the simulation statistic of the target cell that is being
minimized or maximized.
The log displays for each simulation:
1) Time, or the start time of the simulation
2) Iters, or the number of iterations run
3) Result, or the value of the target cell's statistic that you are trying
to maximize or minimize, including penalties for soft constraints
4) Output Mean, Output StdDev, Output Min and Output Max, or
the statistics for the probability distribution for the target cell that
was calculated
5) Input columns, or the values used for your adjustable cells
6) Constraint columns showing whether your constraints were met
The Automatically Scroll to Bottom option, if selected, causes the log file
to automatically scroll to the bottom as new simulations are run.
Chapter 5: Complete Reference
133
134
RISKOptimizer Watcher - Menu Items
RISKOptimizer Watcher - Menu
Items
This section discusses the menus and commands available in the
RISKOptimizer Watcher. Many commands can also be invoked by
pressing a toolbar button in the Watcher.
Population Menu
Start, Pause and
Stop
Optimization
These commands are equivalent to the Start, Pause and Stop icons on
the RISKOptimizer toolbar.
Settings
This command is equivalent to the Population Settings button on the
RISKOptimizer Watcher toolbar.
Options
The Options dialog allows you set window updating and status bar
displays for the RISKOptimizer Watcher. Changing the Update
settings can speed up optimizations when the Watcher is running.
Chapter 5: Complete Reference
135
Create Menu
This menu contains commands that allow you to create each of the
graphs and reports available in the RISKOptimizer Watcher. Selecting
each of the five commands on this menu are equivalent to clicking
each of the toolbar buttons shown in the Watcher. For more
information on these buttons and the graphs and reports they create,
see the RISKOptimizer Watcher Toolbar earlier in this chapter.
Window Menu
Stay On Top
When this item is checked, the RISKOptimizer Watcher will remain the
front-most window on your screen during an optimization, even if
you open other applications.
Cascade and
Tile
Cascade and Tile reposition all open Watcher windows.
136
RISKOptimizer Watcher - Menu Items
Chapter 6: Optimization
Introduction ............................................................................................. 139
Optimization Methods............................................................................. 139
About Hill Climbing Algorithms ........................................................... 141
Excel Solver.............................................................................................. 145
Types of Problems.................................................................................... 146
Linear Problems ............................................................................... 146
Non-linear Problems ....................................................................... 146
Table-based problems ..................................................................... 148
Combinatorial problems ................................................................. 148
Chapter 6: Optimization
137
138
Introduction
RISKOptimizer combines optimization and simulation to allow you to
optimize problems that have uncertain elements. The following three
chapters of this manual provide background information on the
analytical techniques used in RISKOptimizer, including 1)
optimization, 2) genetic algorithms and 3) simulation.
Optimization Methods
Traditional Excel-based optimization problems analyzed using Solver
or Evolver (optimization add-ins to Excel) are comprised of:
•
An output or “target” cell that you wish to minimize or maximize
•
A set of input or “adjustable cells” whose values you control
•
A set of constraints that need to be met, often specified using
expresssions such as COSTS<100 or A11>=0.
During an optimization in Solver or Evolver, the adjustable cells are
changed across allowable ranges you specify. For each possible set of
adjustable cell values the model is recalculated and a new value for
the target cell is generated. When the optimization is complete, an
optimal solution (or combination of adjustable cell values) is found.
This solution is the combination of adjustable cell values which yields
the best (i.e., minimum or maximum) value for the target cell while
satisfying the constraints you’ve entered.
Some optimization problems are much harder than others to solve.
For tough problems, such as an Excel model for finding the shortest
route between 1000 cities, it is not feasible to examine every possible
solution. Such an approach would require years of calculations on the
fastest computers.
To solve such problems, it is necessary to search through a subset of
all possible solutions. By examining these solutions, we can get an
idea of how to find better solutions. This is accomplished with an
algorithm. An algorithm is simply a step-by-step description of how to
approach a problem. All computer programs, for example, are built
by combining numerous algorithms.
Chapter 6: Optimization
139
Let us start by exploring how most problem-solving algorithms
represent a problem. Most problems can be divided into three basic
components: inputs, a function of some kind, and a resulting output.
Looking for: Given this:
Problem
Components
Optimization in
Excel
To get the best:
Inputs
Function
Output
Variables
Model
Goal
Let us assume that our optimization problem involves two variables,
X and Y. When placed in an equation, these two variables produce a
result =Z. Our problem is to find the value for X and Y that produces
the largest Z value. We can think of Z as a “rating”, which indicates
how good any particular X,Y pairing is.
In this example
Looking for:
Given this:
To get the best:
X and Y
Equation
Z
A plot of every single set of Xs,Ys, and the resulting Zs would
produce a three-dimensional surface graph such as the one shown
below.
A “landscape” of possible scenarios or solutions.
Each intersection of an X and Y value produces a Z height. The peaks
and valleys of this “landscape” represent good and bad solutions
140
Introduction
respectively. Searching for the maximum or highest point on this
function by examining each solution would take far too much time,
even with a powerful computer and the fastest program.* Remember
that we are giving Excel just the function itself, not a graph of the
function, and that we could just as easily be dealing with a 200dimensional problem as with this two-dimensional problem. Thus,
we need a method that will let us do fewer calculations and still find
the maximum productivity.
About Hill Climbing Algorithms
Let us look at a simple algorithm called hill-climbing. Hill-climbing is
an algorithm that works like this:
1) Start at a random point on the landscape (take a random guess).
2) Walk a small distance in some arbitrary direction.
3) If you have walked to a new point that is higher, stay and repeat
step 2. If your new point is lower, go back to your original point
and try again.
Hill-climbing tries only one solution or scenario at a time. We will use
a black dot (•) to represent one possible solution (a set of X, Y and Z
values). If we place the dot at the random starting point, we hope that
our hill-climbing method will bring the dot to the highest point on the
graph.
From the diagram above we can clearly see that we want the dot to go
up the high hill to the right. However, we only know that because we
have already seen the entire landscape. As the algorithm runs, it sees
the landscape immediately around it, but not the entire landscape; it
sees the trees but not the forest.
In our diagram, the function is shown as a smooth landscape. In the
rare cases where we deal with simple, smooth (differentiable)
functions, it is possible to use calculus to find minima and maxima.
However, most realistic problems are not described by such smooth
functions.
*
Chapter 6: Optimization
141
In most real-world problems, the landscape is not so smooth, and
would require years to calculate, so we only calculate the current
scenario and the immediately surrounding scenarios. Imagine that
the dot is a blindfolded man standing amidst smooth, rolling hills. If
the man employed the hill-climbing algorithm, this man would put
one foot in each direction, and only move when he felt higher ground.
This man would successfully step his way upwards, and eventually
would come to rest on the hilltop where the ground all around him
was lower than the ground he was on. This seems simple enough.
However, we get into a very serious problem if the man starts out in
another place... he climbs up the wrong hill! (see the diagram below).
Even with a smooth function, hill climbing can fail
if you start from a slightly different position (right).
Hill-climbing only finds the nearest hilltop, or local maximum. Thus, if
your problem has a very rough and hilly solution landscape, as most
realistic models do, hill-climbing is not likely to find the highest hill,
or even one of the highest.
Hill-climbing has another problem; how do we actually find the
terrain around our current location? If the landscape is described by a
smooth function, it may be possible to use differentiation (a calculus
technique) to find out which direction has the steepest slope. If the
landscape is discontinuous or not differentiable (as is more likely in
real-world problems), we need to calculate the “fitness” of
surrounding scenarios.
142
Introduction
For example, lets say a bank hires one security guard from 9:00am to
5:00pm to guard the bank, but the bank must give the officer two (2)
half-hour breaks. We must try to find the optimum break times, given
general rules about performance/fatigue ratios, and considering the
different levels of customer activity throughout the day. We may start
by trying out different combinations of duty breaks and evaluate
them. If we currently use a schedule where the breaks are timed at
11:00am and 3:00pm, we might calculate the productivity of the
surrounding scenarios:
Direction
Current Solution
West Scenario
East Scenario
North Scenario
South Scenario
Break 1 (x)
11:00am
10:45am
11:15am
11:00am
11:00am
Break 2 (y)
3:00pm
3:00pm
3:00pm
3:15pm
2:45pm
“Score” (z)
= 46.5
= 44.67
= 40.08
= 49.227
= 43.97
If we had three adjustable cells (breaks) instead of two, we would
need to look at eight different directions. In fact, if we had just fifty
variables, (quite realistic for a medium-sized problem), we would
need to calculate productivity for 250, or over one quadrillion
scenarios, just for one guard!!
There are modifications that can be made to hill-climbing to improve
its ability to find global maxima (the highest hills on the entire
landscape). Hill-climbing is most useful for dealing with unimodal
(one-peak) problems, and that is why some analysis programs use the
technique. Nevertheless, it is very limited for complex and/or large
problems.
Chapter 6: Optimization
143
144
Introduction
Excel Solver
Excel includes an optimization utility called Solver. Solver can solve
two kinds of problems: linear problems and simple non-linear
problems. It solves linear problems using a linear programming
routine. This classic mathematical technique is often called the
Simplex method, and it will always find perfect answers to small,
purely linear problems.
Like most other baby solvers, the Microsoft Solver also solves nonlinear problems, using a hill climbing routine (specifically, the GRG2
routine). A hill climbing routine starts with the current variable
values and slowly adjusts them until the output of the model does not
improve anymore. This means that problems with more than one
possible solution may be impossible for Solver to solve well, because
Solver ends up at a local solution and cannot jump over to the global
solution (see figure below).
Landscape of possible solutions.
In addition, Solver requires that the function represented by your
model be continuous. This means the output should change smoothly
as the inputs are adjusted. If your model uses lookup tables, acquires
noisy, real-time data from another program, contains random
elements, or involves if-then rules, your model will be jumpy and
discontinuous. Solver would not be able to solve such a problem.
Solver also puts a limit on the number of variables and the number of
constraints in your problem (200) above which you must turn to a
more powerful technique.
Chapter 6: Optimization
145
Types of Problems
Several different types of problems are typically optimized.
Linear Problems
In linear problems, all the outputs are simple linear functions of the
inputs, as in y=mx+b. When problems only use simple arithmetic
operations such as addition, subtraction, and Excel functions such as
TREND() and FORCAST() it indicates there are purely linear
relationships between the variables.
Linear problems have been fairly easy to solve since the advent of
computers and the invention by George Dantzig of the Simplex
Method. A simple linear problem can be solved most quickly and
accurately with a linear programming utility. The Solver utility
included with Excel becomes a linear programming tool when you set
the “Assume Linear Model” checkbox.* Solver then uses a linear
programming routine to quickly find the perfect solution. If your
problem can be expressed in purely linear terms, you should use
linear programming. Unfortunately, most real-world problems
cannot be described linearly.
Non-linear
Problems
If the cost to manufacture and ship out 5,000 widgets was $5,000,
would it cost $1 to manufacture and ship 1 widget? Probably not. The
assembly line in the widget factory would still consume energy, the
paperwork would still need to be filled out and processed through the
various departments, the materials would still be bought in bulk, the
trucks would require the same amount of gas to deliver the widgets,
and the truck driver would still get paid a full day’s salary no matter
how full the load was. Most real-world problems do not involve
variables with simple linear relationships. These problems involve
multiplication, division, exponents, and built-in Excel functions such
as SQRT() and GROWTH(). Whenever the variables share a
disproportional relationship to one another, the problem becomes
non-linear.
For more specifics on Microsoft’s Solver utility, see the Excel User’s
Guide.
*
146
Excel Solver
A perfect example of a non-linear problem is the management of a
manufacturing process at a chemical plant. Imagine that we want to
mix some chemical reactants together and get a chemical product as
the result. The rate of this reaction may vary non-linearly with the
amount of reactants available; at some point the catalyst becomes
saturated and excess reactant just gets in the way. The following
diagram shows this relationship:
If we simply need to find the minimum level of reactants that will
give us the highest rate of reaction, we can just start anywhere on the
graph and climb along the curve until we reach the top. This method
of finding an answer is called hill climbing.
Hill climbing will always find the best answer if a) the function being
explored is smooth, and b) the initial variable values place you on the
side of the highest mountain. If either condition is not met, hill
climbing can end up in a local solution, rather than the global
solution.
Highly non-linear problems, the kind often seen in practice, have
many possible solutions across a complicated landscape. If a problem
has many variables, and/or if the formulas involved are very noisy or
curvy, the best answer will probably not be found with hill climbing,
even after trying hundreds of times with different starting points.
Most likely, a sub-optimal, and extremely local solution will be found
(see figure below).
Chapter 6: Optimization
147
Hill climbing finds the local, but not
global maximum.
Noisy data: Hill climbing
not effective, even with
multiple tries.
RISKOptimizer and Evolver (the source of the genetic algorithm-based
optimizer used in RISKOptimizer) do not use hill climbing. Rather,
they use a stochastic, directed search technique, dubbed a genetic
algorithm. This lets RISKOptimizer jump around in the solution space
of a problem, examining many combinations of input values without
getting stuck in local optima. In addition, RISKOptimizer lets good
scenarios “communicate” with each other to gain valuable
information as to what the overall solution landscape looks like, and
then uses that information to better guess which scenarios are likely to
be successful.
RISKOptimizer generates many possible scenarios, then
refines the search based on the feedback it receives.
Table-based
problems
Many problems require the use of lookup tables and databases. For
example, in choosing the quantities of different materials to buy, you
might need to look up the prices charged for different quantities.
Tables and databases make problems discontinuous (non-smooth).
That makes it difficult for hill-climbing routines like Solver to find
optimal solutions. RISKOptimizer, however, does not require
continuity in the functions it evaluates, and it can find good solutions
for table-based problems, even problems that use many large,
interrelated tables.
If your problem involves looking up values from a database, or a table
of data in Excel, where the index of the table item is a variable or a
function of a variable, you need to use Evolver or RISKOptimizer. If
you only look up a single, constant item in a table (the same record is
retrieved from the table regardless of the input variables’ values), then
you are really only dealing with a constant, and you can probably use
Solver effectively.
Combinatorial
problems
148
There is a large class of problems that are very different from the
numerical problems examined so far. Problems where the outputs
Excel Solver
involve changing the order of existing input variables, or grouping
subsets of the inputs are called combinatorial problems. These
problems are usually very hard to solve, because they often require
exponential time; that is, the amount of time needed to solve a
problem with 4 variables might be 4 x 3 x 2 x 1, and doubling the
number of variables to 8 raises the solving time to 8 x 7 x 6 x 5 x 4 x 3 x
2 x 1, or a factor of 1,680. The number of variables doubles, but the
number of possible solutions that must be checked increases 1,680
times. For example, choosing the starting lineup for a baseball team is
a combinatorial problem. For 9 players, you can choose one out of the
9 as the first batter. You can then choose one out of the remaining 8 as
the second batter, one of the remaining 7 will be the third, and so on.
There are thus 9x8x7x6x5x4x3x2x1 (9 factorial) ways to choose a
lineup of 9 players. This is about 362,880 different orderings. Now if
you double the number of players, there are 18 factorial possible
lineups, or 6,402,373,705,000,000 possible lineups!
RISKOptimizer and Evolver’s genetic algorithm intelligently searches
through the possible permutations. This is much more practical than
searching through all possibilities, and it is much more efficient than
examining purely random permutations; sub-orders from good
scenarios can be retained and used to create even better scenarios.
Chapter 6: Optimization
149
150
Chapter 7: Genetic
Algorithms
Introduction ............................................................................................. 153
History ...................................................................................................... 153
Evolution Theory...................................................................................... 153
Modern Adaptations of Genetic Algorithms ............................... 155
A Biological Example............................................................................... 156
A Digital Example .................................................................................... 157
Chapter 7: Genetic Algorithms
151
152
Introduction
Introduction
RISKOptimizer uses genetic algorithms to search for optimal answers
for simulation models. The genetic algorithms used are adapted from
Evolver, an optimization add-in to Excel from Palisade Corporation.
This chapter provides background information on genetic algorithms
to give insights on how they are used for optimizing simulation
models.
History
The first genetic algorithms were developed in the early 1970s by John
Holland at the University of Michigan. Holland was impressed by the
ease in which biological systems could perform tasks which eluded
even the most powerful super-computers; animals can flawlessly
recognize objects, understand and translate sounds, and generally
navigate through a dynamic environment almost instantaneously.
For decades, scientists have promised to replicate these capabilities in
machines, but we are beginning to recognize just how difficult this
task is. Most scientists agree that any complex biological system that
exhibits these qualities has evolved to get that way.
Evolution Theory
Evolution, so the theory goes, has produced systems with amazing
capabilities through relatively simple, self-replicating building blocks
that follow a few simple rules:
1) Evolution takes place at the level of the chromosome. The
organism doesn’t evolve, but only serves as the vessel in which the
genes are carried and passed along. It is the chromosomes which are
dynamically changing with each re-arrangement of genes.
2) Nature tends to make more copies of chromosomes which produce
a more “fit” organism. If an organism survives long enough, and is
healthy, its genes are more likely to be passed along to a new
generation of organisms through reproduction. This principle is often
referred to as “survival of the fittest”. Remember that “fittest” is a
relative term; an organism only needs to be fit in comparison to others
in the current population to be “successful”.
3) Diversity must be maintained in the population. Seemingly
random mutations occur frequently in nature that ensure variation in
the organisms. These genetic mutations often result in a useful, or
even vital feature for a species’ survival. With a wider spectrum of
Chapter 7: Genetic Algorithms
153
possible combinations, a population is also less susceptible to a
common weakness that could destroy them all (virus, etc.) or other
problems associated with inbreeding.
Once we break down evolution into these fundamental building
blocks, it becomes easier to apply these techniques to the
computational world, and truly begin to move towards more fluid,
more naturally behaving machines.
Holland began applying these properties of evolution to simple
strings of numbers that represented chromosomes. He first encoded
his problem into binary strings (rows of “1s” and “0s”) to represent
the chromosomes, and then had the computer generate many of these
“bit” strings to form a whole population of them. A fitness function
was programmed that could evaluate and rank each bit string, and
those strings which were deemed most “fit” would exchange data
with others through a “crossover” routine to create “offspring” bit
strings. Holland even subjected his digital chromosomes to a
“mutation” operator, which injected randomness into the resulting
“offspring” chromosomes to retain diversity in the population. This
fitness function replaced the role of death in the biological world;
determining which strings were good enough to continue breeding
and which would no longer be kept in memory.
The program kept a given number of these “chromosomes” in
memory, and this entire “population” of strings continued to evolve
until they maximized the fitness function. The result was then decoded back to its original values to reveal the solution. John Holland
remains an active pioneer in this field, and is now joined by hundreds
of scientists and scholars who have devoted the majority of their time
toward this promising alternative to traditional linear programming,
mathematical, and statistical techniques.
Holland’s original genetic algorithm was quite simple, yet remarkably
robust, finding optimal solutions to a wide variety of problems. Many
custom programs today solve very large and complex real-world
problems using only slightly modified versions of this original genetic
algorithm.
154
History
Modern
Adaptations of
Genetic
Algorithms
As interest swelled in academic circles, as serious computational
power began moving its way into mainstream desktop machines,
standards like Microsoft Windows and Excel made design and
maintenance of complex models easier. The use of real numbers
rather than bit string representations eliminated the difficult task of
encoding and decoding chromosomes.
The popularity of the genetic algorithm is now growing exponentially,
with seminars, books, magazine articles, and knowledgeable
consultants popping up everywhere. The International Conference of
Genetic Algorithms is already focusing on practical applications, a
sign of maturity that eludes other “artificial intelligence” technologies.
Many Fortune 500 companies employ genetic algorithms regularly to
solve real-world problems, from brokerage firms to power plants,
phone companies, restaurant chains, automobile manufacturers and
television networks. In fact, there is a good chance that you have
already indirectly used a genetic algorithm before!
Chapter 7: Genetic Algorithms
155
A Biological Example
Let us look at a simple example of evolution in the biological world
(on a small scale). By “evolution” here we mean any change in the
distribution or frequency of genes in a population. Of course, the
interesting thing about evolution is that it tends to lead to populations
that are constantly adapting to their environments.
Imagine that we are looking at a population of mice. These mice
exhibit two sizes, small and large, and they exhibit two colors, light or
dark. Our population consists of the following eight mice:
One day, cats move into the neighborhood and start eating mice. It
turns out that darker mice and smaller mice are harder for the cats to
find. Thus, different mice have different odds of avoiding the cats
long enough to reproduce. This affects the nature of the next
generation of mice. Assuming the old mice die soon after
reproducing, the next generation of mice looks like this:
Notice that large mice, light mice, and especially large, light mice, are
having trouble surviving long enough to reproduce. This continues in
the next generation.
Now the population consists mostly of small, dark mice, because these
mice are better suited for survival in this environment than other
kinds of mice. Similarly, as the cats begin to go hungry with less mice
to eat, perhaps those cats who prefer a lunch of grass will be better
adapted, and pass along their grass-loving gene to a new generation
of cats. This is the central concept of “survival of the fittest”. More
156
History
precisely, it could be phrased “survival until reproduction”. In
evolutionary terms, being the healthiest bachelor in the population is
worthless, since you must reproduce in order for your genes to
influence future generations.
A Digital Example
Imagine a problem with two variables, X and Y, that produce a result
Z. If we calculated and plotted the resulting Z for every possible X
and Y values, we would see a solution “landscape” emerge (discussed
also in Chapter 6: Optimization). Since we are trying to find the
maximum “Z”, the peaks of the function are “good” solutions, and the
valleys are “bad” ones.
When we use a genetic algorithm to maximize our function, we start
by creating several possible solutions or scenarios at random (the
black dots), rather than just one starting point. We then calculate the
function’s output for each scenario and plot each scenario as one dot.
Next we rank all of the scenarios by altitude, from best to worst. We
keep the scenarios from the top half, and throw out the others.
First, create a whole “population” of
possible solutions. Some will be better
(higher) than others.
Chapter 7: Genetic Algorithms
Next we rank them all and
keep the solutions which yield
better results.
157
Each of the three remaining scenarios duplicates itself, bringing the
number of scenarios back up to six. Now comes the interesting part:
Each of the six scenarios is made up of two adjustable values (plotted
as an X and a Y coordinate). The scenarios pair off with each other at
random. Now each scenario exchanges the first of its two adjustable
values with the corresponding value from its partner. For example:
Scenario 1
Scenario 2
Before
After
3.4, 5.0
2.6, 5.0
2.6, 3.2
3.4, 3.2
This operation is called crossing over, or crossover. When our six
scenarios randomly mate and perform crossover, we may get a new
set of scenarios such as this:
In the above example, we assume that the original three scenarios, a,
b, and c, paired up with the duplicates, A, B, C, to form the pairs aB,
bC, bA. These pairs then switched values for the first adjustable cell,
which is equivalent in our diagram to exchanging the x and y
coordinates between pairs of dots. The population of scenarios has
just lived through a generation, with its cycle of “death” and “birth”.
Notice that some of the new scenarios result in lower output (lower
altitude) than any we saw in the original generation. However, one
scenario has moved high up on the tallest hill, indicating progress. If
we let the population evolve for another generation, we may see a
scene like the following:
158
History
You can see how the average performance of the population of
scenarios increases over the last generation. In this example, there is
not much room left for improvement. This is because there are only
two genes per organism, only six organisms, and no way for new
genes to be created. This means there is a limited gene pool. The gene
pool is the sum of all the genes of all organisms in the population.
Genetic algorithms can be made much more powerful by replicating
more of the inherent strength of evolution in the biological world;
increasing the number of genes per organism, increasing the number
of organisms in a population, and allowing for occasional, random
mutations. In addition, we can choose the scenarios that will live and
reproduce more like they occur naturally: with a random element that
has a slight bias towards those that perform better, instead of simply
choosing the best performers to breed (even the biggest and strongest
lion may get hit with lightning)!
All of these techniques stimulate genetic refinement, and help to
maintain diversity in the gene pool, keeping all kinds of genes
available in case they turn out to be useful in different combinations.
RISKOptimizer automatically implements all of these techniques.
Chapter 7: Genetic Algorithms
159
160
History
Chapter 8: Simulation
and Risk Analysis
Introduction ............................................................................................. 163
What is Risk? ........................................................................................... 163
Characteristics of Risk ............................................................................. 164
The Need for Risk Analysis .................................................................... 165
Assessing and Quantifying Risk ............................................................ 166
Describing Risk with a Probability Distribution .................................. 167
Modeling Uncertainty in RISKOptimizer .......................................... 169
Variables.................................................................................................... 169
Certain or Uncertain ........................................................................ 169
Independent or Dependent ............................................................ 170
Analyzing a Model with Simulation .................................................. 171
Simulation ................................................................................................. 171
How Simulation Works ........................................................................... 172
Chapter 8: Simulation and Risk Analysis
161
162
Introduction
Introduction
RISKOptimizer uses simulation to handle the uncertainy present in the
Excel models it optimizes. Both the methods for 1) modeling the
uncertainty present in a spreadsheet and 2) running a simulation on
the model are taken from @RISK, a simulation and risk analysis addin to Excel from Palisade Corporation. This chapter provides
background information on risk and simulation to give insights on
how simulation models are set up in RISKOptimizer.
What is Risk?
Everyone knows that "risk" affects the gambler about to roll the dice,
the wildcatter about to drill an oil well, or the tightrope walker taking
that first big step. But these simple illustrations aside, the concept of
risk comes about due to our recognition of future uncertainty — our
inability to know what the future will bring in response to a given
action today. Risk implies that a given action has more than one
possible outcome.
In this simple sense, every action is "risky", from crossing the street to
building a dam. The term is usually reserved, however, for situations
where the range of possible outcomes to a given action is in some way
significant. Common actions like crossing the street usually aren't
risky while building a dam can involve significant risk. Somewhere in
between, actions pass from being nonrisky to risky. This distinction,
although vague, is important — if you judge that a situation is risky,
risk becomes one criterion for deciding what course of action you
should pursue. At that point, some form of Risk Analysis becomes
viable.
Chapter 8: Simulation and Risk Analysis
163
Characteristics of Risk
Risk derives from our inability to see into the future, and indicates a
degree of uncertainty that is significant enough to make us notice it.
This somewhat vague definition takes more shape by mentioning
several important characteristics of risk.
First, risk can be either objective or subjective. Flipping a coin is an
objective risk because the odds are well known. Even though the
outcome is uncertain, an objective risk can be described precisely
based on theory, experiment, or common sense. Everyone agrees with
the description of an objective risk. Describing the odds for rain next
Thursday is not so clear cut, and represents a subjective risk. Given
the same information, theory, computers, etc., weatherman A may
think the odds of rain are 30% while weatherman B may think the
odds are 65%. Neither is wrong. Describing a subjective risk is openended in the sense that you could always refine your assessment with
new information, further study, or by giving weight to the opinion of
others. Most risks are subjective, and this has important implications
for anyone analyzing risk or making decisions based on a Risk
Analysis.
Second, deciding that something is risky requires personal judgment,
even for objective risks. For example, imagine flipping a coin where
you win $1 for a heads and lose $1 for a tails. The range between $1
and -$1 would not be overly significant to most people. If the stakes
were $100,000 and -$100,000 respectively, most people would find the
situation to be quite risky. There would be a wealthy few, however,
who would not find this range of outcomes to be significant.
Third, risky actions and therefore risk are things that we often can
choose or avoid. Individuals differ in the amount of risk they
willingly accept. For example, two individuals of equal net worth
may react quite differently to the $100,000 coin flip bet described
above — one may accept it while the other refuses it. Their personal
preference for risk differs.
164
What is Risk?
The Need for Risk Analysis
The first step in Risk Analysis and modeling is recognizing a need for
it. Is there significant risk involved in the situation you are interested
in? Here are a few examples that might help you evaluate your own
situations for the presence of significant risk:
♦
Risks for New Product Development and Marketing — Will the
R&D department solve the technical problems involved? Will a
competitor get to market first, or with a better product? How
much impact will the proposed advertising campaign have on
sales levels? Will production costs be as forecast? Will the
proposed sales price have to be changed to reflect unanticipated
demand levels for the product?
♦
Risks for Securities Analysis and Asset Management — How will
a tentative purchase affect portfolio value? Will a new
management team affect market price? Will an acquired firm add
earnings as forecast? How will a market correction impact a
given industry sector?
♦
Risks for Operations Management and Planning — Will a given
inventory level suffice for unpredictable demand levels? Will
labor costs rise significantly with upcoming union contract
negotiations? How will pending environmental legislation impact
production costs? How will political and market events affect
overseas suppliers in terms of exchange rates, trade barriers, and
delivery schedules?
♦
Risks for Design and Construction of a Structure (building,
bridge, dam,...) — Will the cost of construction materials and labor
be as forecast? Will a labor strike affect the construction
schedule? Will the levels of stress placed on the structure by peak
load crowds and nature be as forecast? Will the structure ever be
stressed to the point of failure?
♦
Risks for Investment in Exploration for Oil and Minerals — Will
anything be found? If a deposit is found, will it be uneconomical,
or a bonanza? Will the costs of developing the deposit be as
forecast? Will some political event like an embargo, tax reform, or
new environmental regulations drastically alter the economic
viability of the project?
♦
Risks for Policy Planning — If the policy is subject to legislative
approval, will it be approved? Will the level of compliance with
any policy directives be complete or partial? Will the costs of
implementation be as forecast? Will the level of benefits be as
projected?
Chapter 8: Simulation and Risk Analysis
165
Assessing and Quantifying Risk
Realizing that you have a risky situation is only the first step. How do
you quantify the risk you have identified for a given uncertain
situation? "Quantifying risk" means determining all the possible
values a risky variable could take and determining the relative
likelihood of each value. Suppose your uncertain situation is the
outcome from the flip of a coin. You could repeat the flip a large
number of times until you had established the fact that half of the
times it comes up tails and half of the times heads. Alternatively, you
could mathematically calculate this result from a basic understanding
of probability and statistics.
In most real life situations, you can't perform an "experiment" to
calculate your risk the way you can for the flip of a coin. How could
you calculate the probable learning curve associated with introducing
new equipment? You may be able to reflect on past experiences, but
once you have introduced the equipment, the uncertainty is gone.
There is no mathematical formula that you can solve to get the risk
associated with the possible outcomes. You have to estimate the risk
using the best information you have available.
If you can calculate the risks of your situation the way you would for
a coin flip, the risk is objective. This means that everyone would
agree that you quantified the risk correctly. Most risk quantification,
however, involves your best judgment. There may not be complete
information available about the situation, the situation may not be
repeatable like a coin flip, or it just may be too complex to come up
with an unequivocal answer. Such risk quantification is subjective,
which means that someone might disagree with your evaluation.
Your subjective assessments of risk are likely to change when you get
more information on the situation. If you have subjectively derived a
risk assessment, you must always ask yourself whether additional
information is available that would help you make a better
assessment. If it is available, how hard and how expensive would it
be to obtain? How much would it cause you to change the assessment
you already have made? How much would these changes affect the
final results of any model you are analyzing?
166
What is Risk?
Describing Risk with a Probability Distribution
If you have quantified risk — determined outcomes and probabilities
of occurrence — you can summarize this risk using a probability
distribution. A probability distribution is a device for presenting the
quantified risk for a variable. RISKOptimizer and @RISK (the
simulation add-in to Excel used by RISKOptimizer) use probability
distributions to describe uncertain values in your Excel worksheets
and to present results. There are many forms and types of probability
distributions, each of which describes a range of possible values and
their likelihood of occurrence. Most people have heard of a normal
distribution — the traditional "bell curve". But there are a wide
variety of distribution types ranging from uniform and triangular
distributions to more complex forms such as gamma and weibull.
All distribution types use a set of arguments to specify a range of
actual values and distribution of probabilities. The normal
distribution, for example, uses a mean and standard deviation as its
arguments. The mean defines the value around which the bell curve
will be centered and the standard deviation defines the range of
values around the mean. Over thirty types of distributions are
available to you in RISKOptimizer for describing distributions for
uncertain values in your Excel worksheets.
Chapter 8: Simulation and Risk Analysis
167
168
What is Risk?
Modeling Uncertainty in
RISKOptimizer
You are the "expert" at understanding the problems and situations
that you would like to analyze. If you have a problem that is subject
to risk, then RISKOptimizer and Excel can help you construct a
complete and logical model.
A major strength of RISKOptimizer is that it allows you to work in a
familiar and standard model building environment — Microsoft
Excel. RISKOptimizer works with your Excel model, allowing you to
model uncertainty, but still preserves the familiar spreadsheet
capabilities. You presumably know how to build spreadsheet models
in Excel — RISKOptimizer now gives you the ability to easily modify
these models to include uncertainty.
Variables
Variables are the basic elements in your Excel worksheets that you
have identified as being important ingredients to your analysis. If you
are modeling a financial situation, your variables might be things like
Sales, Costs, Revenues or Profits whereas if you are modeling a
geologic situation, your variables might be things like Depth to
Deposit, Thickness of Coal Seam or Porosity. Each situation has its
own variables, identified by you. In a typical worksheet, a variable
labels a worksheet row or column, for example:
Certain or
Uncertain
You may know the values your variables will take in the time frame of
your model — they are certain or what statisticians call
"deterministic". Conversely, you may not know the values they will
take — they are uncertain, or "stochastic". If your variables are
uncertain you will need to describe the nature of their uncertainty.
This is done with probability distributions, which give both the range
of values that the variable could take (minimum to maximum), and
the likelihood of occurrence of each value within the range. In
RISKOptimizer , uncertain variables and cell values are entered as
probability distribution functions, for example:
RiskNormal(100,10)
RiskUniform(20,30)
RiskExpon(A1+A2)
RiskTriang(A3/2.01,A4,A5)
Chapter 8: Simulation and Risk Analysis
169
These "distribution" functions can be placed in your worksheet cells
and formulas just like any other Excel function.
Independent or
Dependent
In addition to being certain or uncertain, variables in a model can be
either "independent" or "dependent". An independent variable is
totally unaffected by any other variable within your model. For
example, if you had a financial model evaluating the profitability of
an agricultural crop, you might include an uncertain variable called
Amount of Rainfall. It is reasonable to assume that other variables in
your model such as Crop Price and Fertilizer Cost would have no
effect on the amount of rain — Amount of Rainfall is an independent
variable.
A dependent variable, in contrast, is determined in full or in part by
one or more other variables in your model. For example, a variable
called Crop Yield in the above model should be expected to depend
on the independent variable Amount of Rainfall. If there's too little or
too much rain, then the crop yield is low. If there's an amount of rain
that is about normal, then the crop yield would be anywhere from
below average to well above average. Maybe there are other variables
that affect Crop Yield such as Temperature, Loss to Insects, etc.
When identifying the uncertain values in your Excel worksheet, you
have to decide whether your variables are independent or dependent.
The DEPC and INDEPC functions in RISKOptimizer are used to
identify independent and dependent variables. It is extremely
important to correctly recognize dependency relationships between
variables or your model might generate nonsensical results. For
example, if you ignored the relationship between Amount of Rainfall
and Crop Yield, RISKOptimizer might choose a low value for the
rainfall at the same time it picked a high value for the crop yield —
clearly something nature wouldn't allow.
170
Modeling Uncertainty in RISKOptimizer
Analyzing a Model with Simulation
Once you have placed uncertain values in your worksheet cells you
have an Excel worksheet that RISKOptimizer can analyze.
Simulation
RISKOptimizer uses simulation, sometimes called Monte Carlo
simulation, to account for uncertainty during an optimization.
Simulation in this sense refers to a method whereby the distribution of
possible outcomes is generated by letting a computer recalculate your
worksheet over and over again, each time using different randomly
selected sets of values for the probability distributions in your cell
values and formulas. In effect, the computer is trying all valid
combinations of the values of input variables to simulate all possible
outcomes. This is just as if you ran hundreds or thousands of "whatif" analyses on your worksheet, all in one sitting.
What is meant by saying that simulation "tries all valid combinations
of the values of input variables"? Suppose you have a model with
only two input variables. If there is no uncertainty in these variables,
you can identify a single possible value for each variable. These two
single values can be combined by your worksheet formulas to
calculate the results of interest — also a certain or deterministic value.
For example, if the certain input variables are:
Revenues = 100
Costs = 90
then the result
Profits = 10
would be calculated by Excel from
Profits = 100 - 90
There is only one combination of the input variable values, because
there is only one value possible for each variable.
Now consider a situation where there is uncertainty in both input
variables. For example,
Revenues = 100 or 120
Costs = 90 or 80
gives two values for each input variable. In a simulation,
RISKOptimizer would consider all possible combinations of these
variable values to calculate possible values for the result, Profits.
Chapter 8: Simulation and Risk Analysis
171
There are four combinations:
Profits = Revenues - Costs
10 = 100 - 90
20 = 100 - 80
30 = 120 - 90
40 = 120 - 80
Profits also is an uncertain variable because it is calculated from uncertain
variables.
How Simulation Works
In RISKOptimizer , simulation uses two distinct operations:
♦
Selecting sets of values for the probability distribution
functions contained in the cells and formulas of your worksheet
♦
Recalculating the Excel worksheet using the new values
The selection of values from probability distributions is called sampling and
each calculation of the worksheet is called an iteration. RISKOptimizer
generates output distributions by consolidating single-valued results from all
the iterations.
172
Analyzing a Model with Simulation
Chapter 9: Probability
Distribution Functions
Introduction ............................................................................................. 175
Entering Probability Distribution Functions ................................ 176
Defining Distributions Graphically ............................................... 177
Fitting Data to Distributions........................................................... 178
Distribution Property Functions .................................................... 178
Alternate Parameters....................................................................... 178
Types of Alternate Parameters....................................................... 179
Location or "loc" Parameters .......................................................... 180
Sampling Distributions with Alternate Parameters .................... 180
Cumulative Descending Percentiles.............................................. 180
Entering Arguments in @RISK Functions..................................... 181
Optional Arguments........................................................................ 181
Important Note on Excel Arrays.................................................... 182
More Information............................................................................. 182
Chapter 9: Probability Distribution Functions
173
174
Introduction
Probability distribution functions are used for adding uncertainty —
in the form of probability distributions — to the cells and equations in
your Excel worksheet. For example, you could enter
RiskUniform(10,20) in a cell in your worksheet. This specifies that the
values for the cell will be generated by a uniform distribution with a
minimum of 10 and a maximum of 20. This range of values replaces
the single "fixed" value required by Excel.
Distribution functions are used by RISKOptimizer for sampling sets of
possible values during the simulation run for each trial solution of the
optimizer. Each iteration of a simulation uses a new set of values
sampled from each distribution function in your worksheet. These
values are then used in recalculating your worksheet and generating a
new set of possible results.
As with Excel functions, distribution functions contain two elements,
a function name and argument values which are enclosed in
parentheses. A typical distribution function is:
RiskNormal(100,10)
A different distribution function is used for each type of probability
distribution. The type of distribution which will be sampled is given
by the name of the function. The parameters which specify the
distribution are given by the arguments of the function.
The number and type of arguments required for a distribution
function vary by function. In some cases, such as with:
RiskNormal(mean,standard deviation)
a fixed number of arguments are specified each time you use the
function. For others, such as DISCRETE, you specify the number of
arguments you desire, based on your situation. For example, a
DISCRETE function may specify two possible outcomes, or three, or
more as needed.
Like Excel functions, distribution functions may have arguments
which are references to cells or expressions. For example:
RiskTriang(B1,B2*1.5,B3)
In this case the cell value would be specified by a triangular
distribution with a minimum value taken from cell B1, a most likely
value calculated by taking the value for cell B2 and multiplying it by
1.5 and a maximum value taken from cell B3.
Chapter 9: Probability Distribution Functions
175
Distribution functions also may be used in cell formulas, just as are
Excel functions. For example, a cell formula could read:
B2: 100+RiskUniform(10,20)+(1.5*RiskNormal(A1,A2))
All standard Excel editing commands are available to you when
entering distribution functions. However, you will need to have
RISKOptimizer or @RISK loaded for the distribution functions to be
recognized by Excel. If it is not attached, Excel will return #NAME in
the cell where the function is located when the worksheet is
recalculated.
Entering
Probability
Distribution
Functions
To enter probability distribution functions:
1) Examine your worksheet and identify those cells which you
think have uncertain values
Look for those cells where the actual values which occur could vary
from those shown in the worksheet. At first, identify those important
variables whose cell values may have the largest variation in value.
As your Risk Analysis gets more refined, you can further expand your
use of distribution functions throughout the worksheet.
2) Select distribution functions for the cells you have identified.
In Excel, use the Paste Function command to enter the selected
functions into formulas.
You have over thirty types of distributions to choose from when
selecting a distribution function. Unless you know specifically how
uncertain values are distributed it is a good idea to start with some of
the simpler distribution types — uniform, triangular, or normal. As a
starting point, if possible, specify the current cell value as the mean or
most likely value of the distribution function. The range of the
function you are using then reflects the possible variation around the
mean or most likely value.
176
Introduction
The simple distribution functions can be very powerful as you can
describe uncertainty with only a few values or arguments. For
example:
♦
RiskUniform(Minimum, Maximum) uses only two values to
describe the full range of the distribution and assign probabilities
for all the values in the range.
♦
RiskTriang(Minimum, Most Likely, Maximum) uses three easily
identifiable values to describe a complete distribution.
As your models become more complex, you probably will want to
choose from more complex distribution types in order to meet your
specific modeling needs. Use the listings in this section to guide you
in selecting and comparing distribution types.
Defining
Distributions
Graphically
A graph of the distribution is often helpful in selecting and specifying
distribution functions. You can use @RISK Define Distribution
window to display distribution graphs and add distribution functions
to cell formulas. To do this, select the cell where you wish to add a
distribution function and click the Define Distribution icon or the
@RISK add-in menu Model Define Distribution command. The online file displayed when the @RISK Help menu Distributions Help
command is selected also contains graphic depictions of different
functions at selected argument values.
It often helps to first use the Define Distribution window to enter your
distribution functions to better understand how to assign values to
function arguments. Then, once you better understand the syntax of
distribution function arguments, you can enter the arguments yourself
directly in Excel, bypassing the Define Distribution window.
Chapter 9: Probability Distribution Functions
177
Fitting Data to
Distributions
The @RISK Model window (Professional and Industrial versions only)
allows you to fit probability distributions to your data. The
distributions which result from a fit are then available to be assigned
as input distributions and added to your spreadsheet model. By
setting the Source: in the Define Distribution window to Fit Results,
you can use the fit results from any fit tab for assigning distributions
to model inputs.
Distribution
Property
Functions
Optional arguments to distribution functions can be entered using
Distribution Property functions. These optional arguments are used
to name an input distribution for reporting and graphing, truncate the
sampling of a distribution, correlate the sampling of a distribution
with other distributions and keep a distribution from being sampled
during a simulation. These arguments are not required, but can be
added as needed.
Optional arguments specified using @RISK distribution property
functions are embedded inside of a distribution function. Distribution
Property functions are entered just as are standard Excel functions
and can include cell references and mathematical expressions as
arguments.
For example, the following function truncates the entered normal
distribution to a range with a minimum value of 0 and a maximum
value of 20:
=RiskNormal(10,5,RiskTruncate(0,20))
No samples will be drawn outside this minimum-maximum range.
Alternate
Parameters
Many distribution functions can be entered by specifying percentile
values for the distribution you want. For example, you may want to
enter a distribution that is normal in shape and has a 10th percentile of
20 and a 90th percentile of 50. These percentiles may be the only
values you know about this normal distribution – the actual mean and
standard deviation required by the traditional normal distribution are
unknown.
Alternate parameters may be used instead of (or in conjunction with)
the standard arguments for the distribution. When entering percentile
arguments, the Alt form of the distribution function is used, such as
RiskNormalAlt or RiskGammaAlt.
178
Introduction
Each parameter to an alternate parameter distribution function
requires a pair of arguments in the function. Each pair of arguments
specifies:
1) The type of parameter being entered
2) The value for the parameter.
Each argument in a pair is entered directly in the Alt function, such as
RiskNormalAlt(arg1type, arg1value, arg2type, arg2value). For example:
•
Types of
Alternate
Parameters
RiskNormalAlt(5%, 67.10, 95%, 132.89) - specifies a normal
distribution with the 5th percentile at the value of 67.10 and the
95th percentile at the value of 132.89.
Alternate parameters may be either percentiles or standard
distribution arguments. If a type of parameter argument is a label in
quotes (such as "mu"), the parameter specified is the standard
distribution argument that has the entered name. This allows
percentiles to be mixed with standard distribution arguments, such as:
•
RiskNormalAlt("mu", 100, 95%, 132.89) - specifies a normal
distribution with a mean of 100 and the 95th percentile at the value
of 132.89.
The allowable names for the standard arguments of each distribution
can be found in the heading for each function in this chapter, in the
Excel Function Wizard in the @RISK Distrib (Alt Param) section, or by
using the Define Distribution window. Note: If you click the Alt icon
in the Define Distribution window and select a Standard Argument
and click OK, @RISK will write the appropriate name for the
standard argument in quotes in the function in the formula bar of
the Define Distribution window.
If a type of parameter argument is a value between 0 and 1 (or 0% to
100%), the parameter specified is the entered percentile for the
distribution.
Chapter 9: Probability Distribution Functions
179
Location or
"loc"
Parameters
Some distributions will have an additional location parameter when
they are specified using alternate parameters. This parameter is
typically available for distributions that do not have a location value
specified in one of their standard arguments. Location is equivalent
to the minimum or 0 perc% value of the distribution. For example,
the Gamma distribution does not have a location value specified
through its standard arguments and thus a location parameter is
available. The normal distribution , on the other hand, does have a
location parameter in its standard arguments – the mean or mu – and
thus does not have a spearate location parameter when it is entered
using alternate parameters. The purpose of this "extra" parameter is
to allow you to specify percentiles for shifted distributions. (e.g. a
three parameter Gamma with a location of 10 and two percentiles)
Sampling
Distributions
with Alternate
Parameters
During a simulation @RISK calculates the appropriate distribution
whose percentile values equal those alternate parameter values
entered and then samples that distribution. Just like all @RISK
functions, the entered arguments may be references to other cells or
formulas, just as with any Excel function; and argument values may
change iteration to iteration during a simulation.
Cumulative
Descending
Percentiles
Alternate percentile parameters to probability distributions may be
specified in terms of cumulative descending percentiles as well as the
standard cumulative ascending percentiles. Each of the Alt forms for
probability distribution functions (such as RiskNormalAlt) has a
corresponding AltD form (such as RiskNormalAltD). If the AltD
form is used, any entered percentile values are cumulative descending
percentiles, where the percentile specifies the chance of a value
greater or equal to the entered value.
If you select the @RISK add-in menu Options command Display
Cumulative Descending Percentiles option, all @RISK reports will
show cumulative descending percentile values. In addition, when
you click the Alt icon in the Define Distribution window to enter
distributions using alternate parameters, cumulative descending
percentiles will automatically be shown and AltD forms of probability
distribution functions will be entered.
In addition to cumulative descending percentiles for alternate
parameters distributions, the @RISK cumulative probability
distribution (RiskCumul) may also be specified using cumulative
descending percentiles. To do this, use the function RiskCumulD.
180
Introduction
Entering
Arguments in
@RISK
Functions
Optional
Arguments
The guidelines for entering Excel functions presented in the relevant
User’s Guide are also applicable to entering @RISK functions.
However, some additional guidelines specific to @RISK functions are:
•
Where integer arguments are required by a distribution function,
any non-integer argument values will be truncated to integers.
•
Integer arguments must be greater than or equal to -32,767 and
less than or equal to 32,767. Values outside this range will cause
the function to return #VALUE in Excel.
•
Distribution functions with varying numbers of arguments (such
as HISTOGRM, DISCRETE, and CUMUL) require that arguments
of the same type be entered as arrays. Arrays in Excel are
denoted by either enclosing the values of the array in {} brackets
or using a reference to a contiguous range of cells — such as
A1:C1. If a function takes a varying number of value/probability
pairs, the values will be one array and the probabilities another.
The first value in the value array is matched with the first
probability in the probability array and so on.
Some @RISK functions have optional arguments, or arguments that
may be used but are not required. The RiskOutput function, for
example, has only optional arguments. You can use it with 0, 1 or 3
arguments, depending on what information you wish to define about
the output cell where the function is used. You can:
1) Just identify the cell as an output, letting @RISK automatically
generate a name for you (i.e., =RiskOutput()).
2) Give the output a name you select (i.e., =RiskOutput(“Profit
1999”)).
3) Give the output a name you select and identify it as part of an
output range (i.e., =RiskOutput(“Profit 1999”,” Profit By Year”,1)).
Any of these forms of the RiskOutput function are allowed because
all of its arguments are optional.
When an @RISK function has optional arguments you can add the
optional arguments you choose and ignore the rest. You must,
however, include all required arguments. For example, for the
RiskNormal function, two arguments, mean and standard deviation, are
required. All of the arguments which can be added to the RiskNormal
function via distribution property functions are optional and can be
entered in any order you like.
Chapter 9: Probability Distribution Functions
181
Important Note
on Excel Arrays
More
Information
182
In Excel, you may not list cell references or names in arrays as you
would list constants. For example, you could not use {A1,B1,C1} to
represent the array containing the values in cells A1, B1, and C1.
Instead, you must use the cell range reference A1:C1 or enter the
values of those cells directly in the arrays as constants — for example,
{10,20,30}.
•
Distribution functions with fixed numbers of arguments will
return an error value if an insufficient number of arguments is
entered and will ignore extra arguments if too many are entered.
•
Distribution functions will return an error value if arguments are
of the wrong type (number, array or text).
This section briefly describes each probability distribution function
available and the arguments required for each. In addition, the online file displayed when the @RISK Help menu Distributions Help
command is selected describes the technical characteristics of each
probability distribution function. The appendices include formulas
for density, distribution, mean, mode, distribution parameters and
graphs of the probability distributions generated using typical
argument values.
Introduction
Table of Available Functions
This table lists the custom functions that are added to Excel by @RISK
and RISKOptimizer.
Distribution Function
Returns
RiskBeta(alpha1,alpha2)
beta distribution with shape parameters
alpha1 and alpha2
RiskBetaGeneral( alpha1,
alpha2,minimum, maximum)
beta distribution with defined minimum,
maximum and shape parameters alpha1 and
alpha2
RiskBetaGeneralAlt(arg1type,
arg1value, arg2type,arg2value,
arg3type,arg3value, arg4type,arg4value)
beta distribution with four parameters
named arg1type to arg4type which can be
either a percentile between 0 and 1 or
“alpha1”, “alpha2”, “min” or “max”
RiskBetaSubj(minimum, most likely,
mean, maximum)
beta distribution with defined minimum,
maximum, most likely and mean
RiskBinomial(n,p)
binomial distribution with n draws and p
probability of success on each draw
RiskChiSq(v)
Chi-Square distribution with v degrees of
freedom
RiskCumul(minimum,maximum,
{X1,X2,...,Xn},{p1,p2,...,pn})
cumulative distribution with n points
between minimum and maximum with
cumulative ascending probability p at each
point
RiskCumulD(minimum,maximum,
{X1,X2,...,Xn},{p1,p2,...,pn})
cumulative distribution with n points
between minimum and maximum with
cumulative descending probability p at each
point
RiskDiscrete({X1,X2,...,Xn},
{p1,p2,...,pn})
discrete distribution with n possible
outcomes with the value X and probability
weight p for each outcome
RiskDuniform({X1,X2,...Xn})
discrete uniform distribution with n
outcomes valued at X1 through Xn
RiskErf(h)
error function distribution with variance
parameter h
RiskErlang(m,beta)
m-erlang distribution with integral shape
parameter m and scale parameter beta
RiskExpon(beta)
exponential distribution with decay
constant beta
Chapter 9: Probability Distribution Functions
183
184
Distribution Function
Returns
RiskExponAlt(arg1type, arg1value,
arg2type,arg2value)
exponential distribution with two
parameters named arg1type and arg2type
which can be either a percentile between 0
and 1 or “beta”or "loc"
RiskExtvalue(a,b)
extreme value (or Gumbel) distribution with
location parameter a and scale parameter b
RiskExtvalueAlt(arg1type, arg1value,
arg2type,arg2value)
extreme value (or Gumbel) distribution with
two parameters named arg1type and
arg2type which can be either a percentile
between 0 and 1 or “alpha” or “beta”
RiskGamma(alpha,beta)
gamma distribution with shape parameter
alpha and scale parameter beta
RiskGammaAlt(arg1type, arg1value,
arg2type,arg2value, arg3type,arg3value)
gamma distribution with three parameters
named arg1type, arg2type and arg3type which
can be either a percentile between 0 and 1 or
“alpha”, “beta”or "loc"
RiskGeneral(minimum,maximum,
{X1,X2,...,Xn},{p1,p2,...,pn})
general density function for a probability
distribution ranging between minimum and
maximum with n (x,p) pairs with value X
and probability weight p for each point
RiskGeometric(p)
geometric distribution with probability p
RiskHistogrm(minimum,maximum,{p1,p2,...,pn})
histogram distribution with n classes
between minimum and maximum with
probability weight p for each class
RiskHypergeo(n,D,M)
hypergeometric distribution with sample
size n, D number of items and M population
size
RiskIntUniform(minimum,maximum)
uniform distribution which returns integer
values only between minimum and maximum
RiskInvGauss(mu,lambda)
inverse gaussian (or Wald) distribution with
mean mu and shape parameter lambda
RiskInvGaussAlt(arg1type, arg1value,
arg2type,arg2value, arg3type,arg3value)
inverse gaussian (or Wald) distribution with
three parameters named arg1type, arg2type
and arg3type which can be either a percentile
between 0 and 1 or “mu”, “lambda”or "loc"
RiskLogistic(alpha,beta)
logistic distribution with location parameter
alpha and scale parameter beta
Table of Available Functions
Distribution Function
Returns
RiskLogisticAlt(arg1type, arg1value,
arg2type,arg2value)
logistic distribution with two parameters
named arg1type and arg2type which can be
either a percentile between 0 and 1 or “alpha”
or “beta”
RiskLoglogistic(gamma,beta, alpha)
log-logistic distribution with location
parameter gamma, scale parameter beta and
shape parameter alpha
RiskLoglogisticAlt(arg1type,
arg1value, arg2type,arg2value,
arg3type,arg3value)
log-logistic distribution with three
parameters named arg1type, arg2type and
arg3type which can be either a percentile
between 0 and 1 or “gamma”, “beta” or
“alpha”
RiskLognorm(mean,standard
deviation)
lognormal distribution with specified mean
and standard deviation
RiskLognormAlt(arg1type, arg1value,
arg2type,arg2value, arg3type,arg3value)
lognormal distribution with three
parameters named arg1type, arg2type and
arg3type which can be either a percentile
between 0 and 1 or “mu”, “sigma”or "loc"
RiskLognorm2(mean,standard
deviation)
lognormal distribution generated from the
"log" of a normal distribution with specified
mean and standard deviation
RiskNegbin(s,p)
negative binomial distribution with s
successes and p probability of success on
each trial
RiskNormal(mean,standard deviation)
normal distribution with given mean and
standard deviation
RiskNormalAlt(arg1type, arg1value,
arg2type,arg2value)
normal distribution with two parameters
named arg1type and arg2type which can be
either a percentile between 0 and 1 or “mu”
or “sigma”
Chapter 9: Probability Distribution Functions
185
186
Distribution Function
Returns
RiskPareto(theta,a)
pareto distribution
RiskParetoAlt(arg1type, arg1value,
arg2type,arg2value)
pareto distribution with two parameters
named arg1type and arg2type which can be
either a percentile between 0 and 1 or “theta”
or “alpha”
RiskPareto2(b,q)
pareto distribution
RiskPareto2Alt(arg1type, arg1value,
arg2type,arg2value)
pareto distribution with two parameters
named arg1type and arg2type which can be
either a percentile between 0 and 1 or “b” or
“q”
RiskPearson5(alpha,beta)
pearson type V (or inverse gamma)
distribution with shape parameter alpha and
scale parameter beta
RiskPearson5Alt(arg1type, arg1value,
arg2type,arg2value, arg3type,arg3value)
pearson type V (or inverse gamma)
distribution with three parameters named
arg1type, arg2type and arg3type which can be
either a percentile between 0 and 1 or
“alpha”, “beta”or "loc"
RiskPearson6(beta,alpha1, alpha2)
pearson type VI distribution with scale
parameter beta and shape parameters alpha1
and alpha2
RiskPert(minimum,most likely,
maximum)
pert distribution with specified minimum,
most likely and maximum values
RiskPertAlt(arg1type, arg1value,
arg2type,arg2value, arg3type,arg3value)
pert distribution with three parameters
named arg1type, arg2type and arg3type which
can be either a percentile between 0 and 1 or
“min”, “max” or “m. likely”
RiskPoisson(lambda)
poisson distribution
RiskRayleigh(b)
rayleigh distribution with scale parameter b
RiskRayleighAlt(arg1type, arg1value,
arg2type,arg2value)
rayleigh distribution with two parameters
named arg1type and arg2type which can be
either a percentile between 0 and 1 or “beta”
or "loc"
RiskSimtable({X1,X2,...Xn})
lists values to be used in each of a series of
simulations
RiskStudent(nu)
student's t distribution with nu degrees of
freedom
RiskTriang(minimum,most likely,
maximum)
triangular distribution with defined
minimum, most likely and maximum values
Table of Available Functions
Distribution Function
Returns
RiskTriangAlt(arg1type, arg1value,
arg2type,arg2value, arg3type,arg3value)
triangular distribution with three
parameters named arg1type, arg2type and
arg3type which can be either a percentile
between 0 and 1 or “min”, “max” or “m.
likely”
RiskTrigen(bottom,most likely,top,
bottom perc.,top perc.)
triangular distribution with three points
representing value at bottom percentile, most
likely value and value at top percentile.
RiskUniform(minimum, maximum)
uniform distribution between minimum and
maximum
RiskUniformAlt(arg1type, arg1value,
arg2type,arg2value)
uniform distribution with two parameters
named arg#type which can be either a
percentile between 0 and 1 or “min” or “max”
RiskWeibull(alpha,beta)
weibull distribution with shape parameter
alpha and scale parameter beta
RiskWeibullAlt(arg1type, arg1value,
arg2type,arg2value, arg3type,arg3value)
weibull distribution with three parameters
named arg1type, arg2type and arg3type
which can be either a percentile between 0
and 1 or “alpha”, “beta”or "loc"
Chapter 9: Probability Distribution Functions
187
188
Distribution Property
Function
Specifies
RiskCollect()
Causes samples to be collected during a
simulation for the distribution in which the
Collect function is included (when
simulation settings specify Collect Samples
for Distributions Marked with Collect only)
RiskCorrmat(matrix cell range,
position,instance)
Identifies a matrix of rank correlation
coefficients and a position in the matrix for
the distribution in which the Corrmat
function is included. Instance specifies the
instance of the matrix at matrix cell range
that will be used for correlating this
distribution.
RiskDepC("ID",coefficient)
Identifies dependent variable in correlated
sampling pair with rank correlation
coefficient and "ID" identifier string
RiskFit(ProjID,FitID,"selected fit
result")
Links a data set identified by ProjID and
FitID and its fit results to the input
distribution so the input can be updated
when data changes
RiskIndepC("ID")
Identifies independent distribution in rank
correlated sampling pair — "ID" is
identifier string
RiskLock()
Blocks sampling of the distribution in which
the Lock function is included
RiskName(“input name”)
Input name for the distribution in which the
Name function is included
RiskShift(shift)
Shifts the domain of the distribution in
which the Shift function is included by shift
value
RiskTruncate(minimum, maximum)
Minimum-maximum range allowable for
samples drawn for the distribution in which
the Truncate function is included
Output Function
Specifies
RiskOutput(“name”,”output range
name”, position in range)
Simulation output cell with name, output
range name to which the output belongs, and
the position in range (Note: all arguments to
this function are optional)
Table of Available Functions
Statistics Function
Returns
RiskData(cellref or output/input name,
iteration#,Sim#)
Data value of the simulated distribution for
the entered cellref or output/input name in
iteration# and Sim#
RiskKurtosis(cellref or output/input
name, Sim#)
Kurtosis of the simulated distribution for
the entered cellref or output/input name in
Sim#
RiskMax(cellref or output/input name,
Sim#)
Maximum value of the simulated
distribution for cellref or output/input name in
Sim#
RiskMean(cellref or output/input name,
Sim#)
Mean of the simulated distribution for cellref
or output/input name in Sim#
RiskMin(cellref or output/input name,
Sim#)
Minimum value of the simulated
distribution for cellref or output/input name in
Sim#
RiskMode(cellref or output/input name,
Sim#)
Mode of the simulated distribution for cellref
or output/input name in Sim#
RiskPercentile(cellref or output/input
name, perc%, Sim#)
Percentile perc% of the simulated
distribution for cellref or output/input name in
Sim#
RiskPercentileD(cellref or
output/input name, perc%, Sim#)
Percentile perc% of the simulated
distribution for cellref or output/input name in
Sim# (perc% is a cumulative descending
percentile)
RiskRange(cellref or output/input
name, Sim#)
Range of the simulated distribution for
cellref or output/input name in Sim#
RiskSkewness(cellref or output/input
name, Sim#)
Skewness of the simulated distribution for
cellref or output/input name in Sim#
RiskStdDev(cellref or output/input
name, Sim#)
Standard deviation of the simulated
distribution for cellref or output/input name in
Sim#
RiskTarget(cellref or output/input
name, target value, Sim#)
Ascending cumulative probability of target
value in the simulated distribution for cellref
or output/input name in Sim#
RiskTargetD(cellref or output/input
name, target value, Sim#)
Descending cumulative probability of target
value in the simulated distribution for cellref
or output/input name in Sim#
RiskVariance(cellref or output/input
name, Sim#)
Variance of the simulated distribution for
cellref or output/input name in Sim#
Chapter 9: Probability Distribution Functions
189
190
Supplemental Function
Returns
RiskCurrentIter()
returns the current iteration of the
simulation
RiskCurrentSim()
returns the current simulation number
Graphing Function
Returns
RiskResultsGraph(cellRef or
output/input name ,graphType,xlFormat,
leftdelimiter,
rightdelimiter,xMin,xMax,xScale, Sim#)
Graph of the simulated distribution for the
entered cellref or output/input name in Sim#,
displayed using graphType in metafile or
xlFormat, with leftdelimiter, rightdelimiter
locations for delimiters
andxMin,xMax,xScale settings for X-axis.
Table of Available Functions
Reference: Distribution Functions
Distribution functions are listed here with their required arguments.
Optional arguments may be added to these required arguments using
the @RISK Distribution Property functions listed in the next section.
RiskBeta
Description
RiskBeta(alpha1,alpha2) specifies a beta distribution using the shape
parameters alpha1 and alpha2. These two arguments generate a beta
distribution with a minimum value of 0 and a maximum value of 1.
Examples
RiskBeta(1,2) specifies a beta distribution using the shape parameters 1 and
2.
RiskBeta(C12,C13) specifies a beta distribution using the shape parameter
alpha1 taken from cell C12 and a shape parameter alpha2 taken from cell
C13.
Guidelines
Both alpha1 and alpha2 must be greater than zero.
RiskBetaGeneral
Description
RiskBetaGeneral(alpha1,alpha2,minimum,maximum) specifies a beta
distribution with the defined minimum and maximum using the shape
parameters alpha1 and alpha2.
Examples
RiskBetaGeneral(1,2,0,100) specifies a beta distribution using the shape
parameters 1 and 2 and a minimum value of 0 and a maximum value of 100.
RiskBetaGeneral(C12,C13,D12,D13) specifies a beta distribution using the
shape parameter alpha1 taken from cell C12 and a shape parameter alpha2
taken from cell C13 and a minimum value from D12 and a maximum value of
from D13.
Guidelines
Both alpha1 and alpha2 must be greater than zero.
Chapter 9: Probability Distribution Functions
191
RiskBetaGeneralAlt
Description
RiskBetaGeneralAlt(arg1type, arg1value, arg2type,arg2value,
arg3type,arg3value, arg4type,arg4value) specifies a beta distribution with four
arguments of the type arg1type to arg4type. These arguments can be either a
percentile between 0 and 1 or “alpha1”, “alpha2”, “min” or “max”.
Examples
RiskBetaGeneralAlt("min",0,10%,1,50%,20,"max",50) specifies a beta
th
distribution with a minimum value of 0 and a maximum value of 50, a 10
th
percentile of 1 and a 50 percentile of 20.
Guidelines
Both “alpha1” and “alpha2” must be greater than zero and “max” > “min”.
RiskBetaSubj
Description
RiskBetaSubj(minimum, most likely, mean, maximum) specifies a beta
distribution with a minimum and maximum value as specified. The shape
parameters are calculated from the defined most likely value and mean.
Examples
RiskBetaSubj(0,1,2,10) specifies a beta distribution with a minimum of 0, a
maximum of 10, a most likely value of 1 and a mean of 2.
RiskBetaSubj(A1,A2,A3,A4) specifies a beta distribution with a minimum
value taken from cell A1, a maximum value taken from cell A4, a most likely
value taken from cell A2 and a mean value taken from cell A3.
Guidelines
Minimum must be less than maximum.
Most likely must be greater than minimum and less than maximum.
Mean must be greater than minimum and less than maximum.
Most likely must be greater than minimum and less than maximum.
Mean must be greater than minimum and less than maximum.
If mean is less than (maximum + minimum) / 2 then most likely must be less
than mean.
If mean is greater than (maximum + minimum) / 2 then most likely must be
greater than mean.
If most likely equals (maximum + minimum) / 2 then mean must equal most
likely.
192
Reference: Distribution Functions
RiskBinomial
Description
RiskBinomial(n, p) specifies a binomial distribution with n number of trials and
p probability of success on each trial. The number of trials is often referred to
as the number of draws or samples made. The binomial distribution is a
discrete distribution returning only integer values greater than or equal to zero.
Examples
RiskBinomial(5,.25) specifies a binomial distribution generated from 5 trials or
"draws" with a 25% probability of success on each draw.
RiskBinomial(C10*3,B10) specifies a binomial distribution generated from the
trials or "draws" given by the value in cell C10 times 3. The probability of
success on each draw is given in cell B10.
Guidelines
The number of trials n must be a positive integer greater than zero and less
than or equal to 32,767.
Probability p must be greater than or equal to zero and less than or equal to 1.
RiskChiSq
Description
RiskChiSq(v) specifies a Chi-Square distribution with v degrees of freedom.
Examples
RiskChisq(5) generates a Chi-Square distribution with 5 degrees of freedom.
RiskChisq(A7) generates a Chi-Square distribution with the degrees of
freedom parameter taken from cell A7.
Guidelines
Number of degrees of freedom v must be a positive integer.
Chapter 9: Probability Distribution Functions
193
RiskCumul
Description
RiskCumul(minimum,maximum,{X1,X2,..,Xn},{p1,p2,..,pn}) specifies a
cumulative distribution with n points. The range of the cumulative curve is set
by the minimum and maximum arguments. Each point on the cumulative curve
has a value X and a probability p. Points on the cumulative curve are specified
with increasing value and increasing probability. Any number of points may be
specified for the curve.
Examples
RiskCumul(0,10,{1,5,9},{.1,.7,.9}) specifies a cumulative curve with 3 data
points and a range of 0 to 10. The first point on the curve is 1 with a
cumulative probability of .1 (10% of the distribution values are less than or
equal to 1, 90% are greater). The second point on the curve is 5 with a
cumulative probability .7 (70% of the distribution values are less than or equal
to 5, 30% are greater). The third point on the curve is 9 with a cumulative
probability of .9 (90% of the distribution values are less than or equal to 9, 10%
are greater).
RiskCumul(100,200,A1:C1,A2:C2) specifies a cumulative distribution with 3
data points and a range of 100 to 200. Row 1 of the worksheet — A1 through
C1 — holds the values of each data point while row 2 — A2 through C2 —
holds the cumulative probability at each of the 3 points in the distribution. In
Excel braces are not required when cell ranges are used as entries to the
function.
Guidelines
The points on the curve must be specified in order of increasing value
(X1<X2<X3,...,<Xn).
The cumulative probabilities p for points on the curve must be specified in
order of increasing probability (p1<=p2<=p3,...,<=pn).
The cumulative probabilities p for points on the curve must be greater than or
equal to 0 and less than or equal to 1.
Minimum must be less than maximum. Minimum must be less than X1 and
Maximum must be greater than Xn.
194
Reference: Distribution Functions
RiskCumulD
Description
RiskCumulD(minimum,maximum,{X1,X2,..,Xn},{p1,p2,..,pn}) specifies a
cumulative distribution with n points. The range of the cumulative curve is set
by the minimum and maximum arguments. Each point on the cumulative curve
has a value X and a probability p. Points on the cumulative curve are specified
with increasing value and decreasing probability. Probabilitites entered are
cumulative descending probabilities, or the probability of a value greater than
the entered X value. Any number of points may be specified for the curve.
Examples
RiskCumulD(0,10,{1,5,9},{.9,.3,.1}) specifies a cumulative curve with 3 data
points and a range of 0 to 10. The first point on the curve is 1 with a
cumulative descending probability of .9 (10% of the distribution values are less
than or equal to 1, 90% are greater). The second point on the curve is 5 with a
cumulative descending probability .3 (70% of the distribution values are less
than or equal to 5, 30% are greater). The third point on the curve is 9 with a
cumulative descending probability of .1 (90% of the distribution values are less
than or equal to 9, 10% are greater).
RiskCumulD(100,200,A1:C1,A2:C2) specifies a cumulative distribution with 3
data points and a range of 100 to 200. Row 1 of the worksheet — A1 through
C1 — holds the values of each data point while row 2 — A2 through C2 —
holds the cumulative probability at each of the 3 points in the distribution. In
Excel braces are not required when cell ranges are used as entries to the
function.
Guidelines
The points on the curve must be specified in order of increasing value
(X1<X2<X3,...,<Xn).
The cumulative probabilities p for points on the curve must be specified in
order of decreasin cumulative descending probabilities (p1>=p2>=p3,...,>=pn).
The cumulative descending probabilities p for points on the curve must be
greater than or equal to 0 and less than or equal to 1.
Minimum must be less than maximum. Minimum must be less than X1 and
Maximum must be greater than Xn.
Chapter 9: Probability Distribution Functions
195
RiskDiscrete
Description
RiskDiscrete({X1,X2,...,Xn},{p1,p2,...,pn}) specifies a discrete distribution with
a number of outcomes equaling n. Any number of outcomes may be entered.
Each outcome has a value X and a weight p which specifies the outcome's
probability of occurrence. As with the RiskHistogrm function, weights may sum
to any value — they are normalized to probabilities by @RISK.
Examples
RiskDiscrete({0,.5},{1,1}) specifies a discrete distribution with 2 outcomes
valued 0 and .5. Each outcome has an equal probability of occurrence as the
weight for each is 1. The probability of 0 occurring is 50% (1/2) and the
probability of .5 occurring is 50% (1/2).
RiskDiscrete(A1:C1,A2:C2) specifies a discrete distribution with three
outcomes. The first row of the worksheet — A1 through C1 — holds the
values of each outcome while row 2 — A2 through C2 — holds the probability
"weight" of each occurring.
Guidelines
Weight values p must be greater than or equal to zero, and the sum of all
weights must be greater than zero.
RiskDUniform
Description
RiskDuniform({X1,X2,...,Xn}) specifies a discrete uniform distribution with n
possible outcomes with an equal probability of each outcome occurring. The
value for each possible outcome is given by the X value entered for the
outcome. Each value is equally likely to occur. To generate a discrete uniform
distribution where every integer in a range is a possible outcome, use the
RiskIntUniform function.
Examples
RiskDuniform({1,2.1,4.45,99}) specifies a discrete uniform distribution with 4
possible outcomes. The possible outcomes have the values 1, 2.1, 4.45 and
99.
RiskDuniform(A1:A5) specifies a discrete uniform distribution with 5 possible
outcomes. The possible outcomes have the values taken from cells A1
through A5.
Guidelines
None.
196
Reference: Distribution Functions
RiskErf
Description
RiskErf(h) specifies an error function with a variance parameter h. The error
function distribution is derived from a normal distribution.
Examples
RiskErf(5) generates an error function with a variance parameter 5.
RiskErf(A7) generates an error function with a variance parameter taken from
cell A7.
Guidelines
Variance parameter h must be greater than 0.
RiskErlang
Description
RiskErlang(m,beta) generates an m-erlang distribution with the specified m
and beta values. m is an integer argument for a gamma distribution and beta
is a scale parameter.
Examples
RiskErlang(5,10) specifies an m-erlang distribution with an m value of 5 and a
scale parameter of 10.
RiskErlang(A1,A2/6.76) specifies an m-erlang distribution with an m value
taken from cell A1 and a scale parameter equaling the value in cell A2 divided
by 6.76.
Guidelines
m must be a positive integer.
beta must be greater than zero.
RiskExpon
Description
RiskExpon(beta) specifies an exponential distribution with the entered beta
value. The mean of the distribution equals beta.
Examples
RiskExpon(5) specifies an exponential distribution with a beta value of 5.
RiskExpon(A1) specifies an exponential distribution with a beta value taken
from cell A1.
Guidelines
Beta must be greater than zero.
Chapter 9: Probability Distribution Functions
197
RiskExponAlt
Description
RiskExponAlt(arg1type, arg1value, arg2type,arg2value) specifies an
exponential distribution with two arguments of the type arg1type and arg2type.
arg1type and arg2type can be either a percentile between 0 and 1 or “beta” or
"loc".
Examples
RiskExponAlt("beta",1,95%,10) specifies an exponential distribution with a
beta value of 1 and a 95% percentile of 10.
Guidelines
"beta" must be greater than zero.
RiskExtValue
Description
RiskExtValue(a,b) specifies an extreme value distribution with location
parameter a and shape parameter b.
Examples
RiskExtvalue(1,2) specifies an extreme value distribution with an a value of 1
and a b value of 2.
RiskExtvalue(A1,B1) specifies an extreme value distribution with an a value
taken from cell A1 and a b value of taken from cell B1.
Guidelines
b must be greater than zero.
RiskExtValueAlt
Description
RiskExtValueAlt(arg1type, arg1value, arg2type,arg2value) specifies an
extreme value distribution with with two arguments of the type arg1type and
arg2type. These arguments can be either a percentile between 0 and 1 or
“alpha” or “beta”.
Examples
RiskExtvalueAlt(5%,10,95%,100) specifies an extreme value distribution with
th
th
a 5 percentile of 10 and a 95 percentile of 100.
Guidelines
“beta” must be greater than zero.
198
Reference: Distribution Functions
RiskGamma
Description
RiskGamma(alpha,beta) specifies a gamma distribution using the shape
parameter alpha and the scale parameter beta.
Examples
RiskGamma(1,1) specifies a gamma distribution where the shape parameter
has a value of 1 and the scale parameter has a value of 1.
RiskGamma(C12,C13) specifies a gamma distribution where the shape
parameter has a value taken from cell C12 and the scale parameter has a
value taken from cell C13.
Guidelines
Both alpha and beta must be greater than zero.
RiskGammaAlt
Description
RiskGammaAlt(arg1type, arg1value, arg2type,arg2value, arg3type,arg3value)
specifies a gamma distribution with three arguments of the type arg1type to
arg3type. These arguments can be either a percentile between 0 and 1 or
“alpha”, “beta” or "loc".
Examples
RiskGammaAlt("alpha",1,"beta",5,95%,10) specifies a gamma distribution
where the shape parameter has a value of 1, the scale parameter has a value
th
of 5 and the 95 percentile has a value of 10.
Guidelines
Both alpha and beta must be greater than zero.
Chapter 9: Probability Distribution Functions
199
RiskGeneral
Description
RiskGeneral(minimum,maximum,{X1,X2,...,Xn},{p1,p2,...,pn}) generates a
generalized probability distribution based on a density curve created using the
specified (X,p) pairs. Each pair has a value X and a probability weight p which
specifies the relative height of the probability curve at that X value. The
weights p are normalized by @RISK in determining the actual probabilities
used in sampling.
Examples
RiskGeneral(0,10,{2,5,7,9},{1,2,3,1}) specifies a general probability
distribution density function with four points. The distribution ranges from 0 to
10 with four points — 2,5,7,9 — specified on the curve. The height of the
curve at 2 is 1, at 5 is 2, at 7 is 3 and at 9 is 1. The curve intersects the X-axis
at 0 and 10.
RiskGeneral(100,200,A1:C1,A2:C2) specifies a general probability distribution
with three data points and a range of 100 to 200. The first row of the
worksheet — A1 through C1 — holds the X value of each data point while row
2 — A2 through C2 — holds the p value at each of the three points in the
distribution. Note that braces are not required when cell ranges are used as
array entries to the function.
Guidelines
Probability weights p must be greater than or equal to zero. The sum of all
weights must be greater than zero.
X values must be entered in increasing order and must fall within the
minimum-maximum range of the distribution.
Minimum value must be less than maximum.
200
Reference: Distribution Functions
RiskGeomet
Description
RiskGeomet(p) generates a geometric distribution with the probability p. The
value returned represents the number of failures prior to a success on a series
of independent trials. There is a p probability of success on each trial. The
geometric distribution is a discrete distribution returning only integer values
greater than or equal to zero.
Examples
RiskGeomet(.25) specifies a geometric distribution with a 25% probability of
success on each trial.
RiskGeomet(A18) specifies a geometric distribution with a probability of
success on each trial taken from cell A18.
Guidelines
Probability p must be greater than zero and less than or equal to one.
Chapter 9: Probability Distribution Functions
201
RiskHistogrm
Description
RiskHistogrm(minimum,maximum,{p1,p2,...,pn}) specifies a user-defined
histogram distribution with a range defined by the specified minimum and
maximum values. This range is divided into n classes. Each class has a
weight p reflecting the probability of occurrence of a value within the class.
These weights may be any values — the only important factor is the weight of
one class relative to the others. This means that the sum of all the weights
need not equal 100%. @RISK normalizes the class probabilities for you.
Normalizing is done by summing all specified weights and dividing each weight
by this sum.
Examples
RiskHistogrm(10,20,{1,2,3,2,1}) specifies a histogram with a minimum value
of 10 and a maximum value of 20. This range is divided into 5 equal length
classes as there are 5 probability values. The probability weights for the five
classes are the arguments 1, 2, 3, 2 and 1. The actual probabilities which
would correspond with these weights are 11.1% (1/9), 22.2% (2/9), 33.3%
(3/9), 22.2% (2/9) and 11.1% (1/9). Division by 9 normalizes these values so
that their sum now equals 100%.
RiskHistogrm(A1,A2,B1:B3) specifies a histogram with a minimum value
taken from cell A1 and a maximum value taken from cell A2. This range is
divided into 3 equal length classes as there are 3 probability values. The
probability weights are taken from cells B1 through B3.
Guidelines
Weight values p must be greater than or equal to zero, and the sum of all
weights must be greater than zero.
202
Reference: Distribution Functions
RiskHypergeo
Description
RiskHypergeo(n,D,M) specifies a hypergeometric distribution with sample size
n, number of items of a certain type equaling D and population size M. The
hypergeometric distribution is a discrete distribution returning only nonnegative integer values.
Examples
RiskHypergeo(50,10,1000) returns a hypergeometric distribution generated
using a sample size of 50, 10 items of the relevant type and a population size
of 1000.
RiskHypergeo(A6,A7,A8) returns a hypergeometric distribution generated
using a sample size taken from cell A6, a number of items taken from cell A7
and a population size taken from cell A8.
Guidelines
All arguments — n, D and M — must be positive integer values.
The value for sample size n must be less than or equal to the population size
M.
The value for number of items D must be less than or equal to the population
size M.
RiskIntUniform
Description
RiskIntUniform(minimum,maximum) specifies a uniform probability
distribution with the entered minimum and maximum values. Only integer
values across the range of the uniform distribution can occur and each has an
equal likelihood of occurrence.
Examples
RiskIntUniform(10,20) specifies a uniform distribution with a minimum value
of 10 and a maximum value of 20.
RiskIntUniform(A1+90,B1) specifies a uniform distribution with a minimum
value equaling the value in cell A1 plus 90 and a maximum value taken from
cell B1.
Guidelines
The minimum value entered must be less than the maximum value.
Chapter 9: Probability Distribution Functions
203
RiskInvgauss
Description
RiskInvgauss(mu,lambda) specifies an inverse gaussian distribution with
mean mu and shape parameter lambda.
Examples
RiskInvgauss(5,2) returns an inverse gaussian distribution with a mu value of
5 and a lambda value of 2.
RiskInvgauss(B5,B6) returns an inverse gaussian distribution with a mu value
taken from cell B5 and a lambda value taken from cell B6.
Guidelines
mu must be greater than zero.
lambda must be greater than zero.
RiskInvgaussAlt
Description
RiskInvgaussAlt(arg1type, arg1value, arg2type,arg2value,
arg3type,arg3value) specifies an inverse gaussian distribution with three
arguments of the type arg1type to arg3type. These arguments can be either a
percentile between 0 and 1 or “mu” , “lambda” or "loc".
Examples
RiskInvgaussAlt("mu",10,5%,1,95%,25) returns an inverse gaussian
th
th
distribution with a mu value of 1, a 5 percentile of 1 and a 95 percentile of
25.
Guidelines
mu must be greater than zero.
lambda must be greater than zero.
RiskLogistic
Description
RiskLogistic(alpha,beta) specifies a logistic distribution with the entered alpha
and beta values.
Examples
RiskLogistic(10,20) returns a logistic distribution generated using an alpha
value of 10 and a beta value of 20.
RiskLogistic(A6,A7) returns a logistic distribution generated using an alpha
value taken from cell A6 and a beta value taken from cell A7.
Guidelines
Beta must be a positive value.
204
Reference: Distribution Functions
RiskLogisticAlt
Description
RiskLogisticAlt(arg1type, arg1value, arg2type,arg2value) specifies a logistic
distribution with two arguments of the type arg1type and arg2type. These
arguments can be either a percentile between 0 and 1 or “alpha” or “beta”.
Examples
RiskLogisticAlt(5%,1,95%,100) returns a logistic distribution with a 5
th
percentile of 1 and a 95 percentile of 100.
Guidelines
“Beta” must be a positive value.
th
RiskLogLogistic
Description
RiskLoglogistic(gamma,beta,alpha) specifies a log-logistic distribution with
location parameter gamma and shape parameter alpha and scale parameter
beta.
Examples
RiskLoglogistic(-5,2,3) returns a log-logistic distribution generated using a
gamma value of -5, a beta value of 2, and an alpha value of 3.
RiskLoglogistic(A1,A2,A3) returns a log-logistic distribution generated using
a gamma value taken from cell A1, a beta value taken from cell A2, and an
alpha value taken from cell A3.
Guidelines
Alpha must be greater than zero.
Beta must be greater than zero.
RiskLogLogisticAlt
Description
RiskLoglogisticAlt(arg1type, arg1value, arg2type,arg2value,
arg3type,arg3value) specifies a log-logistic distribution distribution with three
arguments of the type arg1type to arg3type. These arguments can be either a
percentile between 0 and 1 or “gamma”, “beta” or “alpha”.
Examples
RiskLoglogisticAlt("gamma",5,"beta",2,90%,10) returns a log-logistic
th
distribution generated using a gamma value of 5, a beta value of 2, and a 90
percentile of 10.
Guidelines
”Alpha” must be greater than zero.
“Beta” must be greater than zero
Chapter 9: Probability Distribution Functions
205
RiskLognorm
Description
RiskLognorm(mean,standard deviation) specifies a lognormal distribution with
the entered mean and standard deviation. The arguments for this form of the
lognormal distribution specify the actual mean and standard deviation of the
generated lognormal probability distribution.
Examples
RiskLognorm(10,20) specifies a lognormal distribution with a mean of 10 and
a standard deviation of 20.
RiskLognorm(C10*3.14,B10) specifies a lognormal distribution with a mean
equaling the value in cell C10 times 3.14 and a standard deviation equaling the
value in cell B10.
Guidelines
The mean and standard deviation must be greater than 0.
RiskLognormAlt
Description
RiskLognormAlt(arg1type, arg1value, arg2type,arg2value,
arg3type,arg3value) specifies a lognormal distribution distribution with three
arguments of the type arg1type to arg3type. These arguments can be either a
percentile between 0 and 1 or “mu” , “sigma” or "loc".
Examples
RiskLognormAlt("mu",2,"sigma",5,95%,30) specifies a lognormal
th
distribution with a mean of 2 and a standard deviation of 5 and a 95
percentile of 30.
Guidelines
The “mu” and “sigma” must be greater than 0.
206
Reference: Distribution Functions
RiskLognorm2
Description
RiskLognorm2(mean of corresponding normal dist.,std. dev. of normal)
specifies a lognormal distribution where the entered mean and standard
deviation equal the mean and standard deviation of the corresponding normal
distribution. The arguments entered are the mean and standard deviation of
the normal distribution for which an exponential of the values in the distribution
was taken to generate the desired lognormal.
Examples
RiskLognorm2(10,20) specifies a lognormal distribution generated by taking
the exponential of the values from a normal distribution with a mean of 10 and
a standard deviation of 20.
RiskLognorm2(C10*3.14,B10) specifies a lognormal distribution generated by
taking the exponential of the values from a normal distribution with a mean
equaling the value in cell C10 times 3.14 and a standard deviation equaling the
value in cell B10.
Guidelines
The standard deviation must be greater than 0.
RiskNegbin
Description
RiskNegbin(s,p) specifies a negative binomial distribution with s number of
successes and p probability of success on each trial. The negative binomial
distribution is a discrete distribution returning only integer values greater than
or equal to zero.
Examples
RiskNegbin(5,.25) specifies a negative binomial distribution with 5 successes
with a 25% probability of success on each trial.
RiskNegbin(A6,A7) specifies a negative binomial distribution with the number
of successes taken from cell A6 and a probability of success taken from cell
A7.
Guidelines
Number of successes s must be a positive integer less than or equal to
32,767.
Probability p must be greater than zero and less than or equal to one.
Chapter 9: Probability Distribution Functions
207
RiskNormal
Description
RiskNormal(mean,standard deviation) specifies a normal distribution with the
entered mean and standard deviation. This is the traditional "bell shaped"
curve applicable to distributions of outcomes in many data sets.
Examples
RiskNormal(10,2) specifies a normal distribution with a mean of 10 and a
standard deviation of 2.
RiskNormal(SQRT(C101),B10) specifies a normal distribution with a mean
equaling the square root of the value in cell C101 and a standard deviation
taken from cell B10.
Guidelines
The standard deviation must be greater than 0.
RiskNormalAlt
Description
RiskNormaAlt(arg1type, arg1value, arg2type,arg2value) specifies a normal
distribution with two arguments of the type arg1type and arg2type. These
arguments can be either a percentile between 0 and 1 or “mu" or “sigma”.
Examples
RiskNormalAlt(5%,1,95%,10) specifies a normal distribution with a 5
th
percentile of 1 and a 95 percentile of 10.
Guidelines
"sigma" must be greater than 0.
th
RiskPareto
Description
RiskPareto(theta,a) specifies a pareto distribution with the entered theta and a
values.
Examples
RiskPareto(5,5) specifies a pareto distribution with a theta value of 5 and an a
value of 5.
RiskPareto(A10,A11+A12) specifies a pareto distribution with a theta value
taken from cell A10 and an a value given by the result of the expression
A11+A12.
Guidelines
Theta must be greater than 1.
The a argument must be greater than 0.
208
Reference: Distribution Functions
RiskParetoAlt
Description
RiskParetoAlt(arg1type, arg1value, arg2type,arg2value) specifies a pareto
distribution with two arguments of the type arg1type and arg2type. These
arguments can be either a percentile between 0 and 1 or “theta" or “alpha”.
Examples
RiskParetoAlt(5%,1,95%,4) specifies a pareto distribution with a 5 percentile
th
of 1 and a 95 percentile of 4.
Guidelines
"Theta" must be greater than 1.
"alpha" must be greater than 0.
th
RiskPareto2
Description
RiskPareto2(b,q) specifies a pareto distribution with the entered b and q
values.
Examples
RiskPareto2(5,5) specifies a pareto distribution with a b value of 5 and a q
value of 5.
RiskPareto2(A10,A11+A12) specifies a pareto distribution with a b value
taken from cell A10 and a q value given by the result of the expression
A11+A12.
Guidelines
b must be greater than 0.
q must be greater than 0.
RiskPareto2Alt
Description
RiskPareto2Alt(arg1type, arg1value, arg2type,arg2value) specifies a pareto
distribution with two arguments of the type arg1type and arg2type. These
arguments can be either a percentile between 0 and 1 or “b" or “q”.
Examples
RiskPareto2Alt(5%,.05,95%,5) specifies a pareto distribution with a 5
th
percentile of .05 and a 95 percentile of 5.
Guidelines
"b" must be greater than 0.
"q" must be greater than 0.
Chapter 9: Probability Distribution Functions
th
209
RiskPearson5
Description
RiskPearson5(alpha,beta) specifies a pearson type V distribution with shape
parameter alpha and scale parameter beta.
Examples
RiskPearson5(1,1) specifies a pearson type V distribution where the shape
parameter has a value of 1 and the scale parameter has a value of 1.
RiskPearson5(C12,C13) specifies a pearson type V distribution where the
shape parameter has a value taken from cell C12 and the scale parameter has
a value taken from cell C13.
Guidelines
Alpha must be greater than zero
Beta must be greater than zero.
RiskPearson5Alt
Description
RiskPearson5Alt(arg1type, arg1value, arg2type,arg2value,
arg3type,arg3value) specifies a pearson type Vdistribution with three
arguments of the type arg1type to arg3type. These arguments can be either a
percentile between 0 and 1 or “alpha” , “beta” or "loc".
Examples
RiskPearson5Alt("alpha",2,"beta",5,95%,30) specifies a pearson type V
th
distribution with a alpha of 2 and a beta of 5 and a 95 percentile of 30.
Guidelines
"Alpha" must be greater than zero
"Beta" must be greater than zero.
RiskPearson6
Description
RiskPearson6(alpha1,alpha2,beta) specifies a pearson type VI distribution
with scale parameter beta and shape parameters alpha1 and alpha2.
Examples
RiskPearson6(5,1,2) specifies a pearson type VI distribution where beta has a
value of 2, alpha2 has a value of 1 and alpha1 has a value of 5.
RiskPearson6(E3,F3,D3) specifies a pearson type VI distribution where beta
has a value taken from cell D3, alpha1 has a value taken from cell E3, and
alpha2 has a value taken from cell F3.
Guidelines
Alpha1 must be greater than zero.
Alpha2 must be greater than zero.
Beta must be greater than zero.
210
Reference: Distribution Functions
RiskPert
Description
RiskPert(minimum, most likely, maximum) specifies a PERT distribution (as
special form of the beta distribution) with a minimum and maximum value as
specified. The shape parameter is calculated from the defined most likely
value.
Examples
RiskPert(0,2,10) specifies a beta distribution with a minimum of 0, a maximum
of 10, and a most likely value of 2.
RiskPert (A1,A2,A3) specifies a PERT distribution with a minimum value
taken from cell A1, a maximum value taken from cell A3, and a most likely
value taken from cell A2.
Guidelines
Minimum must be less than maximum.
Most likely must be greater than minimum and less than maximum.
RiskPertAlt
Description
RiskPertAlt(arg1type, arg1value, arg2type,arg2value, arg3type,arg3value)
specifies a PERT distribution with three arguments of the type arg1type to
arg3type. These arguments can be either a percentile between 0 and 1 or
“min” , “m. likely” or "max".
Examples
RiskPertAlt("min",2,"m. likely",5,95%,30) specifies a PERT distribution with a
th
minimum of 2 and a most likely value of 5 and a 95 percentile of 30.
Guidelines
"min" must be less than or equal to the "m. likely" value.
"m. likely" must be less than or equal to the "max" value.
The "min" must be less than the "max" value.
RiskPoisson
Description
RiskPoisson(lambda) specifies a poisson distribution with the specified
lambda value. The argument lambda is also the same as the mean of the
poisson distribution. The poisson distribution is a discrete distribution returning
only integer values greater than or equal to zero.
Examples
RiskPoisson(5) specifies a poisson distribution with a lambda of 5.
RiskPoisson(A6) specifies a poisson distribution with a lambda value taken
from cell A6.
Guidelines
Lambda must be greater than zero.
Chapter 9: Probability Distribution Functions
211
RiskRayleigh
Description
RiskRayleigh(b) specifies a rayleigh distribution with mode b.
Examples
RiskRayleigh(3) specified a rayleigh distribution with a mode of 3.
RiskRayleigh(C7) specifies a rayleigh distribution with a mode taken from the
value in cell C7.
Guidelines
b must be greater than zero.
RiskRayleighAlt
Description
RiskRayleighAlt(arg1type, arg1value, arg2type,arg2value) specifies a
rayleigh distribution with two arguments of the type arg1type and arg2type.
These arguments can be either a percentile between 0 and 1 or “beta" or “loc”.
Examples
RiskRayleighAlt(5%,1,95%,10) specifies a normal distribution with a 5
th
percentile of 1 and a 95 percentile of 10.
Guidelines
"beta" must be greater than zero.
th
RiskSimtable
Description
RiskSimtable({val1,val2,...,valn}) specifies a list of values which will be used
sequentially in individual simulations executed during a Sensitivity Simulation.
In a Sensitivity Simulation the number of simulations, set using the Iterations
Simulations command, is greater than one. In a single simulation or a normal
recalculation RiskSimtable returns the first value in the list. Any number of
RiskSimtable functions may be included in a single worksheet. As with other
functions, the arguments of RiskSimtable may include distribution functions.
Examples
RiskSimtable({10,20,30,40}) specifies four values to be used in each of four
simulations. In Simulation #1 the SIMTABLE function will return 10, Simulation
#2 the value 20 and so on.
RiskSimtable(A1:A3) specifies a list of three values for three simulations. In
Simulation #1 the value from cell A1 will be returned. In Simulation #2 the
value from cell A2 will be returned. In Simulation #3 the value from cell A3 will
be returned.
Guidelines
Any number of arguments may be entered.
The number of simulations executed must be less than or equal to the number
of arguments. If the number of arguments is less than the number of an
executing simulation, ERR will be returned by the function for that simulation.
212
Reference: Distribution Functions
RiskStudent
Description
RiskStudent(nu) specified a student's t distribution with nu degrees of
freedom.
Examples
RiskStudent(10) specifies a student's t distribution with 10 degrees of
freedom.
RiskStudent(J2) specifies a student's t distribution with the degrees of
freedom taken from the value in cell J2.
Guidelines
Nu must be a positive integer.
RiskTriang
Description
RiskTriang(minimum,most likely,maximum) specifies a triangular distribution
with three points — a minimum, most likely and maximum. The direction of the
"skew" of the triangular distribution is set by the size of the most likely value
relative to the minimum and the maximum.
Examples
RiskTriang(100,200,300) specifies a triangular distribution with a minimum
value of 100, a most likely value of 200 and a maximum value of 300.
RiskTriang(A10/90,B10,500) specifies a triangular distribution with a minimum
value equaling the value in cell A10 divided by 90, a most likely value taken
from cell B10 and a maximum value of 500.
Guidelines
The minimum value must be less than or equal to the most likely value.
The most likely value must be less than or equal to the maximum value.
The minimum value must be less than the maximum value.
RiskTriangAlt
Description
RiskTriangAlt(arg1type, arg1value, arg2type,arg2value, arg3type,arg3value)
specifies a triangular distribution with three arguments of the type arg1type to
arg3type. These arguments can be either a percentile between 0 and 1 or
“min” , “m. likely” or "max".
Examples
RiskTriangAlt("min",2,"m. likely",5,95%,30) specifies a triangular distribution
th
with a minimum of 2 and a most likely value of 5 and a 95 percentile of 30.
Guidelines
"min" must be less than or equal to the "m. likely" value.
"m. likely" must be less than or equal to the "max" value.
The "min" must be less than the "max" value.
Chapter 9: Probability Distribution Functions
213
RiskTrigen
Description
RiskTrigen(bottom value,most likely value,top value, bottom perc., top perc.)
specifies a triangular distribution with three points — one at the most likely
value and two at the specified bottom and top percentiles. The bottom
percentile and top percentile are values between 0 and 100. Each percentile
value gives the percentage of the total area under the triangle that falls to the
left of the entered point. Use of the RiskTrigen function avoids the problem of
the minimum and maximum values not actually being possible occurrences in
the standard RiskTriang function. This is because in the RiskTriang function
these are the points where the distribution intersects the X-axis, or points of
zero probability.
Examples
RiskTrigen(100,200,300,10,90) specifies a triangular distribution with a 10th
percentile value of 100, a most likely value of 200 and a 90th percentile value
of 300.
RiskTrigen(A10/90,B10,500,30,70) specifies a triangular distribution with a
30th percentile value equaling the value in cell A10 divided by 90, a most likely
value taken from cell B10 and a 70th percentile value of 500.
Guidelines
The bottom percentile value must be less than or equal to the most likely
value.
The most likely value must be less than or equal to the top percentile value.
The bottom percentile value must be less than the top percentile value.
RiskUniform
Description
RiskUniform(minimum,maximum) specifies a uniform probability distribution
with the entered minimum and maximum values. Every value across the range
of the uniform distribution has an equal likelihood of occurrence.
Examples
RiskUniform(10,20) specifies a uniform distribution with a minimum value of
10 and a maximum value of 20.
RiskUniform(A1+90,B1) specifies a uniform distribution with a minimum value
equaling the value in cell A1 plus 90 and a maximum value taken from cell B1.
Guidelines
The minimum value entered must be less than the maximum value.
214
Reference: Distribution Functions
RiskUniformAlt
Description
RiskUniformAlt(arg1type, arg1value, arg2type,arg2value) specifies a uniform
distribution with two arguments of the type arg1type and arg2type. These
arguments can be either a percentile between 0 and 1 or “min" or “max”.
Examples
RiskUniformAlt(5%,1,95%,10) specifies a uniform distribution with a 5
th
percentile of 1 and a 95 percentile of 10.
Guidelines
The "min" value entered must be less than the "max" value.
th
RiskWeibull
Description
RiskWeibull(alpha,beta) generates a weibull distribution with the shape
parameter alpha and a scale parameter beta. The weibull distribution is a
continuous distribution whose shape and scale vary greatly depending on the
argument values entered.
Examples
RiskWeibull(10,20) generates a weibull distribution with a shape parameter 10
and a scale parameter 20.
RiskWeibull(D1,D2) generates a weibull distribution with a shape parameter
taken from cell D1 and a scale parameter taken from cell D2.
Guidelines
Both shape parameter alpha and scale parameter beta must be greater than
zero.
RiskWeibullAlt
Description
RiskWeibullAlt(arg1type, arg1value, arg2type,arg2value, arg3type,arg3value)
specifies a weibull distribution with three arguments of the type arg1type to
arg3type. These arguments can be either a percentile between 0 and 1 or
“alpha” , “beta” or "loc".
Examples
RiskWeibullAlt("alpha",1,"beta",1,95%,3) specifies a weibull distribution with
th
a alpha of 1 and a beta of 1 and a 95 percentile of 3.
Guidelines
Both shape parameter "alpha" and scale parameter "beta" must be greater
than zero.
Chapter 9: Probability Distribution Functions
215
216
Reference: Distribution Functions
Reference: Distribution Property
Functions
The following functions are used to add optional arguments to
distribution functions. The arguments added by these functions are
not required, but can be added as needed.
Optional arguments are specified using @RISK distribution property
functions that are embedded inside of a distribution function.
RiskCollect
Description
RiskCollect() identifies specific distribution functions whose samples are
collected during a simulation and whose:
statistics are displayed
data points are available
sensitivities and scenario values are calculated
When RiskCollect is used and Inputs Marked With Collect is selected for
Collect Distribution Samples in the Simulation Settings dialog, only functions
identified by RiskCollect are displayed in the Results window Explorer list.
Earlier versions of @RISK had the RiskCollect function entered by placing it in
the cell formula immediately preceding the distribution function for which
samples will be collected, e.g.:
=RiskCollect()+RiskNormal(10,10)
RiskCollect is typically used when a large number of distribution functions are
present in a simulated worksheet, but sensitivities and scenario analyses are
desired on only a pre-identified subset of important distributions. It can also be
used to bypass Windows memory constraints that keep sensitivities and
scenario analyses from being performed on all functions in a large simulation.
Examples
RiskNormal(10,2,RiskCollect()) collects samples from the probability
distribution RiskNormal(10,2).
Guidelines
The “Inputs Marked WithCollect" box in Simulation Settings must be selected
for COLLECT functions to take effect.
Chapter 9: Probability Distribution Functions
217
RiskCorrmat
Description
218
RiskCorrmat(matrix cell range,position,instance) identifies a distribution
function belonging to a set of correlated distribution functions. The function is
used to specify multivariate correlation. RiskCorrmat identifies 1) a matrix of
rank correlation coefficients and 2) the location in the matrix of the coefficients
used in correlating the distribution function which follows the RiskCorrmat
function.
Correlated distribution functions typically are defined using the @RISK Model
Window Model menu Correlate Distributions command; however, the same
type of correlation may be directly entered in your spreadsheet using the
RiskCorrmat function.
The matrix identified by the matrix cell range is a matrix of rank correlation
coefficients. Each element (or cell) in the matrix contains a correlation
coefficient. The number of distribution functions correlated by the matrix
equals the number of rows or columns in the matrix. The argument position
specifies the column (or row) in the matrix to use in correlating the distribution
function which follows the RiskCorrmat function. The coefficients located in
the column (or row) identified by position are used in correlating the identified
distribution function with each of the other correlated distribution functions
represented by the matrix. The value in any given cell in the matrix gives the
correlation coefficient between 1) the distribution function whose RiskCorrmat
position equals the column coordinate of the cell and 2) the distribution
function whose RiskCorrmat position equals the row coordinate of the cell.
Positions (and coordinates) range from 1 to N, where N is the number of
columns or rows in the matrix.
The instance argument is optional and is used when multiple groups of
correlated inputs use the same matrix of correlation coefficients. Instance is
an integer or string argument and all inputs in a correlated group of inputs
share the same instance value or string. String arguments used to specify
instance need to be in quotes.
The RiskCorrmat function generates correlated sets of random numbers to be
used in sampling each of the correlated distribution functions. The sample
matrix of rank correlation coefficients calculated on the correlated set of
random numbers approximates as closely as possible the target correlation
coefficient matrix which was entered in the worksheet.
Correlated sets of random numbers specified by the RiskCorrmat function are
generated when the first RiskCorrmat function is called during a simulation.
This is usually during the first iteration of the simulation. This may cause a
delay while values are sorted and correlated. The length of the delay is
proportional to the number of iterations and the number of correlated variables.
The method used for generating multiple rank correlated distribution functions
is based on the method used for DEPC and INDEPC functions. For more
information on this, see the section Understanding Rank Order Correlation
Coefficient Values under the DEPC function in this section.
Entry of CORRMAT functions outside of a distribution function (in the form
RiskCorrmat+distribution function) as done in earlier versions of @RISK is still
supported. However, these functions will be moved inside the distribution
function they are correlating whenever the formula or correlated distribution is
edited in the @RISK Model window.
Reference: Distribution Property Functions
Examples
RiskNormal(10,10, RiskCorrmat(C10:G14,1,”Matrix 1”)) specifies that the
sampling of the distribution Normal(10,10) will be controlled by the first column
of the 5 by 5 matrix of correlation coefficient values located in the cell range
C10:G14. There are five correlated distributions represented by the matrix as
there are five columns in the matrix. The coefficients used in correlating
Normal(10,10) with the other four correlated distributions are found in row 1 of
the matrix. This distribution - Normal(10,10) - will be correlated with the other
distributions that include the instance Matrix 1 in their embedded RiskCorrmat
functions.
Guidelines
Multiple matrices of correlation coefficients may be used in a single worksheet.
The sample matrix of correlation coefficients (calculated on the correlated
random numbers generated by @RISK) approximates as closely as possible
the target correlation coefficient matrix located in the matrix cell range. It is
possible that the target coefficients are inconsistent and approximation cannot
be performed. @RISK will notify the user if this occurs.
Any blank cells or labels in the matrix cell range specify a correlation
coefficient of zero.
Position may be a value between 1 and N, where N is the number of columns
in the matrix.
The matrix cell range must be square, that is, with an equal number of rows
and columns.
By default @RISK uses the correlation coefficients in the matrix cell range on a
rowwise basis. Because of this only the top 'half' of the matrix — the top right
of the matrix when it is split on the diagonal — needs to be entered.
Correlation coefficients must be less than or equal to 1 and greater than or
equal to -1. Coefficients on the diagonal of the matrix must equal 1.
Chapter 9: Probability Distribution Functions
219
RiskDepC
Description
220
RiskDepC("ID",coefficient) designates a dependent variable in a correlated
sampling pair. The ID in quotes is the string used to identify the independent
variable being correlated with. The string must be in quotes. This is the same
ID used in the RiskIndepC function for the independent variable. The
coefficient entered is the rank-order correlation coefficient which describes the
relationship of the values sampled for the distributions identified by the
RiskDepC and RiskIndepC. The RiskDepC function is used with the
distribution function which specifies the possible values for the dependent
variable
Understanding Rank-Order Correlation Coefficient Values
The rank-order correlation coefficient was developed by C. Spearman in the
early 1900's. It is calculated using rankings of values, not actual values
themselves (as is the linear correlation coefficient). A value's "rank" is
determined by its position within the min-max range of possible values for the
variable.
The coefficient is a value between -1 and 1 which represents the desired
degree of correlation between the two variables during sampling. Positive
coefficient values indicate a positive relationship between the two variables —
when the value sampled for one is high, the value sampled for the second will
also tend to be high. Negative coefficient values indicate an inverse
relationship between the two variables — when the value sampled for one is
high, the value sampled for the second will tend to be low.
@RISK generates rank-correlated pairs of sampled values in a two step
process. First, a set of randomly distributed "rank scores" are generated for
each variable. If 100 iterations are to be run, for example, 100 scores are
generated for each variable. (Rank scores are simply values of varying
magnitude between a minimum and maximum. @RISK uses van der
Waerden scores based on the inverse function of the normal distribution).
These rank scores are then rearranged to give pairs of scores which generate
the desired rank correlation coefficient. For each iteration there is a pair of
scores, with one score for each variable.
In the second step, a set of random numbers (between 0 and 1) to be used in
sampling is generated for each variable. Again, if 100 iterations are to be run,
100 random numbers are generated for each variable. These random
numbers are then ranked smallest to largest. For each variable, the smallest
random number is then used in the iteration with the smallest rank score, the
second smallest random number is used in the iteration with the second
smallest rank score and so on. This ordering based on ranking continues for
all random numbers, up to the point where the largest random number is used
in the iteration with the largest rank score.
This method of correlation is known as a "distribution-free" approach because
any types of distributions may be correlated. Although the samples drawn for
the two distributions are correlated, the integrity of the original distributions are
maintained. The resulting samples for each distribution reflect the input
distribution function from which they were drawn.
Reference: Distribution Property Functions
Earlier versions of @RISK had the RiskDepC function entered by placing it in
the cell formula immediately preceding the distribution function which will be
correlated, e.g.:
=RiskDepC(”Price 1”,.9)+RiskNormal(10,10)
This form of function entry is still supported. However, these functions will be
moved inside the distribution function they are correlating whenever the
formula or correlated distribution is edited in the @RISK Model window.
The correlation coefficient generated by using RiskDepC and RiskIndepC is
approximate. The generated coefficient will more closely approximate the
desired coefficient as increasing numbers of iterations are executed. There
may be a delay at the start of a simulation when distributions are correlated
when RiskDepC and RiskIndepC are used. The length of the delay is
proportional to the number of RiskDepC functions in the worksheet and the
number of iterations to be performed. See the @RISK Modeling Techniques
chapter for a detailed example of dependency relationships
Examples
RiskNormal(100,10, RiskDepC("Price",.5)) specifies that the sampling of the
distribution RiskNormal(100,10) will be correlated with the sampling of the
distribution identified with the function RiskIndepC("Price"). The sampling of
RiskNormal(100,10) will be positively correlated with the sampling of the
distribution identified with the function RiskIndepC("Price") as the coefficient is
greater than 0.
Guidelines
Coefficient must be a value greater than or equal to -1 and less than or equal
to 1. "ID" must be the same string of characters used to identify the
independent variable in the RiskIndepC function. “ID” may be a reference to
cell that contains an identifier string.
Chapter 9: Probability Distribution Functions
221
RiskFit
Description
RiskFit(ProjID,FitID,"selected fit result") links a data set and its fit results to
the input distribution the RiskFit function is used in. The ProjID and FitID are
internal @RISK IDs that identify the fit from which the distribution was
selected and should not be changed. The selected fit result in quotes is a
string used to identify the type of fit result to select. The RiskFit function is
used to link an input to the fit results for a data set so that when the data is
changed the input distribution selected from the fit can be updated.
The selected fit result can be any of the following entries:
Best Chi-Sq, indicating the best fitting distribution from the Chi-Sq. test
should be used
Best A-D, indicating the best fitting distribution from the Anderson-Darling
test should be used
Best K-S, indicating the best fitting distribution from the Kolmogorov-Smirnov
test should be used.
Best RMS Err, indicating the best fitting distribution from the RMS Error test
should be used
A distribution name, such as "Normal", indicating that the best-fitting
distribution of the entered type should be used.
What Happens When Data Changes When RiskFit is Used
The RiskFit function "hot-links" a distribution function to a data set and the fit
of that data set. The data used in a fit can be either in Excel or on a fit tab in
the @RISK – Model window. When the fitted data changes in either one of
these locations, the following actions take place:
@RISK re-runs the fit using the current settings on the fit tab where the fit
was originally run
The distribution function that includes the RiskFit function that references the
fit is changed to reflect the new fit results. The changed function replaces the
original one in Excel. If, for example, the distribution function's RiskFit
argument specified "Best Chi-sq" for selected fit result, the new best-fitting
distribution based on the Chi-Sq test would replace the original one. This
new function would also include the same RiskFit function as the original
one.
@RISK can perform the above actions either 1) immediately when the data
and fit have changed or 2) when a simulation starts or the list of Outputs and
Inputs is generated. The Update method used is specified using the @RISK
Model window Fitting menu Update Linked @RISK Functions command.
Examples
RiskNormal(2.5, 1, RiskFit(71367, 59129, "Best A-D")) specifies that the
best fitting distribution from the Anderson-Darling test for the fitted data
associated with the specified ProjID and FitID is a Normal distribution with a
mean of 2.5 and a standard deviation of 1.
Guidelines
n/a
222
Reference: Distribution Property Functions
RiskIndepC
Description
RiskIndepC("ID") designates an independent variable in a rank correlated
sampling pair. The ID in quotes is a string used to identify the independent
variable. The RiskIndepC function is used with the distribution function which
specifies the possible values for the independent variable. RiskIndepC is just
an identifier.
Earlier versions of @RISK had the RiskIndepC function entered by placing it
in the cell formula immediately preceding the distribution function which will
be correlated, e.g.:
=RiskIndepC(”Price 1”)+RiskNormal(10,10)
This form of function entry is still supported. However, these functions will be
moved inside the distribution function they are correlating whenever the
formula or correlated distribution is edited in the @RISK Model window.
Examples
RiskNormal(10,10, RiskIndepC("Price")) identifies the function
NORMAL(10,10) as the independent variable "Price". This function will be
used as the independent variable anytime a DEPC function with the ID string
"Price" is used.
Guidelines
"ID" must be the same string of characters used to identify the dependent
variable in the DEPC function. "ID" must be the same string of characters
used to identify the independent variable in the INDEPC function. “ID” may
be a reference to cell that contains an identifier string.
A maximum of 64 individual INDEPC functions may be used in a single
worksheet. Any number of DEPC functions may be dependent on those
INDEPC functions
See the @RISK Modeling Techniques chapter for a detailed example of
dependency relationships.
Chapter 9: Probability Distribution Functions
223
RiskLock
Description
RiskLock() keeps a distribution from being sampled in a simulation.
Locking an input distribution causes it to return the value set in using the
Simulation Settings standard recalc options.
Examples
RiskNormal(10,2,RiskLock()) stops samples from being drawn from the
probability distribution RiskNormal(10,2).
Guidelines
None
RiskName
Description
RiskName(“Input Name”) names the input distribution in which the function is
used as an argument. This name will appear in both the @RISK Model
Window Outputs and Inputs list and in any reports and graphs which include
simulation results for the input.
Examples
RiskTriang(10,20,30,RiskName(“Price”)) gives the name Price to the input
described by the probability distribution RiskTriang(10,20,30).
RiskTriang(10,20,30,RiskName(A10)) gives the name contained in the cell
A10 to the input described by the probability distribution
RiskTriang(10,20,30).
Guidelines
The name specified must be entered in quotes.
Any valid cell references can be used to define a name.
RiskShift
Description
RiskShift(shift amount) shifts the domain of the distribution in which it is
used by the entered shift amount. This function is automatically entered
when a fit result includes a shift factor.
Examples
RiskBeta(10,2,RiskShift(100)) shifts the domain of the distribution
RiskBeta(10,2) by 100 .
Guidelines
None.
224
Reference: Distribution Property Functions
RiskTruncate
Description
RiskTruncate(minimum,maximum) truncates the input distribution in which
the function is used as an argument. Truncating a distribution restricts
samples drawn from the distribution to values within the entered minimummaximum range. Truncated forms of specific distributions available in earlier
versions of @RISK (such as RiskTnormal and RiskTlognorm) are still
supported.
Examples
RiskTriang(10,20,30,RiskTruncate(13,27)) restricts the samples drawn from
the probability distribution RiskTriang(10,20,30) to a minimum possible value
of 13 and a maximum possible value of 27.
RiskTriang(10,20,30,RiskTruncate(D11,D12)) restricts the samples drawn
from the probability distribution RiskTriang(10,20,30) to a minimum possible
value of taken from cell D11 and a maximum possible value of taken from
cell D12.
Guidelines
Minimum must be less than or equal to maximum.
Chapter 9: Probability Distribution Functions
225
226
Reference: Distribution Property Functions
Reference: Output Functions
Output cells are defined using RiskOutput functions. These functions
allow the easy copying, pasting and moving of output cells.
RiskOutput functions are automatically added when the standard
@RISK Add Output icon is pressed. RiskOutput functions optionally
allow you to name your simulation outputs and add individual
output cells to output ranges.
Note: These functions are supported by RISKOptimizer but are
only applicable for defining outputs for @RISK simulations.
Chapter 9: Probability Distribution Functions
227
RiskOutput
Description
The function RiskOutput is used to identify output cells you have selected in
your spreadsheet. This function takes up to three arguments as shown here:
=RiskOutput("output cell name", "output range name",element# in
range)
These arguments are optional, as a simple =RiskOutput() is sufficient for
entering a single element output range where @RISK creates the name of
the output for you. RiskOutput used with a single argument such as:
=RiskOutput ("output cell name")
specifies for a single element output range where the name is entered by
you.
When a multiple element output range is identified, the form:
=RiskOutput ("output cell name", "output range name", position# in
range)
is used; however, the output cell name entry can be omitted if you wish to
have @RISK automatically generate a name for each output cell in the
range.
RiskOutput functions are automatically generated for you when you select
outputs using the @RISK Add Output icon. However, like any other @RISK
function, RiskOutput may be typed directly in the cell which you wish to
reference as a simulation output.
A RiskOutput function is entered by adding it to the cell formula which is
already present in the cell that is to be a simulation output. For example, a
cell containing the formula:
=NPV(.1,G1…G10)
would become
=RiskOutput()+NPV(.1,G1…G10)
when the cell is selected as an output.
Examples
=RiskOutput(“Profit 1999”, “Annual Profit”, 1)+NPV(.1,G1…G10)
identifies the cell where the RiskOutput function is located as a simulation
output and gives it the name Profit 1999 and makes it the first cell in a
multiple cell output range named Annual Profit.
Guidelines
If names are entered directly in the RiskOutput function, the entered output
cell name and output range name must be enclosed in quotes. Names may
also be included by referencing cells with labels in them.
Position# must be a positive integer >=1.
228
Reference: Output Functions
Reference: Statistics Functions
RISKOptimizer provides a set of functions for returning simulation
results directly to your worksheet. As with probability distribution
functions, simulation statistics functions may be used any where in
your worksheet cells and formulas just as are standard Excel
functions.
For all @RISK statistics functions, the cell reference argument specifies
the cell for which you wish to see the relevant simulation statistic. For
example, the function:
•
RiskMean(A12) would return the mean of the distribution of
simulation results for cell A12
These functions – which return values that are updated “real time” as
a simulation is running – are used to:
♦
Display the results from simulations in the spreadsheet
♦
Enter constraints (i.e., if the function =RiskStdDev(A11) is
entered in cell A12, then a hard constraint could be entered
which specified that A12<1000 or that the “standard deviation
of cell A11 must be less than 1000”)
♦
Perform any modeling calculations in spreadsheet formulas as
needed
NOTE: The functions always return the specified statistic for the
most recent simulation, except in the case where you select Best Values
Calculated So Far in the Optimization Stop dialog. In this case, the
simulation statistics functions will show the statistics from the best
simulation and best combinantion of adjustable cell values that were
generated during the optimization.
When a simulation starts, prior return values from the functions are
cleared and the statistics functions show the current running statistic
for the output distribution for the referenced cell.
NOTE: These functions also can be used in @RISK (even if
RISKOptimizer is not running) once RISKOptimizer has been
installed.
Chapter 9: Probability Distribution Functions
229
RiskData
Description
RiskData(cellref or output/input name,iteration#,Sim#) returns the data
point(s) of the simulated distribution for cellref in the specified iteration# and
simulation#. RiskData can optionally be entered as an array formula, where
iteration# is the first iteration to be returned in the first cell in the array
formula range. The data points for each subsequent iteration will be filled
into cells in the range where the array formula is entered.
Examples
RiskData(A10,1) returns the data point of the simulated distribution for cell
A10 in iteration #1 of a simulation.
RiskData("Profit",100,2) returns the data point of the simulated distribution
th
for the output cell named Profit in the current model for the 100 iteration of
the second simulation executed when multiple simulations are run.
Guidelines
None.
230
Reference: Statistics Functions
RiskKurtosis
Description
RiskKurtosis(cellref or output/input name,Sim#) returns the kurtosis of the
simulated distribution for cellref.
Examples
RiskKurtosis(A10) returns the kurtosis of the simulated distribution for cell
A10.
RiskKurtosis("Profit",2) returns the kurtosis of the simulated distribution for
the output cell named Profit in the current model for the second simulation
executed when multiple simulations are run.
Guidelines
None.
RiskMax
Description
RiskMax(cellref or output/input name,Sim#) returns the maximum value of
the simulated distribution for cellref.
Examples
RiskMax(A10) returns the maximum of the simulated distribution for cell A10.
RiskMax(“profit”) returns the maximum of the simulated distribution for the
output cell in the current model named “profit”.
Guidelines
None.
RiskMean
Description
RiskMean(cellref or output/input name,Sim#) returns the mean value of the
simulated distribution for cellref.
Examples
RiskMean(A10) returns the mean of the simulated distribution for cell A10
RiskMean(”Price”) returns the mean of the simulated distribution for the
output cell named Price.
Guidelines
None.
Chapter 9: Probability Distribution Functions
231
RiskMin
Description
RiskMin(cellref or output/input name,Sim#) returns the minimum value of the
simulated distribution for cellref.
Examples
RiskMin(A10) returns the minimum of the simulated distribution for cell A10.
RiskMin("Sales") returns the minimum value of the simulated distribution for
the output cell in the current model named "Sales".
Guidelines
None.
RiskMode
Description
RiskMode(cellref or output/input name,Sim#) returns the mode of the
simulated distribution for cellref.
Examples
RiskMode(A10) returns the mode of the simulated distribution for cell A10.
RiskMode("Sales") returns the mode of the simulated distribution for the
output cell in the current model named "Sales".
Guidelines
None.
RiskPercentile
Description
RiskPercentile(cellref or output/input name, percentile,Sim#) returns the
value of the entered percentile of the simulated distribution for cellref.
Examples
RiskPercentile(C10,.99) returns the 99 percentile of the simulated
distribution for cell C10.
RiskPercentile(C10,A10) returns the percentile value from cell A10 of the
simulated distribution for cell C10.
Guidelines
The entered percentile must be a value >=0 and <=1.
232
th
Reference: Statistics Functions
RiskRange
Description
RiskRange(cellref or output/input name,Sim#) returns the minimummaximum range of the simulated distribution for cellref.
Examples
RiskRange(A10) returns the range of the simulated distribution for cell A10.
Guidelines
None.
RiskSkewness
Description
RiskSkewness(cellref or output/input name,Sim#) returns the skewness of
the simulated distribution for cellref.
Examples
RiskSkewness(A10) returns the skewness of the simulated distribution for
cell A10.
Guidelines
None.
RiskStdDev
Description
RiskStdDev(cellref or output/input name,Sim#) returns the standard
deviation of the simulated distribution for cellref.
Examples
RiskStdDev(A10) returns the standard deviation of the simulated distribution
for cell A10.
Guidelines
None.
Chapter 9: Probability Distribution Functions
233
RiskTarget
Description
RiskTarget(cellref or output/input name, targetvalue,Sim#) returns the
cumulative probability for targetvalue in the simulated distribution for cellref.
The cumulative probability returned is the probability of a value <=
targetvalue occurring.
Examples
RiskTarget(C10,100000) returns the cumulative probability of the value
100000 as calculated using the simulated distribution for cell C10.
Guidelines
The entered targetvalue can be any value.
RiskVariance
Description
RiskVariance(cellref or output/input name,Sim#) returns the variance of the
simulated distribution for cellref.
Examples
RiskVariance(A10) returns the variance of the simulated distribution for cell
A10.
Guidelines
None.
234
Reference: Statistics Functions
Reference: Supplemental Functions
The following functions can be used in macro applications based on
@RISK to determine the status of a running simulation.
RiskCurrentIter
Description
RiskCurrentIter() returns the current iteration of an executing simulation. No
arguments are required.
Examples
None.
Guidelines
None.
RiskCurrentSim
Description
RiskCurrentSim() returns the current simulation number. No arguments are
required.
Examples
None.
Guidelines
None.
Chapter 9: Probability Distribution Functions
235
236
Reference: Supplemental Functions
Chapter 11:
RISKOptimizer Extras
Adding Constraints ................................................................................ 239
Range Constraints .................................................................................... 239
Hard Constraints - customized .............................................................. 240
Iteration vs. Simulation Constraints ...................................................... 241
Soft Constraints ........................................................................................ 241
Penalty Functions............................................................................. 242
Entering a Penalty Function ........................................................... 242
Viewing the Effects of an Entered Penalty Function................... 243
Viewing the Penalties Applied....................................................... 243
Entering Soft Constraints In Your Worksheet.............................. 244
More Examples of Penalty Functions............................................ 245
Using Penalty Functions ................................................................. 245
Multiple Goal Problems .......................................................................... 246
Improving Speed .................................................................................... 249
How RISKOptimizer's Optimization is Implemented..................... 251
Selection ............................................................................................ 251
Crossover .......................................................................................... 251
Mutation............................................................................................ 252
Replacement ..................................................................................... 252
Constraints........................................................................................ 253
Chapter 11: RISKOptimizer Extras
237
238
Adding Constraints
Realistic problems often have a number of constraints that must be
met while we search for optimal answers. For example, in the tutorial
which seeks the transformer design with the lowest cost, one of the
constraints is that the transformer must remain cool, radiating no
more than 0.16 watts/cm2.
A scenario which meets all the constraints in a model is said to be a
viable or “valid” solution. Sometimes it is difficult to find viable
solutions for a model, much less to find the optimal viable solution.
This may be because the problem is very complex, and only has a few
viable solutions, or because the problem is overspecified (there are too
many constraints, or some constraints conflict with others), and there
are no viable solutions.
There are three basic kinds of constraints: range constraints, or minmax ranges placed on adjustable cells, hard constraints, which must
always be met, and soft constraints which we would like to be met as
much as possible, but which we may be willing to compromise for a
big improvement in fitness.
Range Constraints
The simplest hard constraints are the ones that are placed on the
variables themselves. By setting a certain range on each variable, we
can limit the overall number of possible solutions RISKOptimizer will
search through, resulting in a more efficient search. Enter Min and
Max values in the Adjustable Cells Dialog to tell RISKOptimizer the
range of values that are acceptable for each variable.
RISKOptimizer will only try values between 0 and 100,000 for the specified cells.
Chapter 11: RISKOptimizer Extras
239
A second type of hard constraint placed on the variables is built in to
each of RISKOptimizer’s solving methods (recipe, order, grouping,
etc.). For example, when we adjust variables using the budget solving
method, that means RISKOptimizer is hard constrained to try only sets
of values that add up the same amount. Like the Ranges setting, this
hard constraint also reduces the number of possible scenarios that
must be searched.
The integer option in the Adjustable Cells Dialog box is also a hard
constraint, telling RISKOptimizer to try only integer values (1,2,3 etc.)
instead of real numbers (1.34, 2.034, etc.) when adjusting the variable
values.
Hard Constraints - customized
Any constraint that falls outside the RISKOptimizer variable
constraints can be entered using the Constraint Definition dialog.
NOTE: Like evolution in nature, a genetic algorithm’s problemsolving power lies primarily in its ability to freely explore many
combinations of likely solutions, and naturally lean towards the best
ones. If we forbid RISKOptimizer to even look at solutions that do
not meet our demands, the genetic algorithm optimization process
can be crippled.
It is always easier for RISKOptimizer to find solutions that meet the
hard constraints if the initial scenario in the worksheet does itself meet
the constraints. That lets RISKOptimizer know a starting point in the
space of valid solutions. If you do not know of a scenario which
meets the constraints, run RISKOptimizer with any initial scenario and
it will do its best to find scenarios which meet the constraints.
240
Adding Constraints
Iteration vs. Simulation Constraints
Hard constraints in RISKOptimize may be evaluated 1) each iteration
of a simulation run for a trial solution (“an iteration constraint”, or
2) at the end of the simulation run for a trial solution (“a simulation
constraint”).
♦
An iteration constraint is a constraint that is evaluated each
iteration of a simulation run for a given trial solution. If an
iteration results in values which violate the hard constraint, the
simulation is stopped (and the trial solution rejected) and the next
trial solution and its associated simulation begins.
♦
A simulation constraint is specified in terms of a simulation
statistic for a spreadsheet cell; for example the Mean of A11>1000.
In this case, the constraint is evaluated at the end of a simulation.
A simulation constraint, as opposed to an iteration constraint, will
never cause a simulation to be stopped prior to completion.
Soft Constraints
Forcing a program to find only solutions that meet all constraints can
result in no viable solutions being found. Often, it is more useful to
have an approximately viable solution, where maybe a few solutions
fall short of meeting the constraints.
An alternative to the use of “hard constraints” that must be met is to
reconfigure the problem with “soft constraints”; constraints that
RISKOptimizer will tend to meet. These soft constraints are often more
realistic, and allow RISKOptimizer to try many more options. In the
case of a highly constrained problem (where there are not very many
possible solutions that would meet all your requirements),
RISKOptimizer’s genetic algorithm will be more likely to find the best
solution if it is allowed to get feedback on some solutions that are
close to satisfying the constraints.
When constraints are design goals, such as “produce twice as many
forks as knives”, it is often not so important to meet them exactly:
especially if getting a perfectly balanced production schedule required
a day-long optimization process. In this case, a good solution to the
problem, that almost meets the constraint (production is 40% forks,
23% knives, 37% spoons), is usually better than waiting all day to find
out that maybe there is no solution, because all the constraints could
not possibly be met.
Chapter 11: RISKOptimizer Extras
241
Penalty
Functions
Soft constraints can easily be implemented in Excel through the use of
penalty functions. Instead of telling RISKOptimizer that it absolutely
cannot use certain values when looking for solutions, we allow those
“invalid” values to be explored, but we will penalize such solutions
accordingly. For example, your problem may involve finding the
most efficient way to distribute goods with the constraint that you use
only three trucks. A more accurate model would include a penalty
function that allowed you to use more trucks, but added the
tremendous cost to the bottom line. Penalty functions can be specified
in the Constraint Definition dialog or entered directly in your model
by adding formulas to represent the penalty functions.
Entering a
Penalty
Function
RISKOptimizer has a default penalty function which is displayed when
you first enter a soft constraint. Any valid Excel formula, however,
may be entered to calculate the amount of penalty to apply when the
soft constraint is not met. An entered penalty function should include
the keyword deviation which represents the absolute amount by which
the constraint has gone beyond its limit. At the end of a trial
solution's simulation RISKOptimizer checks if the soft constraint has
been met; if not, it places the amount of deviation in the entered
penalty formula and then calculates the amount of penalty to apply to
the simulation statistic for the target cell that is being minimized or
maximized.
The penalty amount is either added or subtracted from the calculated
statistic for the target cell in order to make it less "optimal." For
example, if Maximum is selected in the Find the field in the
RISKOptimizer Settings dialog, the penalty is subtracted from the
calculated statistic for the target cell.
242
Adding Constraints
Viewing the
Effects of an
Entered Penalty
Function
RISKOptimizer includes an Excel worksheet PENALTY.XLS which can
be used to evaluate the effects of different penalty functions on
specific soft constraints and target cell results.
PENALTY.XLS allows you to select a soft constraint from your model
whose effects you wish to analyze. You can then change the penalty
function to see how the function will map a specific value for the
unmet soft constraint into a specific penalized statistic for the target
cell. For example, if your soft constraint is A10<100, you could use
PENALTY.XLS to see what the target value would be if a value of 105
was calculated for cell A10.
Viewing the
Penalties
Applied
When a penalty is applied to the target cell due to an unmet soft
constraint, the amount of penalty applied along with the value for the
soft constraint cell can be viewed in the RISKOptimizer Watcher. In
addition, when a RISKOptimizer Optimization summary worksheet is
created, penalty values applied along with soft constraint values are
placed in the Optimization summary worksheet.
Chapter 11: RISKOptimizer Extras
243
Entering Soft
Constraints In
Your Worksheet
Penalty functions may also be entered directly in your worksheet. A
Boolean penalty function will assign a set penalty on any scenario
which does not meet the specified constraint. For example, if you
wanted the value in cell B1(supply) to be at least as great as the value
in cell A1(demand), you could create this penalty function in another
cell: =IF(A1>B1, -1000, 0). If the result of this cell were added to the
statistic for the target cell, than every time RISKOptimizer tried a
solution which violated that constraint (i.e. the supply did not meet
the demand), the statistic for the target cell being maximized would
show a value 1,000 lower than the real result. Any solution which
violated this constraint would produce a low value for the statistic for
the target cell, and eventually RISKOptimizer would “breed out” these
organisms.
You can also use a scaling penalty function, which more accurately
penalizes the solution relative to how badly it violates the constraint.
This is often more practical in the real world, because a solution
where supply did not quite meet demand would be better than a
solution where supply didn’t even come close to the demand. A
simple scaling penalty function computes the absolute difference
between the constraint’s goal value and it’s actual value. For
example, in the same problem where A1(demand) should not exceed
B1(supply), we could assign the following penalty function:
=IF(A1>B1, (A1-B1)^2, 0). This kind of penalty function measures
how close a constraint is to being met, and exaggerates that difference
by squaring it. Now our penalty changes based on how badly a
solution violates the constraint.
244
Adding Constraints
More Examples
of Penalty
Functions
For example, suppose you have created a manufacturing model where
one of the constraints is that the amount of wood used should be
equal to the amount of plastic used. This constraint is met when
“AmountWood” = “AmountPlastic”. We want to find solutions that
include the same amount of both materials, so we create a penalty
function to discourage solutions that stray from our goal. The formula
“=ABS(AmountWood-AmountPlastic)” computes the absolute (nonnegative) difference between the amount of wood and the amount of
plastic being used. By using the ABS() function, we arrive at the same
penalty value if AmountWood is 20 greater than AmountPlastic, or if
AmountPlastic is 20 less than AmountWood. Now when we optimize
the model, our goal is to minimize the mean of the simulation results
for this absolute difference.
Suppose instead we impose the following constraint: The amount of
wood must be twice the amount of plastic. The penalty function
would then be:
=ABS(AmountWood-AmountPlastic*2)
A different possible constraint is that the amount of wood should be
no less than twice the amount of plastic. While the previous example
produced a penalty if there was too much wood, in this case we only
care if there is not enough wood; if AmountWood is ten times
AmountPlastic, we want no penalty to be applied. The appropriate
penalty function would then be:
=IF(AmountWood<AmountPlastic*2,
ABS(AmountPlastic*2-AmountWood),0)
If AmountWood is at least twice as great as AmountPlastic, the
penalty function returns 0. Otherwise, it gives a measure of how
much less than twice AmountPlastic the AmountWood value is.
Using Penalty
Functions
After you have created penalty functions to describe the soft
constraints in your model, you can combine them with your normal
target cell formula to obtain a constrained target cell formula. In the
example illustrated below, if cell C8 computes the total cost of a
project, and cells E3:E6 contain five penalty functions, then you can
create a formula in cell C10 such as =SUM(C8, E3:E6).
Chapter 11: RISKOptimizer Extras
245
Create a cell that adds the constraints to your total, and minimize the mean of the
simulation results for this cell.
This adds the penalties in column E to the cost in C8 to obtain a
constrained or penalized cost function in C10. Note that if this were a
maximization problem, you would subtract, rather than add, the
penalties to the original target cell. Now when you use
RISKOptimizer, you simply select this constrained cell, C10, as the
target cell to be whose simulation statistic will be optimized.
When RISKOptimizer tries to optimize a constrained statistic for the
target cell, the penalty functions will tend to force the search towards
scenarios that meet the constraints. Eventually RISKOptimizer will
end up with solutions that are good answers and that meet or nearly
meet all constraints (the penalty functions will have values near 0).
Multiple Goal Problems
You may only specify one cell in the target cell field of RISKOptimizer,
but you can still solve for multiple goals by creating a function that
combines the two goals into one goal. For example, as a polymer
scientist, you may be trying to create a substance that is flexible, but
also strong. Your model computes the resulting strength, flexibility
and weight that would result from a given mix of chemical
combinations. The amounts of each chemical to use are the adjustable
variables of the problem.
Since you want to maximize the Strength of the substance (in cell S3)
but also maximize its Flexibility (in cell F3), you would create a new
cell with the formula: =(S3+F3). This would be your new target cell,
for the higher this number went, the better the overall solution.
246
Adding Constraints
If the flexibility was more important than the strength, we could
change the formula in the target cell to read =(S3+(F3*2)). This way,
scenarios which increased the flexibility by a certain amount would
look better (produce a higher fitness “score”) than scenarios which
increased the strength by the same amount.
If you wanted to maximize the Strength of a substance (in cell S5) but
also minimize its Weight (in cell W5), you would create a new cell
with the following formula: =(S5^2)-(W5^2). This formula would
produce a higher number when the structure was both strong-andlight, a lower number when the structure was weak-and-heavy, and
equally average numbers for weak-but-light and strong-but-heavy
scenarios. You would therefore use this new cell as your target, and
maximize its mean to satisfy both goals.
Chapter 11: RISKOptimizer Extras
247
248
Adding Constraints
Improving Speed
When you use RISKOptimizer to solve a problem, you are using both
the RISKOptimizer library of compiled routines to control the process
and Excel’s spreadsheet evaluation function to examine different
scenarios. A large percentage of the time used by RISKOptimizer is
actually used by Excel as it recalculates your spreadsheet. There are a
number of things that can be done to speed up RISKOptimizer
optimization and Excel’s recalculation process.
♦
The speed of RISKOptimizer is directly related to the speed of your
computer processor. A Pentium/200 will be roughly twice as fast
as the Pentium/100. This means that RISKOptimizer will be able
to evaluate twice as many trials in the same amount of time.
♦
Experiment with different simulation stopping conditions. Initial
tests of a model should be done with a low fixed number of
iterations per simulation. Once you are certain that your model
and constraints are performing as desired, have RISKOptimizer
determine how many iterations to run each simulation by
selecting Stop on Actual Convergence or Stop on Projected
Convergence. The setting Stop on Projected Convergence results
in faster optimizations than Stop on Actual Convergence.
♦
Increase the Convergence Tolerance setting if you are using the
simulation stopping condition Stop on Actual Convergence or
Stop on Projected Convergence. This will keep RISKOptimizer
from running unnecessary iterations without significantly
changing simulation statistics. Setting Convergence Tolerance too
high, however, will result in unstable simulation results.
♦
Try to avoid re-drawing in your window. Drawing graphics and
numbers on the screen takes time, sometimes more than half the
time spent optimizing! If you have charts or graphs on the sheet,
they will slow down the re-calculate time significantly. You can
tell Excel not to spend time drawing while RISKOptimizer is
solving a problem by turning off the Update Display option in the
RISKOptimizer Settings Dialog or by minimizing the Excel sheet.
You can see how much faster your problem is working by
watching the status bar.
♦
Once RISKOptimizer has more or less converged on a solution, and
there has been no improvement on the best solution in a while
(e.g. last 1000 trials), you may want to increase the mutation rate
to allow RISKOptimizer to broaden its search for solutions, rather
than continuing to refine solutions in the current population using
Chapter 11: RISKOptimizer Extras
249
primarily crossover. You can increase mutation rate through the
RISKOptimizer Watcher using the Population Settings command.
♦
250
Set more tightly the ranges that the adjustable cells must fall
between; this will create a smaller area in which RISKOptimizer
must search for solutions, and should therefore speed up the
process. Make sure that your ranges allow enough freedom for
RISKOptimizer to explore all realistic solutions.
Improving Speed
How RISKOptimizer's Optimization
is Implemented
In this section we describe more specifically how RISKOptimizer’s
optimization algorithms are implemented.
NOTE: You do not need to know this material in order to use
RISKOptimizer.
The majority of RISKOptimizer’s genetic algorithm technology such as
the recipe and order solving methods are based on academic work in
the genetic algorithm field over the last ten years. However, most of
the descendant solving methods included with RISKOptimizer, and the
multiple groups of adjustable cells, backtracking, strategy, and
probability features are unique to RISKOptimizer.
RISKOptimizer uses a steady-state approach. This means that only one
organism is replaced at a time, rather than an entire “generation”
being replaced. This steady state technique has been shown to work
as well or better than the generational replacement method. To find
out the equivalent number of “generations” RISKOptimizer has run,
take the number of individual trials it has explored and divide that by
the size of the population.
Selection
When a new organism is to be created, two parents are chosen from
the current population. Organisms that have high fitness scores are
more likely to be chosen as parents.
In RISKOptimizer, parents are chosen with a rank-based mechanism.
Instead of some genetic algorithm systems, where a parent's chance to
be selected for reproduction is directly proportional to its fitness, a
ranking approach offers a smoother selection probability curve. This
prevents good organisms from completely dominating the evolution
from an early point.
Crossover
Since each solving method adjusts the variables in different ways,
RISKOptimizer employs a different crossover routine optimized for
that type of problem.
The basic recipe solving method performs crossover using a uniform
crossover routine. This means that instead of chopping the list of
variables in a given scenario at some point and dealing with each of
the two blocks (called “single-point” or “double-point” crossover),
two groups are formed by randomly selecting items to be in one
group or another. Traditional x-point crossovers may bias the search
with the irrelevant position of the variables, whereas the uniform
Chapter 11: RISKOptimizer Extras
251
crossover method is considered better at preserving schema, and can
generate any schema from the two parents.
The order solving method performs crossover using a similar
algorithm to the order crossover operator described in L. Davis’
Handbook of Genetic Algorithms.* This selects items randomly from
one parent, finds their place in the other parent, and copies the
remaining items into the second parent in the same order as they
appear in the first parent. This preserves some of the sub-orderings in
the original parents while creating some new sub-orderings.
Mutation
Like crossover, mutation methods are customized for each of the
different solving methods. The basic recipe solving method performs
mutation by looking at each variable individually. A random number
between 0 and 1 is generated for each of the variables in the organism,
and if a variable gets a number that is less than or equal to the
mutation rate (for example, 0.06), then that variable is mutated. The
amount and nature of the mutation is automatically determined by a
proprietary algorithm. Mutating a variable involves replacing it with
a randomly generated value (within its valid min-max range).
To preserve all the original values, the order solving method performs
mutation by swapping the positions of some variables in the
organism. The number of swaps performed is increased or decreased
proportionately to the increase and decrease of the mutation rate
setting (from 0 to 1).
Replacement
Since RISKOptimizer uses a rank-ordered rather than generational
replacement method, the worst-performing organisms are always
replaced with the new organism that is created by selection, crossover,
and mutation, regardless of its fitness “score”.
Davis, Lawrence (1991). Handbook of Genetic Algorithms. New
York: Van Nostrand Reinhold.
*
252
How RISKOptimizer's Optimization is Implemented
Constraints
Hard constraints are implemented with Palisade’s proprietary
“backtracking” technology. If a new offspring violates some
externally imposed constraints, RISKOptimizer backtracks towards one
of the parents of the child, changing the child until it falls within the
valid solution space.
Chapter 11: RISKOptimizer Extras
253
254
How RISKOptimizer's Optimization is Implemented
Appendix A: Controlling
RISKOptimizer with VBA
Overview .................................................................................................. 259
The Organization of this Chapter........................................................... 259
Example Application ............................................................................... 259
Using the VBA Functions ........................................................................ 259
VBA and RISKOptimizer Settings....................................................... 261
Public Variable Types Used for RISKOptimizer Settings..................... 261
Defining RISKOptimizer Settings Using Code ...................................... 262
Using VBA to Control an Optimization ............................................. 265
VBA Reference - Public RISKOptimizer Variables.......................... 267
Description of EvSettingsType ............................................................... 267
Variables in EVSettingsType ............................................................... 269
WB .............................................................................................................. 269
CellToOptimize ........................................................................................ 269
OutputFunction ........................................................................................ 269
OutputFunctionParameter ...................................................................... 270
OptimizationGoal..................................................................................... 270
TargetValue............................................................................................... 270
NumAdjustableGroups ........................................................................... 270
AdjustableGroups().................................................................................. 271
NumConstraints ....................................................................................... 271
Constraints().............................................................................................. 271
StopOnTrials ............................................................................................. 271
StopTrials................................................................................................... 272
StopOnMinutes......................................................................................... 272
StopMinutes .............................................................................................. 272
StopOnChange.......................................................................................... 273
StopChangeTrials ..................................................................................... 273
StopChangeMagnitude............................................................................ 273
Appendix A: Controlling RISKOptimizer with VBA
255
StopChangeIsPercent ............................................................................... 274
StopOnFormula ........................................................................................ 274
StopFormula.............................................................................................. 274
PopulationSize .......................................................................................... 274
UpdateDisplay.......................................................................................... 274
GraphProgress .......................................................................................... 275
PauseOnError............................................................................................ 275
GenerateLog.............................................................................................. 275
RandomlyGenerateSeed .......................................................................... 275
SeedValue.................................................................................................. 275
SimStopMode............................................................................................ 276
SimMaxIters .............................................................................................. 276
SimConvergenceTolerance...................................................................... 276
SimsUseSameSeed.................................................................................... 277
SamplingType........................................................................................... 277
StandardRecalc ......................................................................................... 277
RunStartMacro.......................................................................................... 278
StartMacro ................................................................................................. 278
RunBeforeSimMacro ................................................................................ 278
BeforeSimMacro ....................................................................................... 278
RunBeforeRecalcMacro............................................................................ 279
BeforeRecalcMacro................................................................................... 279
RunAfterRecalcMacro.............................................................................. 279
AfterRecalcMacro..................................................................................... 279
RunAfterSimMacro .................................................................................. 280
AfterSimMacro ......................................................................................... 280
RunAfterStorageMacro............................................................................ 280
AfterStorageMacro................................................................................... 280
RunFinishMacro ....................................................................................... 281
FinishMacro............................................................................................... 281
EvAdjustableGroupType ...................................................................... 282
Listing of EvAdjustableGroupType....................................................... 282
Variables in EvAdjustableGroupType ............................................... 282
Description ................................................................................................ 282
SolvingMethod ......................................................................................... 282
CrossoverRate ........................................................................................... 283
MutationRate ............................................................................................ 283
NumTimeBlocks ....................................................................................... 283
ConstRange ............................................................................................... 283
NumInputRanges ..................................................................................... 284
InputRanges()............................................................................................ 284
EvInputRangeType................................................................................. 285
256
Listing of EvInputRangeType................................................................. 285
Variables in EvInputRangeType ......................................................... 285
Reference ................................................................................................... 285
MinValue................................................................................................... 285
MaxValue .................................................................................................. 286
ExcludeMinValue..................................................................................... 286
ExcludeMaxValue .................................................................................... 286
IsInteger..................................................................................................... 286
EvConstraintType ................................................................................... 287
Listing of EvConstraintType................................................................... 287
Variables in EvConstraintType............................................................ 287
ConstraintType ......................................................................................... 287
EntryMode ................................................................................................ 288
Formula ..................................................................................................... 288
PenaltyFunction........................................................................................ 289
RiskOptEvalTime ..................................................................................... 289
Description ................................................................................................ 289
Status Variables Available During an Optimization ...................... 291
VBA Reference - Public RISKOptimizer Functions.......................... 293
EvCopyAdjustableGroup........................................................................ 293
EvCopySettings ........................................................................................ 294
EvError ...................................................................................................... 294
EvGetListOfSolvingMethods.................................................................. 295
EvOptimize ............................................................................................... 295
EvReadSettings......................................................................................... 298
EvReadSettingsDefaults .......................................................................... 298
EvReadSettingsFromSummary .............................................................. 299
EvRestoreValuesFromSummary ............................................................ 300
EvShowSettingsDlg.................................................................................. 301
EvWriteSettings ........................................................................................ 301
Appendix A: Controlling RISKOptimizer with VBA
257
258
Overview
The RISKOptimizer functions and types accessible by Excel VBA
programmers fall into two general categories. The first category
allows you to automate the process of editing RISKOptimizer settings
using code. For example, you might wish to open all the workbooks
in a given folder, change the size of the RISKOptimizer population in
each of those models, and then save them. Or perhaps you want to
make a custom settings interface, which shields other users from
certain details. The second category of functions and types allows you
to start and control an RISKOptimizer optimization. For example, you
may wish to run multiple optimizations, one after another, and
compare the results between each.
The Organization of this Chapter
The first section of this chapter, Overview, details how to use the
RISKOptimizer VBA functions and variables, how to specify
RISKOptimizer settings, and how to run optimizations from VBA. The
next section, VBA Reference - Public Variables, lists the public
RISKOptimizer variables available in VBA. The last section, VBA
Reference - Public Functions, lists the public RISKOptimizer functions
available in VBA.
Example Application
An example application that controls RISKOptimizer from VBA is
provided with RISKOptimizer. This file (RODKEXAM.XLS) is located
in the RISKOPT\EXAMPLES directory along with the other example
files provided with RISKOptimizer.
Using the VBA Functions
To use any of the functions, types, and constants described here, you
must first make a “reference” to the RISKOptimizer add-in from within
your VBA application. First, make sure RISKOptimizer is loaded in
Excel. Next, from within your VBA module, choose the “Tools”
menu’s ”References…” option. This will bring up a dialog list of all
the available references. Make sure RISKOpt.xla is checked as a
reference.
NOTE: The VBA functions and variables available in RISKOptimizer
are nearly identical to the VBA functions and variables available in
Evolver, the optimization add-in to Excel also from Palisade. For
consistency, all Evolver and RISKOptimizer VBA functions and
variables start with the letters "Ev", such as EvOptimize.
Appendix A: Controlling RISKOptimizer with VBA
259
260
VBA and RISKOptimizer Settings
VBA and RISKOptimizer Settings
Public Variable Types Used for RISKOptimizer
Settings
The VBA control of the RISKOptimizer settings is based on a hierarchy
of four public defined variable types, which have been designed to
closely match the user interface of RISKOptimizer. Before reading this
guide, you should be familiar with the RISKOptimizer Excel interface.
The three available public RISKOptimizer variable types are:
EvSettingsType
The defined public type EvSettingsType is the root of the hierarchy.
It contains all the RISKOptimizer settings (such as the cell to optimize,
the population size, etc.). Imbedded in EvSettingsType is an array of
adjustable cell groups and an array of constraints.
EvAdjustable
GroupType
The public defined type, EvAdjustableGroupType, defines a single
group of adjustable cells of a model. It contains information about
how collections of cell ranges should be adjusted by RISKOptimizer (it
includes the solving method, mutation rate, etc.).
EvInputRange
Type
EvInputRangeType, a third public defined type, is imbedded in the
EvAdjustableGroupType. This variable is used to describe the
individual cell ranges that make up a group of adjustable cells and in
what manner RISKOptimizer is allowed to vary them during the
optimization.
EvConstraint
Type
The EvConstraintType, a fourth public defined type, is imbedded in
the EvSettingsType and is used to describe additional hard and soft
constraints.
Appendix A: Controlling RISKOptimizer with VBA
261
Defining RISKOptimizer Settings Using Code
Constructing an
EvSettingsType
Variable
To construct a EvSettingsType variable from scratch, you will need to
redimension the arrays that hold information about adjustable cell
groups and constraints. For example, the following code defines a
settings variable with one group of adjustable cells that has two
ranges and one additional constraint:
Sub SetupModel()
Dim mySettings as EvSettingsType
With mySettings
.NumAdjustableGroups = 1
Redim .AdjustableGroups(1 to 1)
.AdjustableGroups(1).NumInputRanges = 2
Redim .AdjustableGroups(1).InputRanges(1 to 2)
.NumConstraints = 1
Redim .Constraints(1 to 1)
End With
‘now fill in the variable with the information that describes the model.
End Sub
Notice how you must also set the numAdjustableGroups,
numConstraints, and numInputRanges settings to be consistent with
the sizes of the arrays.
Public
Functions for
RISKOptimizer
Settings
262
There are several public functions that RISKOptimizer provides for
retrieving, copying, and storing RISKOptimizer settings:
♦
The EvReadSettings function will read the RISKOptimizer settings
stored in an Excel workbook and put them into an EvSettingsType
variable.
♦
The EvWriteSettings function stores the information in an
EvSettingsType variable into a workbook. Because the
RISKOptimizer settings are stored directly in the workbook, they
are not saved on disk until the workbook itself is saved. Keep in
mind, changes made to an EvSettingsType variable will not affect
an optimization unless you have called EvWriteSettings.
♦
The EvReadSettingsDefaults function will fill an EvSettingsType
variable with a set of default settings, but with no defined
AdjustableGroups or additional constraints. These are the same
settings a user would see when the RISKOptimizer settings toolbar
button is pressed for a model with no current RISKOptimizer
settings.
♦
The EvReadSettingsFromSummary function retrieves settings
stored in RISKOptimizer’s optimization summary worksheet.
VBA and RISKOptimizer Settings
♦
In addition, since VBA does not allow the assignment of variables
with embedded arrays, the EvCopySettings and
EvCopyAdjustableGroup functions are provided for copying
EvSettingsType and EvAdjustableGroupType variables.
Each of these functions are discussed in detail in the Public Function
Reference.
Note: Be sure to always check the integer return code from all
RISKOptimizer functions. Zero indicates the function was called
successfully. A non-zero value indicates an error was encountered.
You can pass the return value to the function EvError to get a
description of the error.
Appendix A: Controlling RISKOptimizer with VBA
263
264
VBA and RISKOptimizer Settings
Using VBA to Control an
Optimization
Public
Functions For
Controlling an
Optimization
You can start an optimization or restart a paused optimization by
calling the EvOptimize function. If one of the stopping conditions is
met during an optimization, the normal behavior of RISKOptimizer is
to put up a dialog box. If you desire to suppress this behavior, you
can specify a StopRoutine in your call EvOptimize. This is a function
that is called whenever any of the stopping conditions are met. See
the description of EvOptimize in the Public Function Reference for
more details.
Macros
During the optimization, you can specify seven different macros to
run at different times during the optimization process. The macros
you write must be declared as public subroutines which take no
arguments. The StartMacro runs when the optimization begins or
when the optimization is restarted after being paused by the user.
You can check the EvPaused variable to determine why the macro
was called. This type of macro is useful if you want to modify the
spreadsheet model each time the user starts optimizing a model. In a
similar manner, the FinishMacro runs when the optimization
terminates. Again, the EvPaused variable indicates whether the
optimization has been paused, rather than stopped.
The two macros BeforeSimMacro and AfterSimMacro are called each
time RISKOptimizer simulates the spreadsheet. BeforeSimMacro is
called before each trial solution's simulation begins. AfterSimMacro
is called after each trial solution's simulation ends.
The three macros BeforeRecalcMacro, AfterRecalcMacro and
AfterStorageMacro are called each time RISKOptimizer recalculates
the spreadsheet during a simulation. The BeforeRecalcMacro is
called after RISKOptimizer has sampled values in the spreadsheet
model, but before Excel is recalculated with these values. This type of
macro is useful if you want to modify these values before the
calculation occurs. The AfterRecalcMacro is called just after
RISKOptimizer recalculates the spreadsheet model, but before the
output value is checked against the constraints and stored internally.
This type of macro is useful if you want to modify the output value
before RISKOptimizer uses it internally. Finally, the
AfterStorageMacro is called after RISKOptimizer stores the output
value, but before the next iteration begins. This type of macro is
useful if you want to collect all the output values or create your own
Appendix A: Controlling RISKOptimizer with VBA
265
progress indicator. The EvConstraintValue variable tells you the
status of the constraint(s) for this recalculation.
Optimization
Status Variables
266
In your code, you have access to a set of public variables which can be
used when controlling an optimization. These can be accessed during
macros executed during an optimization, such as macros defined in
RunAfterRecalcMacro or RunBeforeRecalcMacro. These variables
return information such as the current best value found by
RISKOptimizer (EVBestValue) or the number of trials performed
(EvTrials) or other similar data. See the section Status Variables
Available During an Optimization for a complete list of these public
variables.
Using VBA to Control an Optimization
VBA Reference - Public
RISKOptimizer Variables
Description of EvSettingsType
EvSettingsType
Public Type EvSettingsType
'-- MODEL DEFINITION --------------wb As Workbook
CellToOptimize As String
OutputFunction As Integer
OutputFunctionParameter As Double
OptimizationGoal As Integer
TargetValue As Double
numAdjustableGroups As Integer
AdjustableGroups() As EvAdjustableGroupType
numConstraints As Integer
constraints() As EvConstraintType
'-- OPTIONS -----------------------PopulationSize As Integer
UpdateDisplay As Integer
GraphProgress As Boolean
PauseOnError As Boolean
GenerateLog As Boolean
RandomlyGenerateSeed As Boolean
SeedValue As Long
'-- RISKOptimizer OPTIONS ---------SimStopMode As Integer
SimMaxIters As Long
SimConvergenceTolerance As Double
SimsUseSameSeed As Boolean
SamplingType As Integer
StandardRecalc As Integer
'-- STOPPING CONDITIONS -----------StopOnTrials As Boolean
StopTrials As Double
StopOnMinutes As Boolean
StopMinutes As Double
StopOnChange As Boolean
StopChangeTrials As Double
StopChangeMagnitude As Double
StopChangeIsPercent As Boolean
StopOnFormula As Boolean
StopFormula As String
'--MACROS--------------------------Appendix A: Controlling RISKOptimizer with VBA
267
RunStartMacro As Boolean
StartMacro As String
RunBeforeSimMacro As Boolean
BeforeSimMacro As String
RunBeforeRecalcMacro As Boolean
BeforeRecalcMacro As String
RunAfterRecalcMacro As Boolean
AfterRecalcMacro As String
RunAfterSimMacro As Boolean
AfterSimMacro As String
RunAfterStorageMacro As Boolean
AfterStorageMacro As String
RunFinishMacro As Boolean
FinishMacro As String
'------------------------------------
End Type
268
VBA Reference - Public RISKOptimizer Variables
Variables in EVSettingsType
WB
Excel workbook object. The Excel workbook that is to be optimized.
Examples
Set mySettings.wb = ActiveWorkbook
Set mySettings.wb = Workbooks(“myWorkbook”)
CellToOptimize
String. The cell RISKOptimizer is to optimize.
Guidelines
Examples
♦
Must be a reference to a single cell in the workbook given by WB.
♦
May be a defined name or a cell address, but all addresses must
be qualified by the sheet name.
mySettings.CellToOptimize = “sheet1!$A$1”
mySettings.CellToOptimize = “myDefinedName”
OutputFunction
Integer. The @RISK statistic function whose value (for the simulation
results for the target cell) is being minimized, maximized or set to a
specific value in the optimization.
Guidelines
Must be one of the 12 public constants:
EvRiskFuncMean
the mean of the simulated values
EvRiskFuncStdDev
the standard deviation of the simulated values
EvRiskFuncVariance
the variance of the simulated values
EvRiskFuncSkewness
the skewness of the simulated values
EvRiskFuncKurtosis
the kurtosis of the simulated values
EvRiskFuncMin
the minimum of the simulated values
EvRiskFuncMax
the maximum of the simulated values
EvRiskFuncRange
the range of the simulated values (max
EvRiskFuncMode
the mode of the simulated values
EvRiskFuncPercentile
a specified percentile of the simulated values
EvRiskFuncTarget
a specified target of the simulated values
EvValue
the cell itself is the output
Appendix A: Controlling RISKOptimizer with VBA
269
Example
‘specify that we want RISKOptimizer to maximize of mean of cell $A$1 on
sheet1
mySettings.CellToOptimize = “Sheet1!$A$1”
mySettings.OutputFunction = EvRiskFuncMean
mySettings.OptimizationGoal = EvMaximize
OutputFunctionParameter
Double. A parameter for function specified in the OutputFunction
setting. This setting only has effect if the OutputFunction is
EvRiskFuncPercentile or EvRiskFuncTarget.
Example
‘specify that we want RISKOptimizer to minimize of 13th percentile
‘of cell $A$1 on sheet1
mySettings.CellToOptimize = “Sheet1!$A$1”
mySettings.OutputFunction = EvRiskFuncPercentile
mySettings.OutputFunctionParameter = .13
mySettings.OptimizationGoal = EvMinimize
OptimizationGoal
Integer. The nature of the objective that RISKOptimizer is optimizing
for.
Guidelines
♦
Example
mySettings.OptimizationGoal = EvMaximize
Must be one of the three public constants EvMinimize,
EvMaximize, or EvTargetValue.
TargetValue
Double. The value RISKOptimizer should try to match the output to.
This only has effect when OptimizationGoal is set to EvTargetValue.
Example
‘look for the closest value to 100
mySettings.OptimizationGoal = EvTargetValue
mySettings.TargetValue = 100
NumAdjustableGroups
Integer. The number of AdjustableGroups in the RISKOptimizer
model. This is the upper limit of the AdjustableGroups array. If you
modify the size of the AdjustableGroups array, you must update this
parameter.
Example
270
MsgBox “There are “ & mySettings.NumAdjustableGroups & “
AdjustableGroups in this model.”
Variables in EVSettingsType
AdjustableGroups()
Array of EvAdjustableGroupType. This array stores the definitions of
each AdjustableGroup. The lowest element of the array is 1 and the
highest element of the array is given by the NumAdjustableGroups
setting.
NumConstraints
Integer. The number of constraints (hard and soft) in the
RISKOptimizer model. This is the upper limit of the Constraints array.
If you modify the size of the Constraints array, you must update this
parameter. Keep in mind this number does not include range
constraints. They are defined in the InputRanges array of each
AdjustableGroup.
Example
MsgBox “There are “ & mySettings.NumConstraints & “ additional
constraints in this model.”
Constraints()
Array of EvConstraintType. This array stores the definitions of each
additional hard or soft constraint. The lowest element of the array is 1
and the highest element of the array is given by the NumConstraints
setting. During the optimization process, each organism
RISKOptimizer generates is checked against each of the constraints. If
all hard constraints evaluate to TRUE the organism is deemed “valid”
and may continue to evolve. If any hard constraint is not met, the
orgainism is “invalid”. For each soft constraint that is not met, the
output value is penalized by the amount specified in the constraint's
penalty function. Keep in mind this array does not include range
constraints. They are defined in the InputRanges array of each
AdjustableGroup.
StopOnTrials
Boolean. Indicates that RISKOptimizer should stop optimizing after a
certain number of trials have been run. The number of trials is
specified in the StopTrials setting.
Example
‘stop optimizing after 1000 trials
mySettings.StopOnTrials = TRUE
mySettings.StopTrials = 1000
Appendix A: Controlling RISKOptimizer with VBA
271
StopTrials
Double. The number of trials RISKOptimizer should run before
automatically stopping. This setting only has effect when
StopOnTrials setting is set to TRUE.
Example
‘stop optimizing after 1000 trials
mySettings.StopOnTrials = TRUE
mySettings.StopTrials = 1000
StopOnMinutes
Boolean. Indicates that RISKOptimizer should stop optimizing after a
certain number of minutes have elapsed. The number of trials is
specified in the StopMinutes setting.
Example
‘stop optimizing after 10 minutes have elapsed
mySettings.StopOnMinutes = TRUE
mySettings.StopMinutes = 10
StopMinutes
Double. The number of minutes RISKOptimizer should run for before
automatically stopping. This setting only has effect when the
StopOnMinutes setting is set to TRUE.
Example
272
‘stop optimizing after 30 seconds have elapsed
mySettings.StopOnMinutes = TRUE
mySettings.StopMinutes = .5
Variables in EVSettingsType
StopOnChange
Boolean. Indicates that RISKOptimizer should stop optimizing when
the change in the output is less than a certain amount. The amount of
change necessary to trigger this stopping condition is specified in the
three settings: StopChangeTrials, StopChangeMagnitude, and
StopChangeIsPercent. If the StopOnChange stopping condition is
set to TRUE, after each trial RISKOptimizer calculates the maximum
change in the output during the previous number of trials specified in
StopChangeTrials. RISKOptimizer will stop running if this change is
less than the minimum amount specified in the
StopChangeMagnitude and StopChangeIsPercent properties. If
StopChangeIsPercent is TRUE, StopChangeMagnitude is a
minimum percentage change in the output. If StopChangeIsPercent
is FALSE, StopChangeMagnitude is the minimum actual change in
the output.
Examples
‘stop if the change in the output cell is less than 1% in the last 1000 trials
With mySettings
.StopOnChange = TRUE
.StopChangeTrials = 1000
.StopChangeMagnitude = 1
.StopChangeIsPercent = TRUE
End With
‘stop if the change in the output cell is less than 100 in the last 500 trials
With mySettings
.StopOnChange = TRUE
.StopChangeTrials = 500
.StopChangeMagnitude = 100
.StopChangeIsPercent = FALSE
End With
StopChangeTrials
Double. The number of trials to check for the StopOnChange
condition. This setting only has effect when the StopOnChange
setting is set to TRUE.
StopChangeMagnitude
Double. The minimum amount of change allowed in the
StopOnChange condition. This setting only has effect when the
StopOnChange setting is set to TRUE. May be a percentage value or
an actual value depending on the StopChangeIsPercent setting.
Appendix A: Controlling RISKOptimizer with VBA
273
StopChangeIsPercent
Boolean. Indicates whether the value in the StopChangeMagnitude
setting is a percentage or an actual number. This setting only has
effect when StopOnChange is set to TRUE.
StopOnFormula
Boolean. Indicates that RISKOptimizer should stop optimizing if the
formula specified in the StopFormula setting evaluates to TRUE.
Example
mySettings.StopOnFormula = TRUE
mySettings.StopFormula = “AND(sheet1!$A$1<15, sheet2!$B$9>22)”
StopFormula
String. RISKOptimizer stops the optimization when this formula
evaluates to TRUE. This setting only has effect when StopOnFormula
is set to TRUE.
Guidelines
Examples
♦
Must be a valid Excel formula.
♦
All cell references must be qualified with a sheet name.
mySettings.StopFormula = “AND(sheet1!$A$1<15, sheet2!$B$9>22)”
mySettings.StopFormula = “myDefinedName = 22”
PopulationSize
Integer. The number of organisms in the RISKOptimizer population.
Guidelines
♦
Example
mySettings.PopulationSize = 50
The minimum population size is 2 and the maximum population
size is 32767.
UpdateDisplay
Integer. Describes how the screen will be updated during the
optimization.
Guidelines
Must be one of the two public constants EvDisplayOn or
EvDisplayOff.
Example
mySettings.UpdateDisplay = EvDisplayOff
274
Variables in EVSettingsType
GraphProgress
Boolean. Specifies whether the RISKOptimizer watcher automatically
display a progress graph.
Example
mySettings.GraphProgess = TRUE
PauseOnError
Boolean. Specifies whether the optimization should automatically be
paused when an error is calculated in the output cell, the constraint
formulas, or the stop formula.
Example
mySettings.PauseOnError = TRUE
GenerateLog
Boolean. If set to TRUE, logging information will be written to disk as
the optimization proceeds. The data can then be viewed in the
RISKOptimizer Watcher or in Excel after the optimization has been
stopped.
Example
mySettings.GenerateLog = TRUE
RandomlyGenerateSeed
Boolean. Specifies whether RISKOptimizer’s random number
generator uses a random seed or a fixed seed. If the
RandomlyGenerateSeed setting is TRUE, the SeedValue setting is
ignored.
Example
mySettings.RandomlyGenerateSeed = TRUE
SeedValue
Long. Specifies afixed seed value used in RISKOptimizer’s random
number generator. If RandomlyGenerateSeed is TRUE, the SeedValue
setting is ignored. Use a fixed seed if you want to exactly reproduce
your optimization from run to run. Note if your model contains
random elements outside of RISKOptimizer’s control (such as Excel’s
RAND() statement) the model will not be reproducible run to run,
even if you have a fixed seed value.
Guidelines
♦
Example
mySettings.RandomlyGenerateSeed = FALSE.
mySettings.SeedValue = 12345
Must be a positive long value between 1 and 2147483647.
Appendix A: Controlling RISKOptimizer with VBA
275
SimStopMode
Integer. Determines how RISKOptimizer decides when each
simulation should stop. If SimStopMode is set to EvSimStopActual
or EvSimStopProjected, the convergence tolerance is controlled with
the SimConvergenceTolerance setting. If SimStopMode is set to
EvSimStopIterations, the number of iterations run is specified in
SimMaxIters.
Guidelines
Example
Must be one of the three public constants:
EvSimStopIterations
stop after exactly the # of iterations
specified in SimMaxIters
EvSimStopActual
stop when the output and constraints have
converged
EvSimStopProjected
similar to EvSimStopActual, except
RISKOptimizer is allowed to stop a
simulation before it has actually converged,
because it has predicted it will not be able to
make it into the population of best solutions
‘run exactly 1000 iterations each simulation
mySettings.SimStopIterations = TRUE
mySettings.MaxIters = 1000
SimMaxIters
Long. How many iterations should be run in a single simulation.
This setting only has effect if the SimStopMode setting is
EvSimStopIterations.
Example
‘run exactly 2500 iterations each simulation
mySettings.SimStopIterations = TRUE
mySettings.MaxIters = 2500
SimConvergenceTolerance
Double. A number specifying how strict the definition of
“convergence” is. This setting only has effect if the SimStopMode
setting is EvSimStopActual or EvSimStopProjected.
Guidelines
276
Either a number between 1-100 or the special constant
EvAutoTolerance.
Variables in EVSettingsType
SimsUseSameSeed
Boolean. Specifies that each simulation in RISKOptimizer will use the
same stream of random numbers. This is useful to reduce the effect of
random fluctuations between different simulations so that the effect of
the changing of the input cells can be identified.
Example
mySettings.SimsUseSameSeed = TRUE
SamplingType
Integer. Determines how distribution samples are generated during a
simulation.
Guidelines
Must be one of the two constants EvSamplingTypeMonteCarlo or
EvSamplingTypeLatinHypercube
Example
mySettings.SamplingType = EvSamplingTypeLatinHypercube
StandardRecalc
Integer. Specifies how the spreadsheet will recalculate in it’s normal
mode of operation (i.e. when you press the F9 key or tell Excel to
“CalcNow”).
Guidelines
Example
Must be one of the three public constants:
EvStandardRecalcMonteCarlo
each distribution calculates a
random sample
EvStandardRecalcTrueEV
each distribution calculates its
mean
EvStandardRecalcExpectedValue
each continuous distribution
calculates its mean. Each
discrete function calculate the
closest possible value to the
mean that can actually be
generated by that distribution
mySettings.StandardRecalc = EvStandardRecalcTrueEV
Appendix A: Controlling RISKOptimizer with VBA
277
RunStartMacro
Boolean. Indicates that the macro specified in the StartMacro setting
should be run whenever RISKOptimizer starts optimizing. The start
macro will run when RISKOptimizer starts optimizing or when
RISKOptimizer is restarted from a paused simulation. The EvPaused
variable indicates whether the optimization is being restarted from a
paused state. It is useful to have a StartMacro for initializing your
spreadsheet in a particular manner each time RISKOptimizer is run.
Example
mySettings.RunStartMacro = TRUE
mySettings.StartMacro = “myVBAMacro”
StartMacro
String. A macro to run when RISKOptimizer starts optimizing a
model. This setting only has effect when the RunStartMacro setting is
set to TRUE.
Guidelines
♦
Example
mySettings.RunStartMacro = TRUE
mySettings.StartMacro = “myVBAMacro”
VBA macro specified must be declared as a Public subroutine that
takes no arguments.
RunBeforeSimMacro
Boolean. Indicates that the macro specified in the BeforeSimMacro
setting should be run before each simulation begins.
Example
mySetting.RunBeforeSimMacro = TRUE
mySetting.BeforeSimMacro = “myVBAMacro”
BeforeSimMacro
String. A macro to run before each simulation begins. This setting
only has effect when the RunBeforeSimMacro setting is TRUE.
Example
278
mySetting.RunBeforeSimMacro = TRUE
mySetting.BeforeSimMacro = “myVBAMacro”
Variables in EVSettingsType
RunBeforeRecalcMacro
Boolean. Indicates that the macro specified in the BeforeRecalcMacro
setting should be run before each recalculation of the spreadsheet. The
BeforeRecalcMacro is called after RISKOptimizer has placed a new set
of values in the spreadsheet to evaluate, but before the recalculation
actually is performed. This is useful if you want your macro to
modify how the spreadsheet recalculates.
Example
mySettings.RunBeforeRecalcMacro = TRUE
mySettings.BeforeRecalcMacro = “myVBAMacro”
BeforeRecalcMacro
String. A macro to run before each recalculation of the spreadsheet.
This setting only has effect when the RunBeforeRecalcMacro setting
is set to TRUE.
Guidelines
♦
Example
mySettings.RunAfterRecalcMacro = TRUE
mySettings.AfterRecalcMacro = “myVBAMacro”
VBA macro specified must be declared as a Public subroutine that
takes no arguments.
RunAfterRecalcMacro
Boolean. Indicates that the macro specified in the AfterRecalcMacro
setting should be run after each recalculation of the spreadsheet. The
AfterRecalcMacro is called after RISKOptimizer has calculated your
spreadsheet, but before the output is stored internally. This is useful
if you want your macro to modify the output before it is stored
internally.
Example
mySettings.RunAfterRecalcMacro = TRUE
mySettings.AfterRecalcMacro = “myVBAMacro”
AfterRecalcMacro
String. A macro to run after each recalculation of the spreadsheet.
This setting only has effect when the RunAfterRecalcMacro setting is
set to TRUE.
Guidelines
♦
Example
mySettings.RunAfterRecalcMacro = TRUE
mySettings.AfterRecalcMacro = “myVBAMacro”
VBA macro specified must be declared as a Public subroutine that
takes no arguments.
Appendix A: Controlling RISKOptimizer with VBA
279
RunAfterSimMacro
Boolean. Indicates that the macro specified in the AfterSimMacro
setting should be run before each simulation begins.
Example
mySetting.RunBeforeSimMacro = TRUE
mySetting.BeforeSimMacro = “myVBAMacro”
AfterSimMacro
String. A macro to run after the each simulation ends. This setting
only has effect when the RunAfterSimMacro setting is TRUE.
Example
mySetting.RunAfterSimMacro = TRUE
mySetting.AfterSimMacro = “myVBAMacro”
RunAfterStorageMacro
Boolean. Indicates that the macro specified in the AfterStorageMacro
property should be run after RISKOptimizer stores the output value
for each iteration of the optimization. The AfterStorageMacro is called
after RISKOptimizer has retreived the output value from a particular
recalc of the spreadsheet. This is useful if you want to collect statistics
for each output value calculated by RISKOptimizer.
Example
mySettings.RunAfterStorageMacro = TRUE
mySettings.AfterStorageMacro = “myVBAMacro”
AfterStorageMacro
String. A macro to run after RISKOptimizer stores the output for each
iteration of the optimization. This setting only has effect when the
RunAfterStorageMacro setting is set to TRUE.
Guidelines
♦
Example
mySettings.RunAfterStorageMacro = TRUE
mySettings.AfterStorageMacro = “myVBAMacro”
280
VBA macro specified must be declared as a Public subroutine that
takes no arguments.
Variables in EVSettingsType
RunFinishMacro
Boolean. Indicates that the macro specified in the FinishMacro setting
should be run whenever RISKOptimizer stops optimizing. The finish
macro will run when RISKOptimizer stops optimizing or when
RISKOptimizer is paused. You can look in the public variable
EvPaused to determine in which manner RISKOptimizer was
terminated.
Example
mySettings.RunFinishMacro = TRUE
mySettings.FinishMacro = “myVBAMacro”
FinishMacro
String. A macro to run when RISKOptimizer stops optimizing. This
setting only has effect when the RunFinishMacro setting is set to
TRUE.
Guidelines
♦
Example
mySettings.RunFinishMacro = TRUE
mySettings.FinishMacro = “myVBAMacro”
VBA macro specified must be declared as a Public subroutine that
takes no arguments.
Appendix A: Controlling RISKOptimizer with VBA
281
EvAdjustableGroupType
Listing of EvAdjustableGroupType
Public Type EvAdjustableGroupType
Description as String
SolvingMethod As String
CrossoverRate As Double
MutationRate As Double
NumTimeBlocks As Integer
ConstRange As String
NumInputRanges As Integer
InputRanges() As EvInputRangeType
End Type
Variables in
EvAdjustableGroupType
Description
String. A comment that describes the AdjustableGroup.
Guidelines
♦
Example
mySettings.AdjustableGroups(1).Description = “This comment describes
AdjustableGroup #1.”
String must be less than 255 characters in length for Excel 7 and
Excel 5.
SolvingMethod
String. The solving method used for the evolution of this
AdjustableGroup.
Guidelines
♦
Must be a valid solving method.
The “recipe”, “order”, “grouping”, “schedule”, “project”, and
“budget” solving methods will always be available. It is also possible
to define custom solving methods using the RISKOptimizer
Developer’s Kit. To get a list of all the valid solving methods call the
EvGetListOfSolvingMethods function.
Example
282
mySettings.AdjustableGroups(1).SolvingMethod = “recipe”
EvAdjustableGroupType
CrossoverRate
Double. The crossover rate of this AdjustableGroup.
Guidelines
♦
Example
mySettings.AdjustableGroups(1).CrossoverRate = .15
Must be between 0 and 1.
MutationRate
Double. The mutation rate of this AdjustableGroup.
Guidelines
♦
Examples
mySettings.AdjustableGroups(1).MutationRate = .15
mySettings.AdjustableGroups(2).MutationRate = EvAutoMutate
Must be between 0 and 1 or the special value EvAutoMutate (for
Professional and Industrial versions of RISKOptimizer only).
NumTimeBlocks
Integer. The number of time blocks for the schedule solving method.
This setting only has effect when the SolvingMethod setting is set to
“schedule”.
Example
With mySettings.AdjustableGroups(1)
.SolvingMethod = “schedule”
.NumTimeBlocks = 6
End With
ConstRange
String. A range that defines the constraints list for the schedule
solving method or the preceding task list for the project solving
method. This setting only has effect when the SolvingMethod setting
is set to “schedule” or “project”.
Guidelines
Example
♦
Must be a contiguous range of cells in Excel.
♦
All cell references must be qualified with their sheet name.
With mySettings.AdjustableGroups(1)
.SolvingMethod = “schedule”
.ConstRange = “sheet1!$A$5:$C$18”
End With
With mySettings.AdjustableGroups(1)
.SolvingMethod = “project”
.ConstRange = “myDefinedName”
End With
Appendix A: Controlling RISKOptimizer with VBA
283
NumInputRanges
Integer. The number of different ranges that make up a group of
adjustable cells. This is the upper limit of the InputRanges array. If
you modify the size of the InputRanges array, you must update this
parameter.
Example
MsgBox “This AdjustableGroup has “ &
mySettings.AdjustableGroups(1).NumInputRanges & “ ranges.”
InputRanges()
Array of EvInputRangeType. This array stores the information about
each range that makes up a group of adjustable cells such as
minimum and maximum values for the range. The lowest element of
the array is 1 and the highest element of the array is given by the
NumInputRanges setting.
284
Variables in EvAdjustableGroupType
EvInputRangeType
Listing of EvInputRangeType
Public Type EvInputRangeType
Reference As String
MinValue As Double
MaxValue As Double
ExcludeMinValue As Boolean
ExcludeMaxValue As Boolean
IsInteger As Boolean
End Type
Variables in EvInputRangeType
Reference
String. The reference of the input range. The entered string
represents the Excel reference for a range of input cells to be adjusted
during an optimization. Any valid Excel reference or range name
may be specified, with the actual reference or range name entered as a
string in quotes.
Guidelines
Examples
♦
Must be a valid Excel reference or range name.
♦
All cell references must be qualified with a sheet name.
mySettings.AdjustableGroups(1).InputRanges(1).Reference =
"Sheet1!$C$10"
mySettings.AdjustableGroups(1).InputRanges(1).Reference="MyRangeNa
me"
MinValue
Double. The minimum value allowed for the cells in an input range
identified by Reference. A MinValue is only used if the input range
is in a group of adjustable cells which use the “recipe” or “budget”
solving method.
Examples
mySettings.AdjustableGroups(1).InputRanges(1).MinValue = 100
Appendix A: Controlling RISKOptimizer with VBA
285
MaxValue
Double. The maximum value allowed for the cells in an input range
identified by Reference. A MaxValue is only used if the input range
is in a group of adjustable cells which use the “recipe” or “budget”
solving method.
Examples
mySettings.AdjustableGroups(1).InputRanges(1).MaxValue = 200
ExcludeMinValue
Boolean. Specifies whether or not to include the entered MinValue in
the possible values allowed for the cells in an input range identified
by Reference. An entry of TRUE is equivalent to selecting the
operator < in the Adjustable Cells dialog box, while an entry of FALSE
is equivalent to selecting <= in the Adjustable Cells dialog box. This
setting only has effect if the input range is in a group of adjustable
cells which use the “recipe” or “budget” solving method.
Examples
mySettings.AdjustableGroups(1).InputRanges(1).ExcludeMinValue =
TRUE
ExcludeMaxValue
Boolean. Specifies whether or not to include the entered MaxValue in
the possible values allowed for the cells in an input range identified
by Reference. An entry of TRUE is equivalent to selecting the
operator < in the Adjustable Cells dialog box, while an entry of FALSE
is equivalent to selecting <= in the Adjustable Cells dialog box. This
setting only has effect if the input range is in a group of adjustable
cells which use the “recipe” or “budget” solving method.
Examples
mySettings.AdjustableGroups(1).InputRanges(1).ExcludeMaxValue =
TRUE
IsInteger
Boolean. Specifies whether the values in the cells in the input range
identified by Reference must be integers. This setting only has effect
if the input range is in a group of adjustable cells which use the
“recipe” or “budget” solving method.
Example
286
MySettings.AdjustableGroups(1).inputRanges(1).IsInteger = TRUE
Variables in EvInputRangeType
EvConstraintType
Listing of EvConstraintType
Public Type EvConstraintType
ConstraintType As Integer
EntryMode As Integer
Formula As String
PenaltyFunction as String
Description As String
RiskOptEvalTime As Integer
End Type
Variables in EvConstraintType
ConstraintType
Integer. The type of constraint. The possible constraints types are
EvConstraintHard and EvConstraintSoft. Hard constraints are
Boolean conditions that must evaluate to TRUE or FALSE. Any
organism that RISKOptimizer calculates that does not meet all the hard
constraints is not allowed to reproduce. Soft constraints are similar to
hard constraints, except instead of tossing out an organism that does
not meet a soft constraint, RISKOptimizer penalizes it depending on
how much the constraint was violated.
Guidelines
♦
Examples
mySettings.constraints(1).constraintType = EvConstraintHard
Must be one of the two defined public constants EvConstraintHard or EvConstraintSoft.
Appendix A: Controlling RISKOptimizer with VBA
287
EntryMode
Integer. Specifies what mode the constraint is entered in.
EvEntryModeSimple specifies that the constraint is defined as a
simple range of values, while EvEntryModeFormula specifies the
constraint is an Excel formula.
Guidelines
♦
Example
mySettings.constraints(1).EntryMode = EvEntryModeFormula
Must be one of the two defined public constraints
EvEntryModeSimple or EvEntryModeFormula.
Formula
String. The string that defines the constraint.
Guidelines
Example
♦
When the EntryMode setting is set to EvEntryModeFormula,
must be a valid Excel formula.
♦
When the EntryMode setting is set to EvEntryModeSimple, must
be a formula which includes a minimum and/or maximum value
and a reference separated by <, <=, >, >= or =.
♦
All cell references must be qualified with a sheet name.
♦
Simulation statistics functions can be included in formulas.
When EntryMode is set to EvEntryModeFormula:
With mySettings.constraints(1)
.ConstraintType = EvConstraintHard
.EntryMode = EvEntryModeFormula
.Formula = “=sheet1!$A$5 > sheet2!$G$6”
End With
When EntryMode is set to EvEntryModeSimple:
With mySettings.constraints(1)
.ConstraintType = EvConstraintHard
.EntryMode = EvEntryModeSimple
.Formula = “0<=sheet1!$A$5<=100”
End With
Example using simulation statistics functions :
With mySettings.constraints(1)
.ConstraintType = EvConstraintHard
.EntryMode = EvEntryMode = EvEntryModeSimple
.RiskOptEvalTime = EvEvalEachSim
.Formula = “RiskStdDev(Sheet1!$A$1) <= 8”
End With
288
Variables in EvConstraintType
PenaltyFunction
An Excel formula that describes a soft constraint’s penalty function. A
positive penalty will always move the result away from the optimal
value, while a negative penalty will move towards the optimal value.
Use the keyword deviation to indicate where in the function the
deviation (the distance from the valid constraint region) should be
used. This value will always be positive. This setting only has effect
if the ConstraintType setting is EvConstraintSoft.
Guidelines
Examples
♦
Must be a valid Excel formula.
♦
All cell references must be qualified with a sheet name.
MySettings.Constraints(1).PenaltyFunction =
“Abs(deviation*sheet1!$A$1)”
MySettings.Constraints(2).PenaltyFunction = “1000*deviation^2”
MySettings.Constraints(3).PenaltyFunction = “100*(exp(deviation/10)-1)”
RiskOptEvalTime
Integer. Specifies when the constraint should be evaluated. Has effect
only if ConstraintType is EvConstraintHard. An iteration hard
constraint is evaluated each iteration of each simulation. If on any
evaluation the constraint is not met, the simulation is immediately
stopped. A simulation hard constraint is only evaluated at the end of
a completed simulation.
Guidelines
Must be one of the two public constants EvEvalEachIter or
EvEvalEachSim.
Example
‘specify a sim constraint that requires the mean of cell $C$3 on sheet1 to be
positive.
With mySettings.Constraints(1)
.ConstraintType = EvConstraintHard
.ConstraintEntryMode = EvEntryModeSimple
.RiskOptEvalTime = EvEvalEachSim
.Formula = “RiskMean(Sheet1!$C$3) > 0”
End With
Description
String. A comment describing the constraint.
Guidelines
♦
Example
mySettings.Constraints(1).Description = “This is my constraint #1.”
String must be less than 255 characters in length.
Appendix A: Controlling RISKOptimizer with VBA
289
290
Variables in EvConstraintType
Status Variables Available During
an Optimization
The following status variables have meaning only after an
optimization has started. These can be accessed in macros run during
an optimization or after an optimization is finished. Macros to be run
are defined using the Macro variables in the EvSettingsType, such as
RunAfterRecalcMacro or RunBeforeRecalcMacro.
Variable
Type
Read-Write?
Description
EvBestValue
Double.
Read-Only.
The best value found by
RISKOptimizer so far.
EvConstraintValue(n)
Double.
Read-Only.
Only relevant during an
AfterStorageMacro.
Returns the value of the
nth non-range constraint.
For hard constraints, this
value is always 0 or 1. For
a soft constraint, the value
is the total deviation.
EvDisableStatusBar
Boolean.
Read-Write
Set to TRUE to prevent
RISKOptimizer from
updating Excel’s status
bar.
EvPaused
Boolean.
Read-Write
Indicates if an
RISKOptimizer
optimization is currently
paused. Setting this to
TRUE is equivalent to the
user pressing the
RISKOptimizer’s pause
button.
EvTotalTrials
Double.
Read-Only
The number of trials and
simulations that have been
performed.
EvStop
Boolean
Write-Only
Set to TRUE to stop the
RISKOptimizer
optimization.
EvTimeElapsed
Double
Read-Only
The elapsed optimization
time in milliseconds.
Appendix A: Controlling RISKOptimizer with VBA
291
EvValidTrials
292
Double
Read-Only
The number of valid trials
that have been performed.
Status Variables Available During an Optimization
VBA Reference - Public
RISKOptimizer Functions
EvCopyAdjustableGroup
Copies one EvAdjustableGroupType variable to another.
Function EvCopyAdjustableGroup(source As EvAdjustableGroupType, dest
As EvAdjustableGroupType) As Integer
Guidelines
Parameter
Description
source
The source EvAdjustableGroup variable that is to be
copied.
dest
The destination EvAdjustableGroup variable that is to
be filled.
Because EvAdjustableGroupType contains an array, you can not use
an assignment to copy it. In other words, the VBA statement:
destAdjustableGroup = sourceAdjustableGroup
' bad!
will not correctly copy the variable. The
EvCopyAdjustableGroup function is provided to allow you to do
this type of operation.
Return Value
A non-zero return code indicates an error. Use the EvError function
to get a description of the error.
Example
Sub Macro1()
Dim mySettings as EvSettingsType
Dim myAdjustableGroup as EvAdjustableGroupType
‘read the settings from the ActiveWorkbook and copy them into
myAdjustableGroup
If ReadEvSettings(ActiveWorkbook, mySettings) <> 0 then Exit Sub
If EvCopyAdjustableGroup(mySettings.AdjustableGroups(1),
myAdjustableGroup) <> 0 then Exit Sub
End Sub
Appendix A: Controlling RISKOptimizer with VBA
293
EvCopySettings
Copies one EvSettingsType variable to another.
Function EvCopySettings(source As EvSettingsType, dest As
EvSettingsType) as Integer
Guidelines
Parameter
Description
source
The source EvSettingsType variable that is to be copied.
dest
The destination EvSettingsType variable that is to be
filled.
♦
Copies one EvSettingsType variable to another. Because the
EvSettingsType variable contains an array, you can not use an
assignment to copy it. In other words, the VBA statement:
destEvSettings = sourceEvSettings
' bad!
will not correctly copy the variable. The EvCopySettings function
is provided to allow you to do this type of operation.
Return Value
A non-zero return code indicates an error. Use the EvError function
to get a description of the error.
Example
Sub Macro1()
Dim sourceSettings as EvSettingsType, destSettings as EvSettingsType
‘read the settings from the ActiveWorkbook and copy them into a second
variable.
If ReadEvSettings(ActiveWorkbook, sourceSettings) <> 0 then Exit Sub
If EvCopySettings(sourceSettings, destSettings) <> 0 then Exit Sub
End Sub
EvError
Returns a string description of an error.
Function EvError(errorCode as Integer) as String
Parameter
Description
errorCode
The error code to obtain a description of.
Return Value
A string which describes the error.
Example
Sub Macro1()
Dim ErrorCode%
Dim mySettings as EvSettingType
ErrorCode = EvReadSettings(ActiveWorkbook, mySettings)
If ErrorCode <> 0 then MsgBox EvError(ErrorCode)
End Sub
294
VBA Reference - Public RISKOptimizer Functions
EvGetListOfSolvingMethods
Returns a list of all the available solving methods.
Function EvGetListOfSolvingMethods(nameArray() as string) as integer
Parameter
Description
nameArray
An array to fill with the names of the solving methods.
Return Value
The number of solving methods. A negative value indicates an error.
Use the EvError function to get a description of the error.
Example
Sub Macro1()
Dim i%, nameArray$(), numMethods%
‘Cycle through all the solving methods
numMethods = EvGetListOfSolvingMethods(nameArray())
For i = 1 to numMethods
MsgBox “Solving method # “ & i & “ is “ & nameArray(i)
Next i
End Sub
EvOptimize
Starts (or restarts) an RISKOptimizer optimization.
Function EvOptimize(wb as workbook, stopRoutine as string) as Integer
Return Value
Parameter
Description
wb
The workbook to optimize.
stopRoutine
A VBA function to run when the optimization stops.
See below.
A non-zero return code indicates an error. Use the EvError function
to get a description of the error.
Appendix A: Controlling RISKOptimizer with VBA
295
Additional
Information
about the
StopRoutine
The normal behavior when RISKOptimizer meets one of the stopping
conditions is to present a dialog box to the user. If you want this
behavior specify an empty string for the StopRoutine. If you want to
suppress this feature, specify a public VBA function name in
StopRoutine. This is a callback function that RISKOptimizer will call
automatically when the optimization stops, instead of presenting the
normal stop dialog. The function must have the format:
Public Function myStopRoutine(stopReason as Integer) as Integer
The StopReason parameter is one of the following constants:
Constant
Description
EvStopTrials
RISKOptimizer has calculated the specified
number of trials.
EvStopMinutes
RISKOptimizer has been optimizing for the
specified number of minutes.
EvStopFormula
The stop formula evaluated to TRUE.
EvStopConvergence
The change in the output was less than the
amount specified.
EvStopButtonPressed
The user pressed RISKOptimizer’s stop
button or the ESC key.
EvStopTargetReached
RISKOptimizer exactly matched the target
value you specified.
EvStopOther
Other unspecified stopping conditions.
The return value from the Stop Routine should be one of the constant
values:
296
Constant
Description
EvBest
Stop optimizing – Place the best values found in the
spreadsheet.
EvOriginal
Stop optimizing – Place the original model values into
the spreadsheet.
EvLast
Stop optimizing – Place the last calculated values into
the spreadsheet.
EvContinue
Continue optimizing – Stop again if this condition
occurs again.
EvIgnore
Continue optimizing – Don’t stop again for this reason.
VBA Reference - Public RISKOptimizer Functions
EvIgnore acts like EvContinue if StopReason is
EvStopButtonPressed, or EvOther.
EvContinue acts like EvIgnore if StopReason is EvStopConvergence.
If you choose EvBest, EvOriginal, or EvLast, you may add any
combination of the following constants:
Constant
Description
EvSummaryWorksheet
create a summary worksheet
EvLogWorkbook
create a log workbook
EvLogWorkbookShowOnlyNewBest
restricts the entries in the log
to only those solutions that
led to a new best (must be
used with EvLogWorkbook).
These constants are additive. Thus if you want to generate a
summary worksheet, and a log with the best solutions, and restore the
model to the original cell values, the return value from your stop
routine would be:
EvSummaryWorksheet + EvLogWorkbook +
EvLogWorkbookShowOnlyNewBest + EvOriginal
If you add a constant to EvContinue, it is ignored.
Example
Sub Macro1()
EvOptimize ActiveWorkbook, “myStopRoutine”
End Sub
Public Function myStopRoutine(stopReason as integer) as integer
‘If the optimization stopped because of the time, keep going.
‘Otherwise, stop and put the best values in the spreadsheet.
if stopReason = EvStopMinutes then
myStopRoutine = EvContinue
Else
MyStopRoutine = EvBest + EvLogWorkbook
End If
End Function
Appendix A: Controlling RISKOptimizer with VBA
297
EvReadSettings
Fills an EvSettingsType variable with the RISKOptimizer settings
defined for a workbook.
Function EvReadSettings(wb as workbook, EvSettings as EvSettingsType)
as Integer
Parameter
Description
wb
The Excel workbook object.
EvSettings
The EvSettingsType variable that is to be filled.
Return Value
A non-zero return code indicates an error. Use the EvError function
to get a description of the error.
Example
Sub Macro1()
Dim EvSettings as EvSettingsType
If EvReadSettings(ActiveWorkbook, EvSettings) <> 0 then MsgBox “Call
failed.”: Exit Sub
MsgBox “The number of AdjustableGroups in this model is “ &
EvSettings.numAdjustableGroups
End Sub
EvReadSettingsDefaults
Loads an EvSettingsType variable with the default settings for a
model. This function is useful for filling an EvSettingsType variable,
when there are no defined settings for a model. The default settings
will have no AdjustableGroups or constraints.
Function EvReadSettingsDefaults(wb as workbook, EvSettings as
EvSettingsType) as Integer
Parameter
Description
wb
The Excel workbook object.
EvSettings
The EvSettingsType variable that is to be filled with
defaults.
Return Value
A non-zero return code indicates an error. Use the EvError function
to get a description of the error.
Example
Sub Macro1()
Dim EvSettings as EvSettingsType
If EvReadSettingsDefaults(ActiveWorkbook, EvSettings) <> 0 then Exit
Sub
MsgBox “The default population size is “ & EvSettings.PopulationSize
End Sub
298
VBA Reference - Public RISKOptimizer Functions
EvReadSettingsFromSummary
Fills an EvSettingsType variable with the RISKOptimizer settings
stored in the RISKOptimizer optimization summary worksheet for that
workbook. If no RISKOptimizer optimization summary worksheet
exists in the workbook specified, an error is returned. If the
optimization summary worksheet has been modified manually, it is
likely this call will fail.
Function EvReadSettingsFromSummary(wb as workbook, whichColumn as
integer, EvSettings as EvSettingsType) as Integer
Parameter
Description
wb
The Excel workbook object.
WhichColumn
The particular column of the RISKOptimizer
optimization summary worksheet that should be
retrieved.
EvSettings
The EvSettingsType variable that is to be filled.
Return Value
A non-zero return code indicates an error. Use the EvError function
to get a description of the error.
Example
Sub Macro1()
Dim EvSettings as EvSettingsType
‘get the model settings for the fourth column in the RISKOptimizer
'optimization summary worksheet of the active workbook and change the
'model to use these settings.
If EvReadSettingsFromSummary(ActiveWorkbook, 4, EvSettings) <> 0
then Exit Sub
If EvWriteSettings(EvSettings) <> 0 then Exit Sub
MsgBox “Successfully restored the old settings!”
End Sub
Appendix A: Controlling RISKOptimizer with VBA
299
EvRestoreValuesFromSummary
Puts the original or best input values displayed in a particular column
of the RISKOptimizer optimization summary worksheet back into the
spreadsheet model. If the model has significantly changed since the
optimization summary worksheet was created, it is likely this call will
fail. If the optimization summary worksheet has been modified
manually, it is likely this call will fail. Warning: this will overwrite the
values currently in the spreadsheet with older values.
Function EvRestoreValuesFromSummary(wb as workbook, whichColumn as
integer, whichValues as integer) as Integer
Parameter
Description
wb
The Excel workbook object.
WhichColumn
The particular column of the RISKOptimizer
optimization summary worksheet that values
should be taken from.
WhichValues
Either of the two constants EvBest or EvOriginal.
Return Value
A non-zero return code indicates an error. Use the EvError function
to get a description of the error.
Example
Sub Macro1()
Dim EvSettings as EvSettingsType
‘restore the best values from the fourth column in the optimization
summary 'worksheet worksheet
If EvRestoreValuesFromSummary(ActiveWorkbook, 4, EvBest) <> 0 then
Exit Sub
MsgBox “Successfully restored the old values!”
End Sub
300
VBA Reference - Public RISKOptimizer Functions
EvShowSettingsDlg
Displays the standard RISKOptimizer dialog box.
Function EvShowSettingsDlg(EvSettings as EvSettingsType) as Integer
Parameter
Description
EvSettings
A variable to store the settings in. These values are also
used as defaults when the dialog is first displayed.
Return Value
A non-zero return code indicates an error. Use the EvError function
to get a description of the error. If the user cancels the dialog, an error
is returned.
Example
Sub Macro1(mySettings as EvSettingsType)
‘put up a dialog to the user, and then store the results
If EvShowSettingsDlg(mySettings) <> 0 then Exit Sub
If EvWriteSettings(mySettings) <> 0 then Exit Sub
End Sub
EvWriteSettings
Stores an EvSettingsType variable into the workbook specified in the
EvSettings.wb parameter. If you make modifications to an
EvSettingsType variable, the settings are neither stored in a workbook
nor used in an optimization until you call this function. In addition,
these settings are not saved on disk until that workbook is saved to
disk.
Function EvWriteSettings(EvSettings As EvSettingsType) As Integer
Parameter
Description
EvSettings
The EvSettingsType variable that is to be stored.
Return Value
A non-zero return code indicates an error. Use the EvError function
to get a description of the error.
Example
Sub Macro1()
‘read the settings from the active workbook, change the population size, and
store it
If EvReadSettings(ActiveWorkbook, EvSettings) <> 0 then Exit Sub
EvSettings.PopulationSize = 100
If EvWriteSettings(EvSettings) <> 0 Exit Sub
MsgBox “Changed successfully!”
End Sub
Appendix A: Controlling RISKOptimizer with VBA
301
302
VBA Reference - Public RISKOptimizer Functions
Appendix B:
Troubleshooting / Q&A
Appendix B: Troubleshooting / Q&A
303
304
Troubleshooting / Q&A
Troubleshooting / Q&A
This section answers some commonly asked questions regarding
RISKOptimizer and keeps you up to date on common questions,
problems and suggestions. After reading through this section, you
may call Palisade customer support at the numbers listed in the
beginning chapter of this manual.
Q: Why am I having trouble getting a valid answer from
RISKOptimizer?
A: Make sure that the RISKOptimizer dialog is set up correctly. Most
of the problems are associated with the setting of the variables.
Each group of adjustable cells should be exclusive, in that no
single cell or range of cells is being treated with more than one
solving method.
Q: Can RISKOptimizer deal with concepts or categories instead of
just numbers?
A: RISKOptimizer can indirectly deal with any kind of data, since
numbers are just symbols. Use a lookup table in Excel to translate
between integers and strings of text. RISKOptimizer (like all
computer programs) ultimately can only deal with numbers, but
your interface may use those numbers to represent and display
any strings.
Q: Even though I’m filling in the dialogs the same way, and letting
RISKOptimizer run the same amount of time, why does
RISKOptimizer sometimes find different solutions?
A: As is the case with natural selection in the biological world, the
RISKOptimizer genetic algorithm will not always follow the same
path when searching for solutions (unless you use a fixed random
number generator seed). Ironically it is this “unpredictability”
that allows RISKOptimizer to solve more types of problems, and
often find better solutions than traditional techniques.
RISKOptimizer’s genetic algorithm engine is not just executing a
series of pre-programmed commands, or plugging values through
a mathematical formula, but it is efficiently experimenting with
many random hypothetical scenarios simultaneously, and then
refining the search through many “survival-of-the-fittest”
operators which also contain random elements.
Appendix B: Troubleshooting / Q&A
305
Q: Why is the best solution found not changing?
A: You may have specified the wrong target cell in the RISKOptimizer
Settings Dialog. RISKOptimizer is looking at this blank cell and
the value does not change because there is no formula. To fix this,
display the RISKOptimizer Settings dialog and select a proper
target cell; i.e. one that accurately reflects how good/bad each
possible solution is. A proper target cell has a formula which
depends, directly or indirectly, on the variables RISKOptimizer is
adjusting (adjustable cells).
Q: Some of the cells in my spreadsheet model contain “####”
symbols.
A: If the cell is too small to display all of its contents, it will display
several #### signs. Increase the size of the cell.
Q: RISKOptimizer is working OK, but is there any simple way to
get better results?
A: Consider loosening the constraints in the problem, including
variable ranges. Change some of your hard constraints to soft
constraints via penalty functions (see Adding Constraints in
Chapter 8: RISKOptimizer Extras). Too many restrictions on what
RISKOptimizer can try may be preventing RISKOptimizer from
exploring an area of possibilities that may yield better results.
Remember, the longer you let RISKOptimizer explore the
possibilities, the more likely it is to find the optimal solution. For
more ideas on how to fine-tune RISKOptimizer, see Chapter 8:
RISKOptimizer Extras.
The more scenarios RISKOptimizer can run through, the better.
Speed up the RISKOptimizer process by turning off the “Every
Recalculation” option for display update.
306
Troubleshooting / Q&A
Appendix C: Additional
Resources
Appendix C: Additional Resources
307
308
Additional Learning Resources
The following list represents a select sampling of genetic algorithm
and artificial-life-related materials. A star (*) indicates a Palisade
favorite.
Books
• Bolles, R.C., & Beecher, M.D. (Eds.). (1988). Evolution and Learning.
Lawrence Erlbaum.
• Beer, R.D. (1990). Intelligence as Adaptive Behavior: An Experiment in
Computational Neuroethology. Academic Press.
• Davis, Lawrence (1987). Genetic Algorithms and Simulated Annealing.
Palo Alto, CA: Morgan Kaufman.
* Davis, Lawrence (1991). Handbook of Genetic Algorithms. New York: Van
Nostrand Reinhold.
• Darwin, Charles (1985). On The Origin of Species. London: Penguin
Classics. (originally 1859)
* Dawkins, Richard. (1976). The Selfish Gene. Oxford University Press.
• Eldredge, N. (1989). Macroevolutionary Dynamics: Species, Niches, and
Adaptive Peaks. McGraw-Hill.
• Fogel, L., Owens, J., and Walsh, J. (1966). Artificial Intelligence through
Simulated Evolution. New York: John Wiley and Sons.
• Goldberg, David (1989). Genetic Algorithms in Search, Optimization, and
Machine Learning. Reading, MA: Addison-Wesley Publishing.
• Holland, J.H. (1975). Adaptation in Natural and Artificial Systems. Ann
Arbor, MI: University of Michigan Press.
• Koza, John (1992). Genetic Programming. Cambridge, MA: MIT Press.
* Langton, C.L. (1989). Artificial Life. MIT Press. [ALife I]
• Levy, Steven (1992). Artificial Life. New York: Pantheon.
• Meyer, J.-A., & S.W. Wilson (Eds.). (1991). Proceedings of the First
International Conference on Simulation of Adaptive Behavior: From
Animals to Animats. MIT Press/Bradford Books.
* Proceedings of the Sixth International Conference (ICGA) on Genetic
Algorithms (1995). San Mateo, CA: Morgan Kaufman Publishing. (Also
available; the first five ICGA proceedings).
• Proceedings of the Workshop on Artificial Life (1990). Christopher G.
Langton, Senior Editor. Reading, MA: Addison-Wesley Publishing.
• Rawlins, Gregory (1991). Foundations of Genetic Algorithms. San Mateo,
CA: Morgan Kaufman Publishing.
Appendix C: Additional Resources
309
• Richards, R.J. (1987). Darwin and the Emergence of Evolutionary Theories
of Mind and Behavior. U. Chicago Press.
• Williams, G.C. (1966). Adaptation and Natural Selection. Princeton U.
Press.
Articles
* Antonoff, Michael (October, 1991). Software by Natural Selection. Popular
Science, p. 70-74.
• Arifovic, Jasmina (January, 1994). Genetic Algorithm Learning and the
Cobweb Model. In Journal of Economic Dynamics & Control v18 p.3
* Begley, S (May 8, 1995). “Software au Naturel” In Newsweek p. 70
• Celko, Joe (April, 1993). Genetic Algorithms and Database Indexing. In Dr.
Dobb’s Journal p.30
• Ditlea, Steve (November, 1994). Imitation of Life. In Upside Magazine p.48
• Gordon, Michael (June, 1991). User-based Document Clustering by
Redescribing Subject Descriptions with a Genetic Algorithm. In Journal
of the American Society for Information Science v42 p.311
• Hedberg, Sara (September, 1994). Emerging Genetic Algorithms. In AI
Expert, p. 25-29.
• Hinton, G.E., & Nowlan, S.J. (1987). How Learning Can Guide Evolution.
In Complex Systems 1: p.495-502.
* Kennedy, Scott (June, 1995). Genetic Algorithms: Digital Darwinism. In
Hitchhicker’s Guide to Artificial Intelligence Miller Freeman Publishers
• Kennedy, Scott (December, 1993). Five Ways to a Better GA. In AI Expert,
p. 35-38
• Lane, A (June, 1995). The GA Edge in Analyzing Data. In AI Expert p.11
• Lee, Y.C. (Ed.). (1988). Evolution, learning, and cognition. In World
Scientific.
• Levitin, G and Rubinovitz, J (August, 1993). Genetic Algorithm for Linear
and Cyclic Assignment Problem. In Computers & Operations Research
v20 p.575
• Marler, P., & H.S. Terrace. (Eds.). (1984). The Biology of Learning.
Springer-Verlag.
• Mendelsohn, L. (December, 1994) Evolver Review In Technical Analysis of
Stocks and Commodities. p.33
• Maynard Smith, J. (1987). When Learning Guides Evolution. In Nature
329: p.761-762.
• Murray, Dan (June, 1994). Tuning Neural Networks with Genetic
Algorithms. In AI Expert p.27
310
• Wayner, Peter (January, 1991). Genetic Algorithms: Programming Takes a
Valuable Tip from Nature. In Byte Magazine v16 p.361
Magazines & Newsletters
• Advanced Technology for Developers (monthly newsletter). Jane
Klimasauskas, Ed., High-Tech Communications, 103 Buckskin Court,
Sewickley, PA 15143 (412) 741-7699
• AI Expert (monthly magazine). Larry O’Brien, Ed., 600 Harrison St., San
Francisco, CA 94107 (415) 905-2234. *Although AI Expert ceased
publishing in the spring of 1995, its back issues contain many useful
articles. Miller-Freeman, San Francisco.
• Applied Intelligent Systems (bimonthly newsletter). New Science
Associates, Inc. 167 Old Post Rd., Southport, CT 06490 (203) 259-1661
• Intelligence (monthly newsletter). Edward Rosenfeld, Ed., PO Box 20008,
New York, NY 10025-1510 (212) 222-1123
• PC AI Magazine (monthly magazine). Joseph Schmuller, Ed., 3310 West
Bell Rd., Suite 119, Phoenix, AZ 85023 (602) 971-1869
• Release 1.0 (monthly newsletter). Esther Dyson, Ed., 375 Park Avenue,
New York, NY 10152 (212) 758-3434
• Sixth Generation Systems (monthly newsletter). Derek Stubbs, Ed., PO Box
155, Vicksburg, MI, 49097 (616) 649-3592
Appendix C: Additional Resources
311
Introduction to Simulation
If you are new to Simulation or if you would just like some more
background information on the technique, the following books and
articles might be helpful:
* Baird, Bruce F. Managerial Decisions Under Uncertainty: John Wiley &
Sons, Inc. 1989.
* Clemen, Robert T. Making Hard Decisions: Duxbury Press, 1990.
• Hertz, D.B. "Risk Analysis in Capital Investment": HBR Classic, Harvard
Business Review, September/October 1979, pp. 169-182.
• Hertz, D.B. and Thomas, H. Risk Analysis and Its Applications: John Wiley
and Sons, New York, NY, 1983.
• Megill, R.E. (Editor). Evaluating and Managing Risk: PennWell Books,
Tulsa, OK, 1984.
• Megill, R.E. An Introduction to Risk Analysis, 2nd Ed.: PennWell Books,
Tulsa, OK, 1985.
• Morgan, M. Granger and Henrion, Max, with a chapter by Mitchell Small,
Uncertainty: Cambridge University Press, 1990.
• Newendorp, P.D. Decision Analysis for Petroleum Exploration: Petroleum
Publishing Company, Tulsa, Okla., 1975.
• Raiffa, H. Decision Analysis: Addison-Wesley, Reading, Mass., 1968.
312
Technical References to Simulation and
Monte Carlo Techniques
If you would like a more in depth examination of simulation,
sampling techniques and statistical theory, the following books may
be useful:
• Iman, R. L., Conover, W.J. "A Distribution-Free Approach To Inducing
Rank Correlation Among Input Variables": Commun. Statist.-Simula.
Computa.(1982) 11(3), 311-334
* Law, A.M. and Kelton, W.D. Simulation Modeling and Analysis: McGrawHill, New York, NY, 1991,1982.
Rubinstein, R.Y. Simulation and the Monte Carlo Method: John Wiley and
Sons, New York, NY, 1981.
Technical References to Latin Hypercube
Sampling Techniques
If you are interested in the relatively new technique of Latin
Hypercube sampling, the following sources might be helpful:
• Iman, R.L., Davenport, J.M., and Zeigler, D.K. "Latin Hypercube Sampling
(A Program Users Guide)": Technical Report SAND79-1473, Sandia
Laboratories, Albuquerque (1980).
• Iman, R.L. and Conover, W.J. "Risk Methodology for Geologic Displosal of
Radioactive Waste: A Distribution - Free Approach to Inducing
Correlations Among Input Variables for Simulation Studies": Technical
Report NUREG CR 0390, Sandia Laboratories, Albuquerque (1980).
• McKay, M.D, Conover, W.J., and Beckman, R.J. "A Comparison of Three
Methods for Selecting Values of Input Variables in the Analysis of
Output from a Computer Code": Technometrics (1979) 211, 239-245.
• Startzman, R. A. and Wattenbarger, R.A. "An Improved Computation
Procedure for Risk Analysis Problems With Unusual Probability
Functions": SPE Hydrocarbon Economics and Evaluation Symposium
Proceedings, Dallas (1985).
Appendix C: Additional Resources
313
Examples and Case Studies Using Simulation
If you would like to examine case studies showing the use of
Simulation in real life situations, see the following:
Hertz, D.B. and Thomas, H. Practical Risk Analysis - An Approach Through
Case Histories: John Wiley and Sons, New York, NY, 1984.
* Murtha, James A. Decisions Involving Uncertainty, An @RISK Tutorial for
the Petroleum Industry: James A. Murtha, Houston, Texas, 1993
• Newendorp, P.D. Decision Analysis for Petroleum Exploration: Petroleum
Publishing Company, Tulsa, Okla., 1975.
• Pouliquen, L.Y. Risk Analysis in Project Appraisal: World Bank Staff
Occasional Papers Number Eleven. John Hopkins Press, Baltimore, MD,
1970.
* Trippi, Robert R. and Truban, Efraim, Neural Networks: In Finance and
Investing: Probus Publishing Co., 1993
314
Glossary
Glossary
315
Glossary
316
For additional information on any term, refer to the RISKOptimizer
index in the following chapter.
Algorithm
A mathematically based step-by-step method of solving a certain kind
of problem. All computer programs are built by combining many
algorithms.
Adjustable Cell
A spreadsheet cell whose value can be adjusted by RISKOptimizer to
try to optimize the value of the target cell. An adjustable cell is a
variable value and should always contain a simple number, rather
than an equation.
Baby Solver
slang Simple software programs that find the inputs which produce a
desired output using a combination of linear programming
techniques, or basic hill-climbing algorithms. Baby solvers often take
guesses, then refine their answer to arrive at a “local” solution rather
than a “global” solution.
Cell
The cell is the basic unit of a spreadsheet in which data is stored.
There are up to 256 columns and 16,000 rows, for a total of more than
4 million cells, in each Excel worksheet.
Constraints
Constraints are conditions which should be met (soft constraints) or
must be met (hard constraints) for a scenario to be considered valid.
Continuous
Distribution
A probability distribution where any value between the minimum
and maximum is possible (has finite probability).
See discrete distribution
Crossover
In a genetically based context, crossing over is an exchange of
equivalent genetic material between homologous chromatids during
meiosis. In RISKOptimizer, the term crossover is used to express the
computational equivalent to crossing over, where an exchange
between variables yields new combinations of scenarios.
Cumulative
Distribution
A cumulative distribution, or a cumulative distribution function, is
the set of points, each of which equals the integral of a probability
distribution starting at the minimum value and ending at the
associated value of the random variable.
See cumulative frequency distribution, probability distribution
Glossary
317
Cumulative
Frequency
Distribution
A cumulative frequency distribution is the term for the output and the
input cumulative distributions of RISKOptimizer. A cumulative
distribution is constructed by cumulating the frequency (progressively
adding bar heights) across the range of a frequency distribution. A
cumulative distribution can be an "upwardly sloping" curve, where
the distribution describes the probability of a value less than or equal
to any variable value. Alternatively, the cumulative curve may be a
"downwardly sloping" curve, where the distribution describes the
probability of a value greater than or equal to any variable value.
See cumulative distribution
Dependent
Variable
A dependent variable is one that depends in some way on the values
of other variables in the model under consideration. In one form, the
value of an uncertain dependent variable can be calculated from an
equation as a function of other uncertain model variables.
Alternatively, the dependent variable may be drawn from a
distribution based on the random number which is correlated with a
random number used to draw a sample of an independent variable.
See independent variable
Deterministic
The term deterministic indicates that there is no uncertainty
associated with a given value or variable.
Dialog
The window on a computer screen that requests the user to provide
information. Also called dialog box. RISKOptimizer contains two
major dialogs; the RISKOptimizer Settings Dialog, and the Adjustable
Cells Dialog.
Discrete
Distribution
A probability distribution where only a finite number of discrete
values are possible between the minimum and maximum.
See continuous distribution
Field
The basic unit of data entry. Depending on its field type, a field can
contain text, pictures, or numbers. Most fields in the RISKOptimizer
dialogs ask the user to input the location of spreadsheet cells, or
options regarding how RISKOptimizer should behave.
Fitness
Function
This is a formula which can calculate how good or bad any proposed
solution is to a given problem. The term is often used in the genetic
algorithm field as an analogy to “fitness” in biological selection.
Designing an accurate fitness function is critical when using a genetic
algorithm to solve a problem. A simulation result for this fitness
function becomes the goal or target value to be optimized.
318
Functions
Frequency
Distribution
In Excel, a function is a pre-defined formula that takes a value,
performs an operation, and returns a value. Excel contains hundreds
of built-in formulas (like “SUM”) that save time, space, and are faster.
For example, instead of typing A1+ A2+ A3+ A4+ A5+ A6, you can
type SUM(A1:A6) and get the same result.
Frequency distribution is the proper term for the output probability
distributions and the input histogram distributions (HISTOGRM) of
RISKOptimizer. A frequency distribution is constructed from data by
arranging values into classes and representing the frequency of
occurrence in any class by the height of the bar. The frequency of
occurrence corresponds to probability.
Genetic
Algorithm
A procedure for improving results of some operation by repeatedly
trying several possible solutions and reproducing and mixing the
components of the better solutions. The process is inspired by, and
crudely similar to, the process of evolution in the biological world,
where the fittest survive to reproduce.
Generation
In the field of genetic algorithms, each completely new population of
“offspring” solutions is a new “generation”. Some genetic algorithm
routines mate all members of a population at once, creating a whole
new “generation” of offspring organisms that replaces the previous
population. RISKOptimizer evaluates and replaces one organism at a
time (rank-ordered) and thus does not use the term “generation” in its
documentation. This steady state technique works as well as
generational replacement.
Genotype
In biology, this is the genetic constitution of an individual. The term
usually refers to the sum total of the individual’s genes. In the study
of GAs, genotype is used to describe the artificial “chromosome” that
is evaluated as a possible solution to the problem.
Global
Maximum
The largest possible value for a given function. Complex functions or
models may have many local maxima but only one global maximum.
Group of
Adjustable cells
Each set of variables, along with the way they will be treated, is one
group of adjustable cells. RISKOptimizer will list all groups of
adjustable cells in the variables section of the RISKOptimizer Settings
Dialog. This architecture allows complex problems to be built and
described as several groups of adjustable cells.
Hard
Constraints
A constraint that must always be met. For example, the ranges for
variables in a recipe problem are hard constraints; a variable set to
range between 10 and 20 can never have a value less than 10 or
greater than 20. See also soft constraints.
Higher Moments
Glossary
319
Higher moments are statistics of a probability distribution. The term
generally refers to the skewness and kurtosis, the third and fourth
moments respectively. The first and second moments are the mean
and the standard deviation respectively. See skewness, kurtosis, mean,
standard deviation
Hill-Climbing
Algorithm
An optimization procedure that starts from a given scenario and
repeatedly moves the scenario in small steps in the direction that will
most improve it. Hill-climbing algorithms are fast and simple, but
have two drawbacks. First, much work may be needed to find the
direction of most improvement. Second, the algorithms usually climb
the nearest hill, or local maximum. This prevents the algorithm from
finding the global maximum in a difficult problem.
Independent
Variable
An independent variable is one that does not depend in any way on
the values of any other variable in the model under consideration.
The value of an uncertain independent variable is determined by
drawing a sample from the appropriate probability distribution. This
sample is drawn without regard to any other random sample drawn
for any other variable in the model.
See dependent variable
Iteration
An iteration is one recalculation of the user's model during a
simulation. A simulation consists of many recalculations or iterations.
During each iteration, all uncertain variables are sampled once
according to their probability distributions, and the model is
recalculated using these sampled values.
Also known as a simulation trial
Kurtosis
Kurtosis is a measure of the shape of a distribution. Kurtosis indicates
how flat or peaked the distribution is. The higher the kurtosis value,
the more peaked the distribution.
See skewness
Latin Hypercube
Latin Hypercube sampling is a relatively new stratified sampling
technique used in simulation modeling. Stratified sampling
techniques, as opposed to Monte Carlo type techniques, tend to force
convergence of a sampled distribution in fewer samples.
See Monte Carlo
Local Maximum
320
The largest possible value for a given function within a given range of
values. A local maximum exists at a set of values for variables in a
function if slightly changing any or all of the variables’ values
produces a smaller result from the function. (Compare with global
maximum).
Mean
The mean of a set of values is the sum of all the values in the set
divided by the total number of values in the set. Synonym: expected
value
Model
For the purposes of this manual, a model is a numeric representation,
in Excel, of a real-world situation.
Monte Carlo
Monte Carlo refers to the traditional method of sampling random
variables in simulation modeling. Samples are chosen completely
randomly across the range of the distribution, thus necessitating large
numbers of samples for convergence for highly skewed or long-tailed
distributions.
See Latin Hypercube
Most Likely
Value
The most likely value or mode is the value that occurs most often in a
set of values. In a histogram and a result distribution, it is the center
value in the class or bar with the highest probability.
Mutation
In the biological world, gene mutation is the source of variation
needed for effective natural selection. Likewise, a genetic algorithm
uses mutation techniques to maintain diversity in a population of
possible scenarios.
Optimization
The process of finding values for variables so that the output of a
function can be maximized (made as large as possible) or minimized
(made as small as possible). Optimization by equation solving is easy
for smoothly changing functions with few variables, but extremely
difficult for many real-world problems. Tough problems generally
need a search mechanism. RISKOptimizer uses an optimizing search
mechanism based upon a genetic algorithm.
Organism
A block of memory in a population that stores a set of variable values
(scenario).
Penalty
Function
A spreadsheet equation that RISKOptimizer can use to penalize
scenarios that fail to meet some criteria. Penalty functions are used to
help minimize side effects from scenarios or to achieve multiple goals.
Unlike a hard constraint, a penalty function does allow invalid
solutions to be explored; it just makes those solutions look bad so the
population will evolve away from those solutions. Boolean penalties
are either on or off, penalizing all invalid solutions by the same
amount. Scaling penalties are more fluid, assigning a penalty in
proportion to how badly a constraint is violated.
Percentile
A percentile is an increment of the values in a data set. Percentiles
divide the data into 100 equal parts, each containing one percent of
the total values. The 60th percentile, for example, is the value in the
data set for which 60% of the values are below it and 40% are above.
Glossary
321
Phenotypes
In biology, this is an observable trait of an individual which arises
from interactions between genes, and between genes and the
environment. In the study of GAs, phenotype is used to describe the
individual variables or “genes” that make up one complete solution or
“chromosome”. (see Genotype)
Population
The entire set of scenarios that RISKOptimizer keeps in memory from
which new scenarios are generated. RISKOptimizer keeps one
population of possible solutions for each group of adjustable cells in a
system.
Probability
Probability is a measure of how likely a value or event is to occur. It
can be measured from simulation data as frequency by calculating the
number of occurrences of the value or event divided by the total
number of occurrences. This calculation returns a value between 0
and 1 which then can be converted to percentage by multiplying by
100.
See frequency distribution, probability distribution
Probability
Distribution
A probability distribution or probability density function is the proper
statistical term for a frequency distribution constructed from an
infinitely large set of values where the class size is infinitesimally
small.
See frequency distribution
Random
Number
Generator
A random number generator is an algorithm for choosing random
numbers, typically in the range of 0 to 1. These random numbers are
equivalent to samples drawn from a uniform distribution with a
minimum of 0 and a maximum of 1. Such random numbers are the
basis for other routines that convert them into samples drawn from
specific distribution types.
See random sample, seed
Random Sample
A random sample is a value that has been chosen from a probability
distribution describing a random variable. Such a sample is drawn
randomly according to a sampling "algorithm". The frequency
distribution constructed from a large number of random samples
drawn by such an algorithm will closely approximate the probability
distribution for which the algorithm was designed.
Ranges
In RISKOptimizer:
The user sets the range, or the highest and lowest value that
RISKOptimizer is allowed to try when adjusting a certain variable.
Although this is not necessary to solve a problem, setting these ranges
limits the possibilities and hence narrows RISKOptimizer’s search.
In Excel:
322
Scenario
A block of contiguous cells in a worksheet that is defined by the upper
left cell and the lower right cell (e.g. A5:C9 describes a range of 15
cells).
A set of values for the variables in a spreadsheet model. Each
scenario most often represents one possible solution.
Simulation
Simulation is a technique whereby a model, such as a Excel
worksheet, is calculated many times with different input values with
the intent of getting a complete representation of all possible scenarios
that might occur in an uncertain situation.
Skewness
Skewness is a measure of the shape of a distribution. Skewness
indicates the degree of asymmetry in a distribution. Skewed
distributions have more values to one side of the peak or most likely
value — one tail is much longer than the other. A skewness of 0
indicates a symmetric distribution, while a negative skewness means
the distribution is skewed to the left. Positive skewness indicates a
skew to the right. See kurtosis
Solution
Any given system contains many input variables producing an
output. In RISKOptimizer, a “solution” will more often refer to one of
the possible combinations of variables rather than the best
combination.
Soft Constraints
When constraints do not necessarily have to be met, they can be made
soft instead of hard. This is done by specifying a penalty function in
RISKOptimizer or adding a penalty function to the target cell’s fitness
function.
It is often better for constraints to be soft if possible. This is because:
1. RISKOptimizer can usually solve softly-constrained problems faster,
and 2. a soft-constraint model often will find a great solution that
almost meets the soft constraints, which can be more valuable than a
not-so-great solution that does meet hard constraints.
Solving Method
RISKOptimizer includes six of these methods, each using a customized
algorithm to solve a specific type of problem. For each set of variables
selected in a problem, the user must assign the solving method to be
used on those variables. The six solving methods are: grouping,
order, recipe, budget, project, and schedule.
Standard
Deviation
The standard deviation is a measure of how widely dispersed the
values are in a distribution. Equals the square root of the variance.
See variance
Stochastic
Stochastic is a synonym for uncertain, risky.
See risk, deterministic
Glossary
323
Status Bar
The status bar appears at the bottom of the Excel window, and
displays RISKOptimizer’s current activity.
Survival of the
Fittest
The idea that organisms better suited to an environment are more
likely to live long enough to reproduce and spread their genes
through the population’s next generation.
Target Cell
The spreadsheet cell whose value we want to minimize or maximize.
This cell is set in the RISKOptimizer Settings Dialog (select
“RISKOptimizer” from the “Tools” menu).
Trials
The process of RISKOptimizer generating a value for each variable in
the problem, then recalculating the scenario for evaluation.
324
Index
A
Accept button
Add - Adding Constraints
adjustable cell groups
adding
creating
deleting
editing
adjustable cells
Adjustable cells dialog
description
adjustable cells dialog
screen picture
Adjustable cells dialog
crossover rate
mutation rate
options
screen picture
AdjustableGroups
advertising selection example
AfterRecalcMacro
AfterStorageMacro
algorithm, defined
alphabetize example
Authorization
122
104
88
88
89
89
87
89
42
99
100
99
89
258, 266, 267, 278, 279, 280, 281, 282, 289, 294
67
261, 262, 275, 287
261, 276, 287
137
81
11
B
backtracking
BeforeRecalcMacro
budget allocation example
budget solving method
description
example
251
261, 262, 275, 287
61
93
61, 67, 75
C
CellToOptimize
chemical equilibrium example
class scheduler example
combinatorial problems
Index
265
63
65
146–47
325
constraints
implementation
in schedule solving method
soft
Constraints
ConstraintType
ConstRange
continuous models
Correlation
Instances, Multiple
Rank Order
Create Menu
crossover rate
how it is implemented
introduction
Crossover rate
in Evolver Watcher
what it does
Crossover Rate
CrossoverRate
custom solving method
237–44
251
95
239
258, 267, 285
257, 267, 278, 280, 281, 282, 283, 284
278, 279
143
216
218
134
249
99
126
99
156
278, 279
278
D
databases
Defining Evolver Settings Using Code
Delete button
Distribution
Shifting
Truncating
146
258
89
222
223
E
Edit button
EntryMode
EvAdjustableGroupType
EvConstraintType
EvCopyAdjustableGroup
EvCopySettings
EvError
EvGetListOfSolvingMethod
Evolver
capabilities
how it is implemented
Settings dialog
Settings screen
Tutorial
what is it?:
Evolver Watcher
icon
illustration
326
89
281, 283, 284
257, 259, 267, 278, 281, 283, 289
257, 267, 278, 280, 281, 283
259, 289
259, 290
259, 289, 290, 291, 294, 295, 296, 297
278, 291
144–47
249
85
41
14
17
14
125
EvOptimize
EvReadSettings
EvRestoreValuesFromLog
EvSettingsType
EvShowSettingsDlg
EvWriteSettings
Excel Solver (see Solver
261, 291, 293
258, 290, 294, 295, 296, 297
296
257, 258, 259, 263, 287, 289, 290, 294, 295, 296, 297
297
258, 295, 297
143
F
Find the...
FinishMacro
fitness function
for the cell...
86
261, 277
35, 86
86
G
gene pool
generations
why they aren’t used
genetic operator
global solution
vs. local solution
Glossary
Graph progress
options
Graph Progress
GraphProgress
graphs
line graph
line graph button
population chart
GRG routines
grouping solving method
description
example
157
249
101, 103
143
312
128
111
271
52
127
129
143
92
71
H
hill climbing
an example
described
Solver’s use
139
145
144–45
143
I
InputRanges
Inputs
Collecting Distribution Samples
Locking
Naming
Index
258, 267, 278, 280, 281, 282
215
222
222
327
Integers checkbox
iteration constraint
97
30, 31, 45, 46, 50, 82, 105, 114, 239
J
job shop example
69
L
landscape of solutions
Latin Hypercube
LaunchSolver
learning Evolver
linear problems
local solution
vs. global solution
Logging Simulation Data
138
118
271
14
144
143
51
M
Macros
min/max/value closest options
minutes
Modeling Uncertainty
Monte Carlo
multiple goal problems
mutation rate
how it is implemented
introduction
Mutation rate
in Evolver Watcher
what it does
MutationRate
116
86
113
4
118
244
250
99
126
100
278, 279
N
non-linear problems
NumAdjustableGroups
NumConstraints
NumInputRanges
NumTimeBlocks
144–45
258, 266, 267
258, 267
258, 278, 280
278, 279
O
Of the
Operators
optimization
example
methods
what is it?
Optimization Log
Optimization Stopping Conditions
328
86
101, 103
141
137
19
131
113
optimization summary worksheet
OptimizationGoal
options
min/max/value closest
target cell
order solving method
description
example
53, 109, 113, 122, 123, 124, 258, 295, 296
266
86
86
91
69, 79
P
Palisade Corporation
Parameters
Alternate
Pause on Error
PauseOnError
Penalty Function
penalty functions
examples
explained
using
PenaltyFunction
Percentile
Percentiles
Cumulative Descending
Spreadsheet Function
Population
Size
population chart button
population report button
PopulationSize
portfolio balancing example
portfolio mix example
Probability Distributions
problems
combinatorial
linear
non-linear
table-based
project solving method
description
9
176
111
271
108
243
240
243
281, 283, 285
26, 87, 265, 266, 317
178
230
110
129
130
270, 294, 297
71
75
18, 28
146–47
144
144–45
146
94
R
Random Number Seed
RandomlyGenerateSeed
Read Me file
recipe solving method
description
example
Index
112
271
14
90
63, 81
329
Removing RISKOptimizer from Your Computer
replacement method
Risk Functions
Arguments
Arrays
Property Functions
RISKCollect
RISKCorrmat
RISKCurrentIter
RISKCurrentSim
RISKData
RISKDepC
RISKFit
RISKIndepC
RISKKurtosis
RISKLock
RISKMax
RISKMin
RISKMode
RISKName
RISKOutput
RISKPercentile
RISKRange
RISKShift
RISKSkewness
RISKStdDev
RISKTarget
RISKTruncate
RISKVariance
Shifting
Statistic Functions
Table of
Truncating
RunAfterRecalcMacro
RunAfterStorageMacro
RunBeforeRecalcMacro
RunFinishMacro
RunStartMacro
12
250
179
180
176, 215–24
215
216
233
233
228
218
220
221
229
222
229
230
230
222
226
230
231
222
231
231
232
223
232
222
227–32
181–88
223
262, 275, 287
276
262, 275, 287
277
274
S
salesman problem example
Sampling
schedule solving method
description
example
SeedValue
Selecting the Statistic to Minimize or Maximize
selection routine
settings dialog
330
79
118
95
65
271
87
249
41
Index
description
85
screen picture
85
Simplex Method
144
simulation constraint
5, 30, 31, 45, 47, 50, 75, 78, 82, 105, 106, 114, 115, 239
Simulation Optimization Process
26
Simulation Sampling Type
118
Simulation Stopping Conditions
49, 50, 114
size of population
110
soft constraints
239
Soft Constraints
107
Soft Constraints in Worksheet Formulas
109
Solver
143
solving methods
as constraints
238
budget
93
example
61, 67, 75
grouping
92
example
71
order
91
example
69, 79
project
94
recipe
90
example
63, 81
schedule
95
example
65
what are they?
90
SolvingMethod
278, 279, 291
speed, improving
247
Standard Recalc
118
StartMacro
261, 274
Statistic for the Target Cell
41
status bar
51, 121, 125, 133, 247, 287, 320
stop alert
53
Accept button
122
options
54
Restore button
122
stop button
122
Stop on Actual Convergence
114
Stop on Projected Convergence
115
StopChangeIsPercent
269, 270
StopChangeMagnitude
269, 270
StopChangeTrials
269
StopFormula
270, 292
StopMinutes
268, 292, 293
StopOnChange
269, 270
StopOnFormula
270
StopOnMinutes
268
StopOnTrials
267, 268
stopping condition
261, 269, 292
stopping conditions
331
minutes
Stopping conditions
introduction
StopTrials
113
49
267, 268, 292
T
table-based problems
Target
target cell
TargetValue
technical specifications
Tolerance Option
toolbar
Evolver Watcher
introduction
magnifying glass
pause button
picture
run button
stop button
traveling salesman example
Truncation
tutorial
146
29, 41, 87, 111, 263, 265, 266, 292, 320
86
266
249
115
125
121
125
121
121
121
122
79
223
14
U
Update Display
Use Same Seed Each Sim
112
112
V
Variables dialog
Integers checkbox
97
W
WB
332
265
Fly UP