Vous êtes sur la page 1sur 11

Simulation Tutorial - Introduction Simulation Simulation is a flexible methodology we can use to analyze the behavior of a present or proposed business

activity, new product, manufacturing line or plant expansion, and so on (analysts call this the 'system' under study). By performing simulations and analyzing the results, we can gain an understanding of how a present system operates, and what would happen if we changed it -- or we can estimate how a proposed new system would behave. Often -- but not always -- a simulation deals with uncertainty, in the system itself, or in the world around it.

Simulation Applications Simulation Models Simulation Methods Monte Carlo Simulation

Simulation Applications Simulation is one of the most widely used quantitative methods -- because it is so flexible and can yield so many useful results. Here's just a sample of the applications where simulation is used:

Choosing drilling projects for oil and natural gas Evaluating environmental impacts of a new highway or industrial plant Setting stock levels to meet fluctuating demand at retail stores Forecasting sales and production requirements for a new drug Planning aircraft sorties and ship movements in the military Planning for retirement, given expenses and investment performance Deciding on reservations and overbooking policies for an airline Selecting projects with uncertain payoffs in capital budgeting

Simulation Models In a simulation, we perform experiments on a model of the real system, rather than the real system itself. We do this because it is faster, cheaper, or safer to perform experiments on the model. While simulations can be performed using physical models -- such as a scale model of an airplane -- our focus here is on simulations carried out on a computer. Computer simulations use a mathematical model of the real system. In such a model we use variables to represent key numerical measures of the inputs and outputs of the system, and we use formulas, programming statements, or other means to express mathematical relationships between the inputs and outputs. When the simulation deals with uncertainty, the model will include uncertain variables -- whose values are not under our control -- as well as decision variables or parameters that we can control. The uncertain variables are represented by random number generators that return sample values from a representative distribution of possible values for each uncertain element in each experimental trial or replication of the model. A simulation run includes many hundreds or thousands of trials.

Our simulation model -- often called a risk model -- will calculate the impact of the uncertain variables and the decisions we make on outcomes that we care about, such as profit and loss, investment returns, environmental consequences, and the like. As part of our model design, we must choose how numerical values for the uncertain variables will be sampled on each trial. Simulation Methods Complex manufacturing and logistics systems often call for discrete event simulation, where there are "flows" of materials or parts, people, etc. through the system, and many steps or stages with complex interrelationships. Special simulation modeling languages are often used for these applications. But a great many situations -- including almost all of the examples above -- have been successfully handled with simulation models created in a spreadsheet using Microsoft Excel. This minimizes the learning curve, since you can apply your spreadsheet skills to create the model. Simple steps or stages, such as inventory levels in different periods, are easy to represent in columns of a spreadsheet model. You can solve a wide range of problems with Monte Carlo simulation of models created in Excel, or in a programming language such as Visual Basic, C++ or C#. Running a simulation generates a great deal of statistical data, that must be analyzed with appropriate tools. Professional simulation software, such as Frontline Systems' Risk Solver, allows you to easily create charts and graphs, a wide range of statistics and risk measures, perform sensitivity analysis and parameterized simulations, and use advanced methods for simulation optimization. Monte Carlo Simulation Monte Carlo simulation -- named after the city in Monaco famed for its casinos and games of chance -- is a powerful method for studying the behavior of a system, as expressed in a mathematical model on a computer. As the name implies, Monte Carlo methods rely on random sampling of values for uncertain variables, that are "plugged into" the simulation model and used to calculate outcomes of interest. With the aid of software, we can obtain statistics and view charts and graphs of the results. To learn more, consult our Monte Carlo simulation tutorial. Monte Carlo simulation is especially helpful when there are several different sources of uncertainty that interact to produce an outcome. For example, if we're dealing with uncertain market demand, competitors' pricing, and variable production and raw materials costs at the same time, it can be very difficult to estimate the impacts of these factors -- in combination -on Net Profit. Monte Carlo simulation can quickly analyze thousands of 'what-if' scenarios, often yielding surprising insights into what can go right, what can go wrong, and what we can do about it. Simulation Models A simulation model is a mathematical model that calculates the impact of uncertain inputs and decisions we make on outcomes that we care about, such as profit and loss, investment returns, environmental consequences, and the like. Such a model can be created by writing

code in a programming language, statements in a simulation modeling language, or formulas in a Microsoft Excel spreadsheet. Regardless of how it is expressed, a simulation model will include:

Model inputs that are uncertain numbers -- we'll call these uncertain variables Intermediate calculations as required Model outputs that depend on the inputs -- we'll call these uncertain functions

It's essential to realize that model outputs that depend on uncertain inputs are uncertain themselves -- hence we talk about uncertain variables and uncertain functions. When we perform a simulation with this model, we will test many different numeric values for the uncertain variables, and we'll obtain many different numeric values for the uncertain functions. We'll use statistics to analyze and summarize all the values for the uncertain functions (and, if we wish, the uncertain variables).

Creating Models in Excel or Custom Programs Choosing Samples for Uncertain Variables

Creating Models in Excel or Custom Programs An Excel spreadsheet can be a simple, yet powerful tool for creating your model -especially when paired with Monte Carlo simulation software such as Risk Solver. If your model is written in a programming language, Monte Carlo simulation toolkits like the one in Frontline's Solver Platform SDK provide powerful aids. An example model in Excel might look like this, where cell B6 contains a formula =PsiTriangular(E9,G9,F9) to sample values for the uncertain variable Unit Cost, and cell B10 contains a formula =PsiMean(B9) to obtain the mean value of Net Profit across all trials of the simulation.

A portion of an example model in the C# programming language might look like this, where the array Var[] receives sample values for the two uncertain variables X and Y, and the uncertain function values are computed and assigned to the Problem's FcnUncertain object Value property:

Choosing Samples for Uncertain Variables We must also choose what random sample values to use for the uncertain variables. During a simulation, a new sample value will be drawn for every uncertain variable on each trial. Risk Solver provides state-of-the-art random number generators and sampling methods for your simulation needs. In the simplest case, we might generate random numbers between 0 and 1, and use these as sample values. But in most cases, the range of values, and chance that different values in the range will be drawn on each trial, must be tailored to the uncertain variable. To do this, we normally choose a probability distribution and appropriate parameters for the uncertain variable. As discussed next, selecting appropriate probability distributions is a key step in building a simulation model. Probability Distributions for Simulation For experienced modelers, the most challenging task in creating a simulation model is usually not identifying the key inputs and outputs, but selecting an appropriate probability distribution and parameters to model the uncertainty of each input variable. For example, Risk Solver software provides over 40 probability distributions -- so which one should you use? The answer depends on your application, but some general guidelines can be given.

Discrete Vs. Continuous Distributions Bounded Vs. Unbounded Distributions Analytic Vs. Custom Distributions More Hints and Warnings

Discrete Vs. Continuous Distributions If you must choose or create your own distribution, the first step is to determine whether to use a discrete or continuous form.

If there are a small number of possible values for the uncertain variable, you may be able to use a discrete analytic distribution, or construct a discrete custom distribution. If the underlying physical process involves discrete, countable entities -such as the number of customers arriving at a service window -- you can use a discrete distribution. If the possible values are highly divisible -- such as most prices, volumes, interest rates, exchange rates, weights, distances, etc. -- you will likely use a continuous distribution. In some cases, you may use a continuous distribution to approximate a discrete distribution.

Bounded Vs. Unbounded Distributions Another characteristic that distinguishes probability distributions is the range of sample values they can generate.

Some distributions are intrinsically bounded -- samples are guaranteed to lie between a known minimum and maximum value. Examples are the Uniform, Triangular, Beta, and Binomial distributions. Other distributions are unbounded -- sample values may cluster around the distributions mean, but may sometimes have extreme negative or positive values. Examples are the Normal, Logistic, and Extreme Value distributions. Still other distributions are partially bounded, with a known minimum such as zero, but no maximum value. Examples are the Exponential, Poisson, and Weibull distributions.

At times, you may find that the most appropriate distribution (say the Normal) is unbounded, but you know that the realistic values of the physical process are bounded, or your model is designed to handle values only up to some realistic limit. Your software may allow you to truncate an unbounded distribution. For example, in Risk Solver you can impose bounds on any distribution by passing the PsiTruncate property function as an argument to the distribution function. Analytic Vs. Custom Distributions A third characteristic of probability distributions is whether they are analytic (also called parametric) or custom (sometimes called non-parametric) distributions.

An analytic distribution has a form derived from certain theoretical assumptions about the problem. For example, a Poisson distribution is derived from an assumption that events are independent and occur at a known average rate, and an Exponential distribution is derived from an assumption of a constant rate of decay in some process. A custom distribution has a form dictated by either past data or expert opinion about the range and frequency of sample values. Risk Solver software provides five general-purpose functions -- PsiCumul, PsiDiscrete, PsiDisUniform, PsiGeneral and PsiHistogram -- to help you model custom distributions.

Generally speaking, you should choose an analytic distribution if -- and only if -- the theoretical assumptions truly apply in your situation.

More Hints and Warnings Using a Triangular Distribution. If you only have estimates of the minimum, maximum, and most likely values of an uncertain variable -- and no other past data or literature references -- a popular approach is to create a Triangular distribution from these three numbers. This is unlikely to be a highly accurate representation of the uncertainty, but it will allow you to get started, and it is far better than a single average that is subject to the Flaw of Averages. If your minimum and maximum values are really low- and high-percentile estimates rather than the absolute lowest and highest values that can occur, consider using a 'generalized Triangular' distribution (PsiTriangGen in Risk Solver) instead. Define Each Uncertain Variable Only Once. Often, youll need to use the same uncertain variable in several different formulas in your model. A very common error is to enter the same distribution function, with the same parameters (say PsiNormal(100, 10) in Risk Solver), several times in a model -- in a belief that these instances will yield the same results on each trial. This is incorrect -- by doing this, youve actually defined several independent uncertain variables that may well sample different values on each trial. You should instead define =PsiNormal(100, 10) only once (for example in a cell such as A1), and use A1 in every formula where the uncertain variable is needed. Approaches to Choosing Probability Distributions As noted earlier, the most challenging task in creating a simulation model often involves selecting appropriate probability distributions (and associated parameters) to describe the behavior of each uncertain input variable. In some cases, you might have data on the past (historical) behavior of your uncertain input variables that can assist in this task; in other cases, you probably won't. Following are some suggestions for choosing probability distribution in each of these cases.

When Past Data is Available When Past Data is Not Available

When Past Data is Available If you have, or you can collect data on the past performance of the uncertain variable -- and if you believe that past performance is likely to be representative of future performance -- you have three options:

If you have a reasonably large number of observations of past performance of the variable, compared to the number of simulation trials you want to run, you can use the past data itself for simulation trials. This is sometimes called a trace-driven simulation. In Risk Solver, you can use past data in the form of a SIP (Stochastic Information Packet), and use the PsiSip() or PsiSlurp() distribution function for the uncertain variable. If -- as is often the case -- you have a relatively small number of observations of past performance compared to the number of trials you want to run, you may be better off resampling the past performance data. Instead of using all of the past observations (one per simulation trial), you randomly sample the past observations on each trial. In Risk Solver, you can place past data in a cell range or SIP, and use the

PsiDisUniform() function (single values) or the PsiResample() function (multiple values) for the uncertain variable. If you can fit the data (past observations) to a specific type of analytic distribution and its parameters, and if there is reason to believe that the underlying process that the uncertain variable is measuring is consistent with the assumptions from which the analytic distribution is derived, you can use this distribution (for example PsiNormal, PsiWeibull, etc.) for the variable. You can use Risk Solver to automatically find the best-fitting analytic distribution.

When Past Data is Not Available If you dont have, and you cannot easily collect data on the past performance of the uncertain variable -- or if past performance is not likely to be representative of future performance -you must tackle the problem in a different way:

Consult the literature for your industry, if available, to find examples of applications like yours where simulation models were built. Find out -- by contacting the authors if necessary -- what kinds of distributions were used for the uncertain variables, and the rationale for choosing them. If you cannot find reports on industry-specific applications like yours, consult the publications of professional societies like INFORMS, where simulation applications are reported. One rich source is the past proceedings of the Winter Simulation Conference (www.wintersim.org). The Risk Solver User Guide has a chapter PSI Function Reference, with descriptions of 40 different analytic and custom distribution functions, including brief comments on the types of applications where each distribution has been used in the past. To learn more about analytic distributions, consult textbooks such as Simulation Modeling and Analysis, 4th Ed. by Averill Law, Statistical Distributions, 3rd Ed. by Evans, Hastings and Peacock, Univariate Discrete Distributions, 3rd Ed. by Johnson, Kemp and Kotz, or Continuous Univariate Distributions, Vol. 1 & 2, 2nd Ed. by Johnson, Kotz and Balakrishnan.

You are well-advised to keep it simple! Many physical, social and biological phenomena are well described by the Normal distribution, or -- if the possible values are equally likely to occur, as in a coin flip or single die -- the Uniform distribution. Bear in mind that when any set of distributions are summed, the result (quickly) tends towards the Normal distribution. Applications that involve queuing -- customers arriving or departing, parts awaiting assembly, etc. -- have been well studied, so you can often find appropriate distributions in the literature. Applications that use the Project Evaluation and Review Technique (PERT) can often use the PsiPert() function in Risk Solver to model uncertainty. Analysis of Simulation Results In simulation, we create a mathematical model of a system or process, usually on a computer, and we explore the behavior of the model by running a simulation. A simulation consists of many -- often thousands of -- trials. Each trial is an experiment where we supply numerical values for input variables, evaluate the model to compute numerical values for outcomes of interest, and collect these values for later analysis.

Charts and Graphs Statistical Measures Sensitivity Analysis Parameterized Simulation

Charts and Graphs A simulation yields many possible values for the outcomes we care about -- from Net Profit to environmental impact. The role of simulation analysis is to summarize and analyze the results, in a way that will yield maximum insight and help with decision-making. It is very useful to create charts to help us visualize the results -- such as frequency charts and cumulative frequency charts.

Frequency Chart Statistical Measures

Cumulative Frequency Chart

Statistics often play a key role in summarizing the range of values for each outcome of interest in a simulation analysis. When the outcome is important to us, statistics come to life! A good simulation software package, such as Frontline's Risk Solver, provides a variety of statistics:

Measures of central tendency such as the mean, median and mode Measures of variation such as the variance or standard deviation, skewness, and kurtosis Risk measures such as mean absolute deviation, semivariance or lower partial moment, and semideviation Quantile measures such as percentiles, cumulative targets, Value at Risk, and Conditional Value at Risk Confidence intervals that tell us how close our computed sample mean or standard deviation is to the true value

It's important to look at quantile measures, such as percentiles and Value at Risk, in addition to measures of central tendency and variation. Quantile measures help you answer questions

such as How much money might we lose, with 5% or 10% probability? or What are the chances that well make at least $100,000? based on your simulation model. A simulation uses a sample of the possible values of your uncertain variables; hence any statistic resulting from the simulation involves some degree of sampling error. Confidence intervals help you assess this error, and estimate the range or interval in which you can be confident that the true statistic lies, at a confidence level that you specify. Sensitivity Analysis A powerful tool for assessing model results is sensitivity analysis, which can help us identify the uncertain inputs with the biggest impact on our key outcomes. For example, a tornado chart can give us a quick visual summary of the uncertainties with the greatest positive and negative impact on Net Profit. Using software, we can also run multiple simulations, with an input we choose taking a different value on each simulation, and assess the results. Analyzing the model can give us more information, but also insight about our real-world problem.

Tornado Chart Parameterized Simulation Another powerful method for simulation analysis is running a parameterized simulation. In this method, we run a series of simulations, where we vary the value of one or more variable(s) that we can control -- such as our offering price, our inventory restocking level, or our allocation of investment funds to different asset classes. Each simulation run tests a wide range of values for the uncertain variables in our model, collects results for our outcomes of interest, and produces summary statistics, charts and graphs. We can then compare the different simulations to each other, to better understand how varying the decision variable(s) affects our outcomes, in the presence of uncertainty. Simulation Optimization An even more powerful method for simulation analysis, beyond parameterized simulation, is to use simulation optimization to automatically find the best value of one or more variables that we can control. We can put the computer to work, in effect performing parameterized simulations for many different combinations of values for our decision variables, and seeking the best combination of values for criteria that we specify.

Frontline's Risk Solver Pro and Risk Solver Platform can both handle simulation optimization problems -- at speeds up to 100 times faster than other software!

How Simulation Optimization Works Defining a Simulation Optimization Model Solving a Simulation Optimization Model

How Simulation Optimization Works Optimization helps you make better choices when you have all the data, and simulation helps you understand the possible outcomes when you dont. Frontline Solvers enable you to combine these analytic methods, so you can make better choices for decisions you do control, taking into account the range of potential outcomes for factors you dont control. This method, called simulation optimization, helps you make better resource allocation choices here and now, in situations with uncertainty. You simply create a model that includes: 1. Decision variables for resources you do control, just as in a conventional optimization model 2. Uncertain variables for factors you dont control, just as in a Monte Carlo simulation model 3. An objective to maximize or minimize, that may depend on decision and uncertain variables 4. Constraints to satisfy, that may also depend on decision and uncertain variables A Solver using simulation optimization can search through thousands of ways to allocate resources and, for each one, through thousands of possible future outcomes, and seek the best set of choices. The solution gives you a much better picture of the decisions you should make, given what you know for sure and the range of outcomes for factors that you dont know for sure. Defining a Simulation Optimization Model Creating a simulation optimization model using Risk Solver Pro or Risk Solver Platform is straightforward. You follow these steps: 1. Define decision variable cells (such as A1), using either the Solver Parameters dialog or the PsiVar() function. These are factors that are under your control you (or the Solver) will decide what values they should have. 2. Define uncertain variable cells (such as A2), that contain formulas calling the PSI Distribution functions supplied by Risk Solver for example PsiUniform() and PsiNormal(). These are factors that are not under your control. 3. Build your model, using cell formulas that may depend on the decision variables, uncertain variables, or both. 4. Each cell (such as B1) containing a formula that depends on uncertain variables (say =A1+2*A2) represents thousands of trial values, generated during each Monte Carlo simulation by sampling different values for A2 and computing =A1+2*A2.

5. In other cells (such as C1), define the summary statistics you want, using functions such as PsiMean(B1) or PsiStdDev(B1). You may use formulas to compute further values based on these summary statistics. 6. Define your objective and constraints for optimization. These may be cell formulas that depend only on the decision variables, depend on the uncertain variables through PSI Statistics functions, or depend on both. Solving a Simulation Optimization Model Solving a simulation optimization model using Risk Solver Pro and Risk Solver Platform is also straightforward. Follow these steps: 1. Activate Interactive Simulation by clicking the light bulb button on the Risk Solver Ribbon. 2. On the Output tab of the Task Pane to the right of the Excel window click on the green arrow Solve button. Simulation optimization is a powerful, general framework for finding "best solutions," but it is computationally very expensive, and there are limits on the size and complexity of your model (number of decision variables, uncertain variables, constraints, and total formulas) if you want to find a solution in a reasonable amount of time. That said, Frontline Systems is already delivering the highest performance software for simulation optimization in Excel available today -- and we're continuing to take this capability much further to make it easier for you to make the best decisions in the least amount of time. Contact us if you'd like to learn more.