Recent Developments in Simulation Modeling and Analysis James R. Wilson Department of Industrial Engineering North Carolina State University Raleigh, NC 27695-7906 <www.ie.ncsu.edu/jwilson> 1 Overview • • • • • • • • Introduction to Simulation Fundamental Simulation Concepts Simple Applications Modeling and Generating Inputs Designing and Analyzing Experiments Steps in a Successful Simulation Study An Interesting Recent Application Wrap-Up / Q&A 2 Introduction • Simulation is no longer the “method of last resort” in OR/MS/IE studies. – A 1978 survey of M.S.O.R. graduates of Case Western Reserve ranked simulation 5th in value after graduation. – Longitudinal study of corporate practice (1983, 1989, 1993) ranked simulation 2nd following statistical analysis. 3 Basic Simulation Objectives • We use simulation to: – Describe and analyze the behavior of a complex system, – Ask “what if” questions about the system, and – Aid in the design or improvement of the system. • The system could be existing or conceptual. 4 Fundamental Simulation Concepts • Simulation: building a mathematical-logical model of a system and experimenting with it on a computer. • In a discrete-event simulation, variables defining system status are constant between event times at which they may jump to reflect changes in the system. 5 • In a process-interaction simulation, entities (traffic units, customers, parts) flow through a queueing network, contending for service at the workstations in the network. • In a continuous simulation, system status variables change continuously over time according to a differential or difference equation or an explicit function of time. 6 • In a combined discrete-continuous simulation, system status variables may make jumps at event times but are constant or changing continuously between those event times. 7 Reasons to Simulate • To see if a new proposed system can meet design requirements; • To redesign an old system to meet new requirements; • To resolve disputes about system operation; • To solve urgent problems (e.g., bottlenecks); • To sell a new idea; and • To create a system specification or action plan. 8 Key Simulation Application Areas • Manufacturing—material handling, scheduling, inventory control, staffing • Supply chain management • Service industries—banks, restaurants, theme parks • Health care—emergency, operating rooms 9 Application Areas (Cont’d) • Computer/communications systems • Military operations—war games, logistical support, command and control • Governmental operations—operation of court, prison, and probation/parole systems 10 Simple Simulation Examples • A single-server queue at a fast-food restaurant – Customers arrive randomly, wait for service first-come-first-served – Constant service rate when server is busy – Want to estimate server utilization, avg. queue length, avg. waiting time for food 11 A Discrete-Event Model of Restaurant 12 13 A Process-Interaction Model of Restaurant 14 15 16 Combined Discrete-Continuous Model • Consider a refinery that is fed from storage tanks that are supplied by ocean-going tankers. Storage Tank Waiting Tankers 17 Discrete-Change System State Variables • Number of Tankers Waiting 18 Continuous-Change System State Variables • Crude Oil Level in the Storage Tank 19 Modeling and Generating Probabilistic Simulation Inputs • Methods for generating random numbers— that is, random samples from the uniform distribution on the unit interval [0, 1]; • Methods for generating nonuniform random variables; • Methods for selecting input models. 20 Generating Random Numbers • Multiplicative-congruential generator (MCG): Generate “random” integers {Zi : i = 1, 2, … } in the range 0, 1, …, m–1, starting with the seed Z0 via Zi = a * Zi–1 ( mod m ) for i = 1, 2, …, with multiplier a = 16,807 and modulus m = 231–1 = 2,147,483,647. The associated “random” numbers {Ui } are Ui = Zi / m for i = 1, 2, … . • Used in many popular simulation languages; has cycle length m–1 = 2,147,483,646 ≈ 2.1 * 109. 21 Generating Random Numbers (Cont’d) • A combined multiple recursive generator (CMRG) Starting with seeds X0, X–1, X–2, Y0, Y–1, Y–2, operate two MCGs in parallel, Xi = ( 1403580*Xi–2 – 810728*Xi–3 ) ( mod 4294967087 ) Yi = ( 527612*Yi–2 – 1370589*Yi–3 ) ( mod 4294944443 ); and then combine these streams of “random” integers via Zi = ( Xi – Yi ) ( mod 4294967087 ) for i = 1, 2, … . The associated “random” numbers {Ui } are Ui = Zi / 4294967088, if Zi > 0; and Ui = 4294967087 / 4294967088, if Zi = 0. 22 Generating Random Numbers (Cont’d) • See L’Ecuyer et al. (Operations Research, 2002). • This CMRG has cycle length ≈ 3.1 * 1057. • Run time per random number is only slightly greater than the standard MCG. • Even under Moore’s law (computers double in speed every 1.5 years), this CMRG would require require 219 years to cycle on leading-edge PCs. • Used in Arena 5.0; see Kelton et al., Simulation with Arena (2002). 23 Generating Nonuniform Random Variables • • • • • • Inverse Transform Method Acceptance/Rejection Method Composition Method Convolution Method Alias Method Special Properties Focus on these (continuous rv) 24 Inverse Transform Method • Continuous Case (similar for discrete, mixed random variables): – Random variable X has cumulative distribution function (cdf) F(x) = Pr{X ≤ x} that is increasing for all real x. cdf) F(x) = Pr{X ≤ x} that is increasing for all real x. df) F(x) = Pr{X ≤ x} that is increasing for all real x. f) F(x) = Pr{X ≤ x} that is increasing for all real x. ) F(x) = Pr{X ≤ x} that is increasing for all real x. F(x) = Pr{X ≤ x} that is increasing for all real x. x0 F(x) = Pr{X ≤ x} that is increasing for all real x. (x) = Pr{X ≤ x} that is increasing for all real x. real x. rate U ~ Uniform(0, 1) using the random-number generator. F(X) = U for X and return the solution as the sampled X ampled mpled XX 25 Example of Inverse Transform • Weibull(α, β) distribution with parameters α > 0 and β > 0 • Probability density function (pdf) is αβ −α xα −1e −( x / β ) f ( x) = 0 α otherwise 1 − e −( x / β ) F ( x) = ∫ f (t )dt = −∞ 0 x • Cdf is if x > 0 α if x > 0 otherwise • Solve U = F(X) for X: U = 1− e − ( X / β )α ⇒ X = β [ − ln(1 − U ) ] 1/ α 26 Example of Inverse Transform (Cont’d) • Algorithm: 1. Generate U ~ Uniform(0, 1) 1/ α 2. Return X = β ( − ln(1 − U ) ) • Weibull(α = 1.5, β = 6) example 27 ⇒ 28 Acceptance-Rejection Method • Generally used when speed is an issue and the cdf is analytically and numerically intractable. • Goal: Generate X with pdf f(x). Specify a function t(x) that majorizes f(x), i.e., t(x) ≥ f(x) for all x t (x ) f (x ) x ∞ ∞ −∞ −∞ • Then t(x) ≥ 0 for all x, but C ≡ ∫ t ( x) dx ≥ ∫ f ( x) dx = 1. • If C is finite, then r(x) = t(x)/C is a pdf. 29 Acceptance-Rejection Method (Cont’d) • Acceptance-Rejection Algorithm: 1. Generate Y having pdf r(·). 2. Generate U ~ Uniform(0, 1) (independent of Y in Step 1). 3. If U ≤ f(Y)/t(Y), return X ← Y and stop; else go to Step 1. • Since Pr{Y ∈ [x, x+∆x] } ≈ r(x) ∆x and Y ∈ [x, x+∆x] } ≈ f(x)/t(x) , we see that f(Y)/t(Y) } ≈ r(x)∆x f(x)/t(x) ∝ f(x) ∆x, f(x) must be∆x, able to generate Y ~ r(·) easily. 30 Acceptance-Rejection Method (Cont’d) • Beta(4,3) distribution, density is f(x) = 60 x3 (1 – x)2 for 0 ≤ x ≤ 1. • Peak of density is f(0.6) = 2.0736 (exactly), so let t(x) = 2.0736 for 0 ≤ x ≤ 1. • Thus, c = 2.0736, and r(x) is the Uniform(0, 1) pdf. 31 Acceptance-Rejection Method (Cont’d) • Algorithm: 1. Generate Y ~ Uniform(0,1) 2. Generate U ~ Uniform(0,1) independent of Y 3. If U ≤ 60 Y3 (1 – Y)2 / 2.0736, return X ← Y and stop; else go to step 1. • On each iteration of step 3, Pr(acceptance) = 1/2.0736 = 0.48. 32 Intuitive Basis for Acceptance-Rejection Method 33 A Fatal Variate-Generation Scheme • Box-Müller acceptance-rejection method for generating pairs of normal random variables is widely used but does not work well with some MCGs. • Scatter plots of pairs of normal variates should show points symmetrically distributed about the origin since bivariate normal pdf is bell-shaped. 34 35 36 Selecting Valid Input Models • Selecting a valid input model can be difficult. – Availability of data: “feast or famine” syndrome. – Many data sets arising in simulation studies cannot be adequately modeled by standard pdfs. • Good input-modeling packages are available; see <www.informs-cs.org/wscpapers.html>. • For a state-of-the-art review, see Barton et al. in Proceedings of the 2002 Winter Simulation Conference. Slides available via <www.ie.ncsu.edu/jwilson>. 37 Designing & Analyzing Simulation Experiments • Analyzing simulation output is difficult. Consider consecutive customer waiting times. – Not normally distributed – usually skewed; – Not identically distributed – may have transients or cyclic effects (e.g., warm-up or time-of-day effects); and – Not independent – usually correlated. • Can’t analyze via “usual” statistical methods. 38 Designing & Analyzing Simulation Experiments (Cont’d) • Two general cases to consider – Terminating Simulations • Interested in short-term behavior • Example: Avg. customer waiting time in a bank over the course of a day – Steady-State Simulations • Interested in long-term behavior • Example: Continuously running assembly line 39 Analyzing Terminating Simulations • Method of Independent Replications – Make independent runs (replications) of the simulation, each under identical conditions. – The sample means from each replication are assumed to be approximately i.i.d. normal. – Use classical statistical techniques on the sample means (not the original observations). – For handling nonnormal data, see Chapter 6 in Computer Performance Modeling Handbook (Lavenberg 1983). 40 Analyzing Steady-State Simulations • First deal with initialization (warm-up) bias. – Usually we must “warm up” the simulation before collecting data. – Failure to do so can ruin the statistical analysis. • Many methods for dealing with steady-state data – – – – Batch Means, Spectral Analysis, Standardized Time Series, and Regenerative Analysis. 41 Analyzing Steady-State Simulations (Cont’d) • Method of Batch Means – Make one long run (vs. many shorter runs). – Warm up simulation before collecting data. – Divide remaining observations into adjacent batches of equal size. – Assume the sample means from each batch are approximately i.i.d. normal. – Use classical statistical techniques on the batch means (not on the original observations). 42 Method of Batch Means • Getting a confidence interval (CI) for the mean of a highly correlated autoregressive process: – CIs via classical statistics (“CLT” method on next page) result in severe undercoverage. – Look at batch means vs. CLT. – For recent extensions of batch means that promise to provide much more reliable CIs in practice, see • Steiger and Wilson, Management Science (2002). • Steiger et al., Proceedings of the 2002 Winter Simulation Conference. Available via <www.informs-cs.org>. 43 44 Key Steps in a Successful Simulation Study • • • • • • Formulate the problem. Specify the system and the simulation objectives. Formulate and build the simulation model. Verify (debug) the simulation model. Validate the simulation model. Design, perform, and analyze experiments with the simulation model. • Present recommendations and document the results. • Implement recommendations, disseminate model. 45 An Interesting Recent Application • Since 1995, United Network for Organ Sharing (UNOS) has sponsored a series of simulation models for evaluation of organ-allocation policies in terms of – Equity (fairness, justice); – Medical Utility (efficiency); and – Availability of organs for transplantation. • ULAM (UNOS Liver Allocation Model) was the first such simulation model; see Pritsker, OR/MS Today (1998). 46 ULAM Architecture 47 ULAM Animation 48 ULAM Animation (Cont’d) 49 Wrap-Up / Q&A • No longer the “method of last resort,” simulation is now one of the most popular and effective tools for studying complex systems. • For state-of-the-art simulation work, see the Proceedings of the Winter Simulation Conference online at <www.informs-cs.org/wscpapers.html>. • Questions? • Have a great conference! 50