Ch. 1 Basic Simulation Modeling

Slides:



Advertisements
Similar presentations
Introduction into Simulation Basic Simulation Modeling.
Advertisements

Simulating Single server queuing models. Consider the following sequence of activities that each customer undergoes: 1.Customer arrives 2.Customer waits.
Modeling & Simulation. System Models and Simulation Framework for Modeling and Simulation The framework defines the entities and their Relationships that.
Statistics review of basic probability and statistics.
1 1 Slide STATISTICS FOR BUSINESS AND ECONOMICS Seventh Edition AndersonSweeneyWilliams Slides Prepared by John Loucks © 1999 ITP/South-Western College.
Chapter 15 Application of Computer Simulation and Modeling.
Chapter 3 Simulation Software
Discrete-Event Simulation: A First Course Steve Park and Larry Leemis College of William and Mary.
Chapter 6 Continuous Random Variables and Probability Distributions
Steps of a sound simulation study
Simulation.
1 Validation and Verification of Simulation Models.
4. Review of Basic Probability and Statistics
3-1 Introduction Experiment Random Random experiment.
Chapter 5 Continuous Random Variables and Probability Distributions
Inferences About Process Quality
Lab 01 Fundamentals SE 405 Discrete Event Simulation
Ch. 3 Simulation Software. Programming of discrete-event simulation models Generating random numbers, that is, observations from a U(0,1) probability.
(C) 2009 J. M. Garrido1 Object Oriented Simulation with Java.
Chapter 1 Introduction to Simulation
1 Performance Evaluation of Computer Networks: Part II Objectives r Simulation Modeling r Classification of Simulation Modeling r Discrete-Event Simulation.
 1  Outline  stages and topics in simulation  generation of random variates.
Verification & Validation
Modeling & Simulation: An Introduction Some slides in this presentation have been copyrighted to Dr. Amr Elmougy.
1 OM2, Supplementary Ch. D Simulation ©2010 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible.
Steps in simulation study 1. - Clearly understand problem - Reformulation of the problem 2. - Which questions should be answered? - Is simulation appropriate?
0 K. Salah 2. Review of Probability and Statistics Refs: Law & Kelton, Chapter 4.
Chapter 2 – Fundamental Simulation ConceptsSlide 1 of 46 Chapter 2 Fundamental Simulation Concepts.
Chap. 5 Building Valid, Credible, and Appropriately Detailed Simulation Models.
Chapter 10 Verification and Validation of Simulation Models
Building Simulation Model In this lecture, we are interested in whether a simulation model is accurate representation of the real system. We are interested.
Reid & Sanders, Operations Management © Wiley 2002 Simulation Analysis D SUPPLEMENT.
Learning Simio Chapter 10 Analyzing Input Data
OPERATING SYSTEMS CS 3530 Summer 2014 Systems and Models Chapter 03.
(C) J. M. Garrido1 Objects in a Simulation Model There are several objects in a simulation model The activate objects are instances of the classes that.
ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.
 Simulation enables the study of complex system.  Simulation is a good approach when analytic study of a system is not possible or very complex.  Informational,
MODELING AND SIMULATION CS 313 Simulation Examples 1.
Building Valid, Credible & Appropriately Detailed Simulation Models
Chapter 1 What is Simulation?. Fall 2001 IMSE643 Industrial Simulation What’s Simulation? Simulation – A broad collection of methods and applications.
Introduction To Modeling and Simulation 1. A simulation: A simulation is the imitation of the operation of real-world process or system over time. A Representation.
Traffic Simulation L2 – Introduction to simulation Ing. Ondřej Přibyl, Ph.D.
Simulation Modeling.
Chapter 6 The Normal Distribution and Other Continuous Distributions
Modeling and Simulation CS 313
Slides by JOHN LOUCKS St. Edward’s University.
OPERATING SYSTEMS CS 3502 Fall 2017
Chapter 1 The Systems Development Environment
Prepared by Lloyd R. Jaisingh
Sampling Distributions and Estimation
Modeling and Simulation (An Introduction)
Chapter 1 The Systems Development Environment
ADVANTAGES OF SIMULATION
Hypothesis Testing and Confidence Intervals (Part 1): Using the Standard Normal Lecture 8 Justin Kern October 10 and 12, 2017.
Simulation Department of Industrial Engineering Anadolu University
Chapter 1 The Systems Development Environment
Modeling and Simulation CS 313
Chapter 10 Verification and Validation of Simulation Models
Basic Simulation Modeling II
Prepared by Lee Revere and John Large
Onur Kaya END 201, Ext: 6439 ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2018 Chapter.
Simulation Modeling.
Simulation Software.
MECH 3550 : Simulation & Visualization
Building Valid, Credible, and Appropriately Detailed Simulation Models
MECH 3550 : Simulation & Visualization
DESIGN OF EXPERIMENTS by R. C. Baker
Chapter 1 The Systems Development Environment
Verification and Validation of Simulation Models
Chapter 5: Sampling Distributions
Presentation transcript:

Ch. 1 Basic Simulation Modeling

Basic Simulation Modeling The nature of simulation Systems, Models and Simulation Discrete-Event Simulation Simulation of a single-server queuing system Steps in a sound simulation study Advantages, disadvantages and pitfalls of simulation

The Nature of Simulation Conceptions Application areas Academic level Impediments

Conceptions Simulation course is about techniques for using computers to imitate or simulate the operations of various kinds of real world facilities or processes System: the facility or process of interest Model: a set of assumptions about how the system works, which usually take the form of mathematical or logical relationships, constitute a model that is used to try to gain more understanding of how the corresponding system behaves. Analytic soulution: to obtain exact information on questions of intresets. Simulation: use a computer to evaluate a model numerically, and data are gathered in order to estimate the desired true characteristics of the model.

Example a manufacturing company contemplates building a large extension onto one of its plants, but is not sure if the potential gain in productivity would justify the construction cost.

Application areas Designing and analyzing manufacturing systems evaluating military weapons systems or their logistics requirements determining hardware requirements or protocols for communication networks Determining hardware and software requirements for a computer system Designing and operating transportation systems such as airports, freeways, ports and subways Evaluating designs for service organizations such as call centers, fast-food restaurants, hospitals, and post offices Reengineering of business processes Determining ordering polices for an inventory system Analyzing financial or economic systems

Academic level Winter Simulation Conference (600-700 people every year) Is one of the three important operations-research techniques (in serveys related to the use of operations research techniques: math programming, statistics, simulation) The second only to “math programming” among 13 techniques considered (in 1294 papers from the journal Interfaces from 1970 through 1992)

Impediments Models used to study large-scale systems tend to be very complex, and writing computer programs to execute them can be an arduous task indeed. (excellent software products) Large amount of computer time is sometimes required. (cheaper and faster computer) An unfortunate impression that simulation is just an exercise in computer programming, albeit a complicated one. (attitude, simulation methodology)

Systems, Models and Simulation System is defined to be a collection of entities, e.g., people or machines, which act and interact together toward the accomplishment of some logical end. System depends on the objectives of a particular study. State of a system: collection of variables necessary to describe a system at a particular time, relative to the objectives of a study. (the number of busy tellers, the number of customers in the bank, the time of arrival of each customer in the bank) discrete system: the state variables change instantaneously at separated points in time. (a bank, e.g., the number of customers in the bank) continuous system: the state variables change continuously with respect to time. (an airplane moving through the air, e.g., position and velocity )

Continue... Study on a system: try to gain some insight into the relationships among various components, or to predict performance under some new conditions being considered. Ways to study a system

System Experiment with a model of the system Experiment with the actual system Physical model Mathematical model Analytical solution Simulation

Example One study on a bank to determine the number of tellers needed to provide adequate service for customers who want just to cash a check or make a savings deposite, the system can be defined to be that portion of the bank consisting of the tellers and the customers waiting in line or being served. If the loan officer and the safety deposite boxes are to be included, the definition of the system must be expanded in an obvious way.

Discrete Event Simulation Definition Time-Advance Mechanisms Components and Organization of a Discrete -Event Simulation Model Components Logic Organization

Definitions Discrete-event simulation concerns the modeling of a system as it evolves over time by a representation in which the state variables change instantaneously at separate points in time. Or the system can change at only a countable number of points in time. Event is defined as an instantaneous occurrence that may change the state of the system.

Example 1.1 Single-server queuing system: a barbershop, to estimate the (expected) average delay in queue (line) of arriving customers State variables: the status of the server (busy or idle), the number of customers waiting in queue to be served, the time of arrival of each person waiting in queue. Events: the arrival of a customer and the completion of service for a customer, which results in the customer’s departure.

Time-Advance Mechanism Simulation clock: the variable in a simulation model that gives the current value of simulated time. to keep track of the current value of simulated time as the simulation proceeds to advance simulated time from one value to another Advancing the simulation clock next-event time advance (mostly used) fixed-increment time advance (a special case of the first) Next-event time-advance approach simulation clock is initialized to zero the times of occurrence of future events are determined.

Example 1.2 Notations: : time of arrival of the ith customer () : interarrival time between (i-1)st and ith arrivals of customers : time that server actually spends serving ith customer (exclusive of customer’s delay in queue) : delay in queue of ith customer : time that ith customer completes service and departs : time of occurrence of ith event of any type (ith value the simulation clock takes on, excluding the value )

e0 e1 e2 e3 e4 e5 Time t1 t2 c1 t3 c2 A1 A2 A3 S1 S2

Components and Organization of a Discrete -Event Simulation Model Systems state: The collection of state variables necessary to describe the system at a particular time Simulation clock: A variable giving the current value of simulated time Event list: A list containing the next time when each type of event will occur Statistical counters: Variables used for storing statistical information about system performance

Continue... Initialization routine: A subprogram to initialize the simulation model at time 0 Timing routine: A subprogram that determines the next event from the event list and then advances the simulation clock to the time when that event is to occur Event routine: A subprogram that updates the system state when a particular type of event occurs (there is one event routine for each event type) Library routines: A set of subprograms used to generate random observations from probability distributions that were determined as part of the simulation model

Continue... Report generator: A subprogram that computes estimates (from the statistical counters) of the desired measures of performance and produces a report when the simulation ends Main program: A subprogram that invokes the timing routine to determine the next event and then transfers control to the corresponding event routine to update the system state appropriately. The main program may also check for termination and invoke the report generator when the simulation is over.

Start Initialization routine Main program Time routine 1. Set simulation clock=0 2. Initialize system state and statistical counters 3. Initialize event list 0. Invoke the initialization routine 1. Invoke the timing routine 2. Invoke event routine 1. Determine the next event type, say, i 2. Advance the simulation clock 1 Repeatedly i 2 Event routine i Library routines 1.Update system state 2.Update statistical counters 3.Generate future events and add to event list Generate random variates Is simulation over? No Report generator Yes 1. Compute estimates of interest 2. Write report Stop

Simulation of A Single-Server Queueing System

Components of a queueing system Arrival process: Interarrivals: Ai Mean interarrival time: E(A) Arrival rate: Service mechanism Service time: Si Number of servers: s Mean service time: E(S) Service rate: Queue discipline FIFO LIFO Priority * D. Gross, and C.M. Harris, Fundamentals of Queueing Theory, 3d ed., John Wiley, New York, 1998

Notation for queueing systems s servers in parallel and one FIFO queue feeding all servers A1, A2, are IID random variables S1, S2,…are IID random variables The Ai’s and Si’s are independent . . . 1 2 s FIGURE 1.71 A GI/G/s queue

GI/G/s queue GI (general independent): the distribution of the Ai’s G (general): the distribution of the Si’s Symbols: M (exponential), Ek (k-Erlang), D (deterministic times) M/M/1: a single-server queueing system with exponential interarrival and service times and a FIFO discipline : the utilization factor of the queueing system

A departure customer Server Customer in service Customers in queue An arrival customer FIGURE 1.4 A single-server queueing system.

Measures of Performance for Queueing Systems : delay in queue of ith customer : waiting time in system of ith customer : number of customers in queue at time t : number of customers in system at time t [Q(t) plus number of customers being served at time t] : steady-state average delay : steady-state average waiting time : steady-state time-average number in queue : steady-state time-average number in system

e1, e2, …, e13 : 13 successive events n=6 : delays in queue Interarrival times: A1=0.4, A2=1.2, A3=0.5, A4=1.7, A5=0.2, A6=1.6, A7=0.2, A8=1.4, A9=1.9, … Service times: S1=2.0, S2=0.7, S3=0.2, S4=1.1, S5=3.7, S6=0.6, …

Measures of Performance for the example : delay in queue of ith customer : the expected proportion of the time that Q(t) is equal to i : number of customers in queue at time t The expected average delay in queue The expected average number of customers in queue

Q(t) 3 2 1 1 2 3 4 5 6 7 8 9 t Arrivals Departures FIGURE 1.5 e1=0.4 e2=1.6 e8=4.0 e11=5.8 Arrivals e10=5.6 e12=7.2 e3=2.1 e7=3.8 e6=3.3 Departures e13=8.6=T(6) e4=2.4 e5=3.1 e9=4.9 FIGURE 1.5 Q(t), arrival times, and departure times for a realization of a single-server queueing system.

Measures of Performance for the example The expected utilization of the server

B(t) 1 1 2 3 4 5 6 7 8 9 t Arrivals Departures FIGURE 1.6 e1=0.4 e2=1.6 e8=4.0 e11=5.8 Arrivals e10=5.6 e12=7.2 e3=2.1 e7=3.8 e6=3.3 Departures e13=8.6=T(6) e4=2.4 e5=3.1 e9=4.9 FIGURE 1.6 B(t), arrival times, and departure times for a realization of a single-server queueing system.

Intuitive Explanation

Initialization time = 0 System state A 0.4 D Clock Event list Time of last event Sever status Number in queue Statistical counters Times of arrival Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (a)

Arrival time = 0.4 System state A 1.6 0.4 D 2.4 0.4 Clock Event list 1 0.4 Time of last event Sever status Number in queue Statistical counters Times of arrival 1 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (b)

Arrival time = 1.6 System state A 2.1 1.6 D 2.4 1.6 0.4 Clock Event list 1 1 1.6 Time of last event Sever status Number in queue Statistical counters 1.6 Times of arrival 1 1.2 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (c)

Arrival time = 2.1 System state A 3.8 2.1 D 2.4 1.6 0.4 Clock Event list 1 2 2.1 2.1 Time of last event Sever status Number in queue Statistical counters 1.6 Times of arrival 1 0.5 1.7 2.1 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (d)

Departure time = 2.4 System state A 3.8 2.4 D 3.1 2.1 1.6 Clock Event list 1 1 2.4 Time of last event Sever status Number in queue Statistical counters 2.1 Times of arrival 2 0.8 1.1 2.0 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (e)

Departure time = 3.1 System state A 3.8 3.1 D 3.3 2.1 Clock Event list 1 3.1 Time of last event Sever status Number in queue Statistical counters Times of arrival 3 1.8 1.8 2.7 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (f)

Departure time = 3.3 System state A 3.8 3.3 D Clock Event list 3.3 Time of last event Sever status Number in queue Statistical counters Times of arrival 3 1.8 1.8 2.9 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (g)

Arrival time = 3.8 System state A 4.0 3.8 D 4.9 3.8 Clock Event list 1 3.8 Time of last event Sever status Number in queue Statistical counters Times of arrival 4 1.8 1.8 2.9 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (h)

Departure time = 4.0 System state A 5.6 4.0 D 4.9 4.0 3.8 Clock Event list 1 1 4.0 Time of last event Sever status Number in queue Statistical counters 4.0 Times of arrival 4 1.8 1.8 3.1 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (i)

Departure time = 4.9 System state A 5.6 4.9 D 8.6 4.0 Clock Event list 1 4.9 Time of last event Sever status Number in queue Statistical counters Times of arrival 5 2.7 2.7 4.0 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (j)

Arrival time = 5.6 System state A 5.8 5.6 D 8.6 5.6 4.0 Clock Event list 1 1 5.6 Time of last event Sever status Number in queue Statistical counters 5.6 Times of arrival 5 2.7 2.7 4.7 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (k)

Arrival time = 5.8 System state A 7.2 5.8 D 8.6 5.6 4.0 Clock Event list 1 2 5.8 5.8 Time of last event Sever status Number in queue Statistical counters 5.6 Times of arrival 5 2.7 2.9 4.9 5.8 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (l)

Arrival time = 7.2 System state A 9.1 7.2 D 8.6 5.6 4.0 Clock Event list 1 3 5.8 7.2 7.2 Time of last event Sever status Number in queue Statistical counters 5.6 Times of arrival 5 2.7 5.7 6.3 5.8 Number delayed Total delay Area under Q(t) Area under B(t) 7.2 System Computer Representation (m)

Departure time = 8.6 System state A 9.1 8.6 D 9.2 5.8 5.6 Clock Event list 1 2 7.2 8.6 Time of last event Sever status Number in queue Statistical counters 5.8 Times of arrival 6 5.7 9.9 7.7 7.2 Number delayed Total delay Area under Q(t) Area under B(t) System Computer Representation (n)

Comments Interaction between the simulation clock and the event list Process updates of the state variables and statistical counters Contingencies A departing customer could leave behind an empty queue Termination conditions Time ties

1.4.3 Program Organization and Logic Why general-purpose language Model being simulated: M/M/1 queue n=1000 Interarrival and service times Interarrival: exponential distribution (mean=1 min) Service: exponential distribution (mean=0.5 min)

Arrival Event Schedule the next arrival event Is the server busy? Yes FIGURE 1.8 Flowchart for arrival routine, queueing model Schedule the next arrival event Is the server busy? Yes No Add 1 to the number in queue Set delay=0 for this customer and gather statistics Add 1 to the number of customers delayed Is the queue full? Write error message and stop simulation Yes No Make the server busy Store time of arrival of this customer Schedule a departure event for this customer Return

customer entering service Departure Event FIGURE 1.9 Flowchart for arrival routine, queueing model Is the queue empty? Yes No Make the server idle Subtract 1 from the number in queue Eliminate departure event from consideration Compute delay of customer entering service and gather statistics Add 1 to the number of customers delayed Schedule a departure event for this customer Move each customer in queue (if any) up one place Return

C Program for Queueing Model (Fig 1.19 – Fig. 1.27) External definitions Main functions Function initialize Function timing Function arrive Function departure Function report Function update_avg_stats Function expon

Simulation Output and Discussion (Fig. 1 Simulation Output and Discussion (Fig. 1.28 Output report, queueing model) Single-server queueing system Mean interarrival time 1.000 mins Mean service time 0.500 mins Number of customers 1000 Average delay in queue 0.430 mins Average number in queue 0.418 Server utilization 0.460 Time simulation ended 1027.915 mins

Alternative Stopping Rules (Fig. 1.33 –Fig. 1.37) Stop: fixed run time 480 mins External definitions Main functions Function initialize Function report Output report

Determining the Events and Variables Event-graph Arrival Departure FIGURE 1.38 Event graph, queueing model

Determining the Events and Variables Event-graph Arrival Enter service Departure FIGURE 1.39 Event graph, queueing model with separate “enter-service” event

Determining the Events and Variables Event-graph Arrival Departure End simulation FIGURE 1.40 Event graph, queueing model with fixed run length

STEPS IN A SOUND SIMULATION STUDY Formulate the problem and plan the study Problem of interest is stated by manager. One or more kickoff meeting for the study are conducted, with the project manager, the simulation analysts, and subject-matter experts (SMEs) in attendance. The following issues are discussed: Overall objectives of the study Specific questions to be answered by the study Performance measures that will be used to evaluate the effeciency of different system configurations Scope of the model System configurations to be modeled Software to be used Time frame for the study and the required resources

STEPS… 2. Collect data and define a model. Collect information on the system layout and operating procedures. No single person or document is sufficient. Some people may have inaccurate information---make sure that ture SMEs are identified. Operating procedures may not be formalized. Collect data (if possible) to specify model parameters and input probability distributions Delineate the above information and data in an “assumptions document,” which is the conceptual model Collect data (if possible) on the performance of the existing systsem (for validation purpose in Step 6) The level of model detail should depend on the following: Project objectives Performance measures Data availability Credibility concerns Computer constraints Opinions of SMEs Time and money constraints There need not be a one-to-one correspondence between each element of the model and the corresponding element of the system. Interact with the manager (and other key project personnel) on a regular basis

STEPS… 3. Is the conceptual model valid? Perform a structured walk-through of the conceptual model using the assumptions document before an audience of managers, analysts, and SMEs Helps ensure that the model’s assumptions are correct and complete Promotes ownership of the model Take place before programming begins to avoid significant reprogramming later 4. Construct a computer program and verify. Program the model in a programming language or in simulation software. Benefits of using a programming language are that one is often known, they have a low purchase cost, and they may result in a smaller model execution time. The use of simulation software, on the other hand, reduces programming time and results in a lower project cost. Verify (debug) the simulation computer program.

STEPS… 5. Make pilot runs. 6. Is the programed model valid? Make pilot runs for validation purposes in Step 6. 6. Is the programed model valid? If ther is an existing system, then compare model and system (from Step 2) performance measures for existing system Regardless of whether there is an existing system, the simulation analysts and SMEs should review the model results for correctness. Use sensitivity analyses to determine what model factors have a significant impact on performance measures and, thus, have to be modeled carefully. 7. Design experiments. Specify the following for each system configuration of interest: Length of each run Length of the warmup period, if one is appropriate Number of independent simulation runs using different random numbers---facilitates construction of confidence intervals

STEPS… 8. Make production runs. 9. Analyze output data. Production runs are made for use in Step 9. 9. Analyze output data. Two major objectives in analyzing output data are: Determining the absolute performance of certain system configurations Comparing alternative system configurations in a relative sense 10. Document, present, and use results. Document assumptions (see Step 2), computer program, and study’s results for use in the current and future projects. Present study’s results. Use animation to communicate model to managers and other people who are not familiar with all of the model details. Discuss model building and validation process to promote credibility. Results are used in decision-making process if they are both valid and credible.

Steps in a simulation study. Formulate problem and plan the study Collect data and define a model Conceptual model valid? No Yes Construct a computer program and verify Make pilot runs Programmed Model valid? No Yes Design experiments FIGURE 1.68 Steps in a simulation study. Make production runs Analyze output data Document, present, and use results

ADVANTAGES OF SIMULATION Most complex, real-world systems with stochastic elements cannot be accurately described by a mathematical model that can be evaluated analytically. Thus, a simulation is often the only type of investigation possible. Simulation allows one to estimate the performance of an existing system under some projected set of operating conditions. Alternative proposed system designs (or alternative operating policies for a single system) can be compared via simulation to see which best meets a specified requirement. In a simulation we can maintain much better control over experimental conditions than would generally be possible when experimenting with the system itself. Simulation allows us to study a system with a long time frame---e.g., an economic system---in compressed time, or alternatively to study the detailed workings of a system in expanded time.

DISADVANTAGES OF SIMULATION Each run of a stochastic simulation model produces only estimates of a model’s true characteristics for a particular set of input parameters. If a “valid” analytic model is available or can be easily de developed, it will generally be preferable to a simulation model. Simulation models are often expensive and time-consuming to develop. If a model is not a “valid” representation of a system under study, the simulation results, no matter how impressive they appear, will provide little useful information about the actual system. In some studies both simulation and analytic models might be useful. In particular, simulation can be used to check the validity of assumptions needed in an analytic mode. On the other hand, an analytic model can suggest reasonable alternatives to investigate in a simulation study.

Pitfalls to the successful completion of a simulation study Failure to have a well-defined set of objectives at the beginning of the simulation study Inappropriate level of model detail Failure to communicate with management throughout the course of the simulation study Misunderstanding of simulation by management Treating a simulation study as if it were primarily an exercise in computer programming Failure to have people with a knowledge of simulation methodology and statistics on the modeling team Failure to collect good system data Inappropriate simulation software Obliviously using simulation software products whose complex marco statement may not be well documented and may not implement the desired modeling logic

Pitfalls to the successful completion of a simulation study Belief that easy-to-use simulation packages, which require little or no programming, require a significantly lower level of technical competence Misuse of animation Failure to account correctly for sources of randomness in the actual system Using arbitrary distributions (e.g., normal, uniform, or trianglar) as input to the simualation Analyzing the output data from one simulation run (replication) using formulas that assume independence Making a single replication of a particular system design and treating the output statistics as the “true answers” Comparing alternative system design on the basis of one replication for each design Using the wrong performance measures

Notes In some studies both simulation and analytic models might be useful. In particular, simulation can be used to check the validity of assumptions needed in an analytic model. On the other hand, an analytic model can suggest reasonable alternatives to investigate in a simulation study.

Tarea 1: Simulation of a Single server queueing system Modify the code for the single-server queue in Chapter 1 to compute and write in addition the following measures of performance: The time-average number in the system The average total time in the system The maximum queue length The maximum delay in quque The maximum time in the system The proportion of customers having a delay in queue in excess of 1 minute Entegar: report on the simulation including simulation model description, design of the experiments, results of above measures after the simulation, conclusion on the simulation, and program code. Fecha limite: 18 de Febrero de 2005

Ch. 3 Simulation Software

Programming of discrete-event simulation models Generating random numbers, that is, observations from a U(0,1) probability distribution Generating random variates from a specified probability distribution (e.g., exponential) Advancing simulated time Determining the next event from the event list and passing control to the appropriate block of code Adding records to, or deleting records from, a list Collecting output statistics and reporting the results Detecting error conditions

Advantages of Using a Simulation Package Simulation packages automatically provide most of the features needed to build a simulation model, resulting in a significant decrease in “programming” time and a reduction in overall project cost. They provide a natural framework for simulation modeling. Their basic modeling constructs are more closely akin to simulation than are those in a general-purpose programming language like C. Simulation models are generally easier to modify and maintain when written in a simulation package. They provide better error detection because many potential types of errors are checked for automatically. Since fewer modeling constructs need to be included in a model, the chance of making an error will be probably smaller.

Advantages of Using General-Purpose Programming Language Most modelers already know a programming language, but this is often not the case with a simulation package. A simulation model efficiently written in C or C++ may require less execution time than a model developed in a simulation package. This is so because a simulation package is designed to address a wide variety of systems with one set of modeling constructs, whereas a C program can be more closely tailored to a particular application. This consideration has, however, become less important with the availability of inexpensive, high-speed PCs. Programming languages may allow greater programming flexibility than certain simulation packages. Software cost is generally lower, but total project cost may not be.

3.3 Classification of Simulation Software General-purpose Versus Application-Oriented Simulation Packages Modeling approaches Common Modeling Elements

3.3.1 General-purpose Versus Application-Oriented Simulation Packages Historically, simulation languages application-oriented simulators. Advances: simulation languages: employing graphical model-building approach such as icons, dialog boxes Simulators: allowing programming in certain model locations using an internal pseudo-language. Modify existing modeling constructs Create new constructs Recently, general-purpose simulation packages: Arena, Extend application-oriented simulation packages: Manufacturing, Communications Networks, Process Reengineering and Services, Health Care, Call Centers, Animation (standalone)

3.3.2 Modeling Approaches Event-scheduling approach Process approach Identify characteristic events Write a set of event routines Execute events (no simulated time passes during its execution) Process approach A process is a time-ordered sequence of interrelated events separated by intervals of time, which describes the entire experience of an “entity” as it flows through a “system”.

Process Approach x x x Entity arrives Entity begins service Entity completes service Time x x x Event “Event” Event Possible passage of time in queue Possible of time for serving of entity FIGURE 3.1 Process describing the flow of an entity through a system

Process Approach Routine customer Arrival event 1 Schedule an arrival event for the next customer entity 3 4 Is the server idle ? 2 No Place this customer entity in the queue Wait until selected for service Passage of simulation time Yes 5 Remove this customer entity from the queue 6 Make the server busy Departure event 7 Schedule a departure event for the next customer entity 9 Make the server idle 8 Wait until service is completed 10 Termination of this customer entity Return Passage of simulation time FIGURE 3.2 Prototype customer-process routine for a single-server queueing system.

3.3.3 Common Modeling Elements Type of system Entities Attributes Resources Queues Manufacturing Part Part number, due date Machines, workers Queues or buffers Communications Message Destination, message length Nodes, links Buffers Airport Airplane Flight number, weight Runways, gates Insurance agency Application, claim Name, policy number, amount Agents, clerks

3.4 Desirable Software Features General capabilities (including modeling flexibility and ease of use) Hardware and software considerations Animation Statistical features Customer support and documentation Output reports and plots

3.4.1 General capabilities modeling flexibility Ability to define and change attributes for entities and also global variables, and to use both in decision logic (e.g., if-then-else constructs) Ability to use mathematical expressions and mathematical functions (logarithms, exponentiation, etc.) Ability to create new modeling constructs and to modify existing ones, and to be able to use the new or modified modeling constructs in current and future models

3.4.1 General capabilities ease of use Graphical user interface Modeling constructs (e.g. icons or blocks) that are neither too “primitive” nor too “macro” Tabs in dialog boxes can help manage a large number of options Hierarchy allows a user to combine several basic modeling constructs into a new higher-level construct. (reuse) Debugging aids Follow a single entity through the model to see if it is processed correctly See the state of the model every time a particular event occurs (e.g., a machine breakdown) Set the value of certain attributes or variables to “force” an entity down a logical path that occurs with small probability

3.4.1 General capabilities ease of use Fast model execution speed User-friendly model “front ends” Run-time version Running new or existing scenarios for a model built by an internal or external consultant Sales tool for equipment suppliers or system integrators Training Import data from (and export data to) other applications (e.g., an Excel spreadsheet or a database) Automatically simulate different scenarios that iterate on some model parameter (e.g., the number of machines in a work station for a factory) Combined discrete-continuous simulation External routines Easily initialized in a nonempty and idle state The state of a simulation can be saved at the end of a run Cost From $500 to $50,000 Other costs: maintenance fees, upgrade fees, additional hardware and software, etc.

3.4.2 Hardware and Software Requirements Computer platforms: Windows based PCs, UNIX workstations, Apple computers Required RAM: 128Mb Operating systems: Windows 98, Windows NT, UNIX

3.4.3 Animation and Dynamic Graphics Uses of animation Communicating the essence of a simulation model (or simulation itself) to a manager or to other people who may not be aware of (or care about) the technical details of the model Debugging the simulation program Showing that a simulation model is not valid Suggesting improved operational procedures for a system (some things may not be apparent from looking at just the simulation’s numerical results) Training operational personnel Promoting communication among the project team

3.4.3 Animation and Dynamic Graphics Types of animations Concurrent animation Post-processed Desirable features for animation Default animation Library of standard icons Smooth movement of icons Control to speed up or slow down the animation Zoom and pan, named animation views Vector-based graphics (pictures are drawn with lines, arcs, and fills) rather than pixel-based graphics 3-D animation Import CAD drawings and clip art Dynamic graphics and statistics: clocks, dials, level meters, dynamically update a histograms, time plots, etc.

3.4.4 Statistical capabilities Good random number generator At least 100 different streams that can be assigned to different sources of randomness Same results on different executions Theoretical distributions Continuous: exponential, gamma, Weibull, lognormal, normal, uniform, triangular, beta Discrete: binomial, geometric, negative binomial, Poisson, discrete uniform Empirical distribution Independent replications (or runs) Each runs uses separate sets of different random numbers Each run uses the same initial conditions Each run resets the statistical counters

3.4.4 Statistical capabilities A statistically sound method available for constructing a confidence interval for a mean Warmup period Allow the user to specify what performance measures to collect output data on Optimization

3.4.5 Customer Support and Documentation Public and customized training at the client’s site Good technical support for questions (tel. help) Good documentation User’s guide or reference manual, numerous detailed examples, context-dependent online help, library of mini examples Detailed description of how each modeling construct works Free demo disk Free trail Newsletter, yearly user’s conference Regular updates of the software

3.4.6 Output Reports and Graphics Standard reports for the estimated performance measures Customize reports Histogram Time plot Database Correlation plot Export individual model output observations to other software packages for further analysis and display. (spreadsheets, databases, statistics packages, and graphical packages)

3.5 General-purpose Simulation Packages ARENA, Extend, MODSIM III,

3.6 Object-oriented Simulation Advantages : It promotes code reusability It helps manage complexity It makes model changes easier It facilitates large projects with several programmers. Disadvantages: Some O-O simulation packages may have a steep learning curve. One must do many projects and reuse objects to achieve its full benefits.

Ch.4 Review of Basic Probability and Statistics

simulation output data 4.1 Introduction Perform statistic analyses of the simulation output data Design the simulation experiments Probability and statistics Model a probabilistic system Generate random samples from the input distribution Choose the input probabilistic distribution Validate the simulation model

4.2 Random variables and their properties Experiment is a process whose outcome is not known with certainty. Sample space (S) is the set of all possible outcome of an experiment. Sample points are the outcomes themselves. Random variable (X, Y, Z) is a function that assigns a real number to each point in the sample space S. Values x, y, z

Examples flipping a coin S={H, T} tossing a die S={1,2,…,6} flipping two coins S={(H,H), (H,T), (T,H), (T,T)} X: the number of heads that occurs rolling a pair of dice S={(1,1), (1,2), …, (6,6)} X: the sum of the two dice

Distribution (cumulative) function : the probability associated with the event Properties: F(x) is nondecreasing [i.e., if ]. .

Discrete random variable A random variable X is said to be discrete if it can take on at most a countable number of values. The probability that X takes on the value Then Probability mass function on I=[a,b]

Examples p(x) x p(x) for the demand-size random variable X. 1 2 3 4 1 2 3 4 x p(x) 1/6 1/3 1/2 2/3 5/6 p(x) for the demand-size random variable X.

F(x) for the demand-size random variable X. 1 2 3 4 x F(x) 1/6 1/3 1/2 2/3 5/6 F(x) for the demand-size random variable X.

Continuous random variables A random variable is said to be continuous if there exists a nonnegative function f(x) such that for any set of real number B and f(x) is called the probability density function. for all

f(x) x Interpretation of the probability density function

Uniform random variable on the interval [0,1] , then

x F(x) 1 x f(x) 1 f(x) for a uniform random variable on [0,1] F(x) for a uniform random variable on [0,1] where

Exponential random variable F(x) x f(x) 1 x f(x) for an exponential random variable with mean F(x) for an exponential random variable with mean

Joint probability mass function If X and Y are discrete random variables, then let for all x, y where p(x,y) is called the joint probability mass function of X and Y. X and Y are independent if for all x, y where are the (marginal) probability mass functions of X and Y.

Example 4.9 Suppose that X and Y are jointly discrete random variables with Then for x=1,2 for y=2,3,4 Since For all x, y, the random variables X and Y are independent.

Joint probability density function The random variables X and Y are jointly continuous if there exists a nonnegative function f(x,y), such that for all sets of real numbers A and B, X and Y are independent if for all x and y where are the (marginal) probability density functions of X and Y, respectively.

Example 4.11 Suppose that X and Y are jointly continuous random variables with Then for for Since X and Y are not independent.

Mean or expected value The mean is one measure of central tendency in the sense that it is the center of gravity

Examples 4.12-4.13 For the demand-size random variable, the mean is given by For the uniform random variable, the mean is given by

Properties of means 1. 2. Even if the ‘s are dependent.

Median The median of the random variable is defined to be the smallest value of x such that x area=0.5 The median for a continuous random variable

Example 4.14 1. Consider a discrete random variable X that takes on each of the values, 1, 2, 3, 4, and 5 with probability 0.2. Clearly, the mean And the median of X are 3. 2. Now consider random variable Y that takes on each of the values, 1, 2, 3, 4, and 100 with probability 0.2. The mean and the median of X are 22 and 3, respectively. Note that the median is insensitive to this change in the distribution. The median may be a better measure of central tendency than the mean.

Variance For the demand-size random variable, For the uniform random variable on [0,1],

large small Density functions for continuous random variables with large and small variances.

Properties of the variance 1. 2. 3. if the ‘s are independent (or uncorrelated).

Standard deviation The probability that is between and is 0.95.

Covariance The covariance between the random variables and is a measure of their dependence. if i=j,

Example 4.17 For the jointly continuous random variables X and Y in Example 4.11

If and are independent random variables and are uncorrelated. Generally, the converse is not true.

Correlated If , then and are said to be positively correlated. and tend to occur together and tend to occur together If , then and are said to be negatively correlated. and tend to occur together and tend to occur together

Correlation If is close to +1, then and are highly positively correlated. If is close to -1, then and are highly negatively correlated. For the random variable in Example 4.11

4.3 Simulation output data and stochastic processes Stochastic process is a collection of "similar" random variables ordered over time, which are all defined on a common sample space. State space is the set of all possible values that these random variables can take on. Discrete-time stochastic process: Continuous-time stochastic process:

Example 4.19 M/M/1 queue with IID interarrival times IID service times FIFO service Define the discrete-time stochastic process of delays in queue and are positively correlated. simulation input random variables output stochastic process The state space: the set of nonnegative real numbers

Example 4.20 For the queueing system of Example 4.19, Let be the number of customers in the queue at time t . Then is a continuous-time stochastic process with state space

Covariance-stationary Assumptions about the stochastic process are necessary to draw inferences in practice. A discrete-time stochastic process is said to be covariance-stationary, if and is independent of i for

Covariance-stationary process For a covariance-stationary process, the mean and variance are stationary over time, and the covariance between two observations and depends only on the separation j and not actual time value i and i+j. We denote the covariance and correlation between and by and respectively, where

Example 4.22 Consider the output process for a covariance-stationary M/M/1 queue with .

Warmup period In general, output processes for queueing systems are positively correlated. If is a stochastic process beginning at time 0 in a simulation, then it is quite likely not to be covariance-stationary. However, for some simulation will be approximately covariance-stationary if k is large enough, where k is the length of the warmup period.

4.4 Estimation of means, variance, and correlations Suppose are IID random variables with finite population mean and finite population variance Unbiased estimators: Sample mean Sample variance

How close is to ?

How close is to to construct a confidence interval Unbiased estimator

Density function for Density function for n large n small Distributions of for small and large n.

Estimate the variance of the sample mean . ´s are independent ´s are uncorrelated However, the simulation output data are almost always correlated. are from a covariance-stationary stochastic process, Then, is an unbiased estimator of , however, is no longer an unbiased estimator of . Since

However, simulation output data are always correlated. Since (1) For a covariance-stationary process: (2)

If one estimates from (correct in the IID case) there are two errors: the bias in as an estimator of . the negligence of the correlation terms in Eq. (2). Solution: combine Eq. (1) and Eq. (2) (3) If , then and .

Example 4.24 from the process of delays for a covariance-stationary M/M/1 queue with . Eq.(1) and (3) Thus, is a gross underestimate of , and we are likely to be overly optimistic about the closeness of to

Estimate . In general "good" estimates of the 's will be difficult to obtain unless n is very large and j is small relative to n.

4.5.1 Confidence Intervals

4.5.1 Confidence Intervals Central Limit Theorem: as , where , the distribution function of a normal random variable with and , is given by If n is "sufficiently large", the random variable will be approximately distributed as a standard normal random variable, regardless of the underlying distribution of the 's. For large n, the sample mean is approximately distributed as a normal random variable with mean and variance

where ( ) is the upper critical point for a standard normal random variable.

f(x ) Shaded area = a - 1 2 / z x If n is sufficiently large, an approximate percent confidence interval for is given by

Interpretation I: If one constructs a very large number of independent percent confidence intervals, each based on n observations, where n is sufficiently large, the proportion of these confidence intervals that contains (cover) should be . Interpretation II: If the 's are normal random variables, the random variable has a t distribution with n-1 degree of freedom (df), and an exact (for any ) percent confidence interval for is given by Where is the upper critical point for the t distribution with n-1 df

Standard normal distribution f(x) t distribution with 4df x Figure 4.16 Density function for the t distribution with 4df and for the standard normal distribution.

Example 4.26 10 observations: 1.20, 1.50, 1.68, 1.89, 0.95, 1.49, 1.58, 1.55, 0.50, 1.09 are from a normal distribution, To construct a 90% confidence interval for .

Table 4.1 Estimated coverages based on 500 experiments Distribution Skewness v n=5 n=10 n=20 n=40 Normal 0.00 0.910 0.902 0.898 0.900 Exponential 2.00 0.854 0.878 0.870 0.890 Chi Square 2.83 0.810 0.830 0.848 Lognormal 6.18 0.758 0.768 0.842 0.852 Hyperexponential 6.43 0.584 0.586 0.682 0.774

4.5.2 Hypothesis tests for the mean : If is large, is not likely to be true. If is true, the statistic will have a t distribution with n-1 df.

Example 4.27 For Example 4.26, To test the null hypothesis that at level . We reject .

4.6 The Strong Law of Large Numbers Theorem 4.2

Example 4.29

Tarea II: Teoría de la probabilitad y estatística A.M. Law and W.D. Kelton, Simulation, Modeling and Analysis, 3rd edition, pp. 261-263. Problems 4.1, 4.2, 4.4, 4.7, 4.9, 4.10, 4.13, 4.20, 4.21, 4.23, 4.24, 4.25, 4.26

Chap. 5 Building Valid, Credible, and Appropriately Detailed Simulation Models

5.1 Introduction and Definitions (1) Verification is concerned with determining whether the conceptual simulation model (model assumptions) has been correctly translated into a computer program, i.e., debugging the simulation computer program.

5.1 Introduction and Definitions(2) OJ '. I 5.1 Introduction and Definitions(2) Validation is the process of determining whether a simulation model (as opposed to the computer program) is an accurate representation of the system, for the particular objectives of the study.

Validation A valid model can be used to make decisions. A validation process depends on the complexity of the system and on whether a version of the system currently exists. A model can only be an approximation. A model is valid for one purpose. The measures of performance used to validate the model should include those that the decision maker will actually use for evaluating system design.

5.1 Introduction and Definitions(3) A simulation model and its results have credibility if the manager and other project personnel accept them as "correct“. A credible model is not necessarily valid, and vice versa.

Establish credibility Validation Verification Validation Establish credibility Establish credibility Simulation program “Correct” results available Results used in decision- making process System Conceptual model Analysis and data 1, 2, 3 Programming 4 Make model runs 5,6,7,8,9 Sell results to management 10 Figure 5.1 Timing and relationships of validation, verification, and establishing credibility

5.2 Guidelines for Determining the Level of Model Detail (1) Carefully define the specific issues to be investigated by the study and the measures of performance that will be used for evaluation. The entity moving through the simulation model does not always have to be the same as the entity moving through the corresponding system. Use subject-matter experts (SMEs) and sensitivity analyses. “Moderately detailed“ model. Regular interaction.

5.2 Guidelines for Determining the Level of Model Detail (2) Do not have more detail in the model than is necessary to address the issues of interest, subject to the proviso that the model must have enough detail to be credible. The level of model detail should be consistent with the type of data available. In all simulation studies, time and money constraints are a major factor in determining the amount of model detail. If the number of factors (aspects of interest) for the study is large, then use a "coarse" simulation model or analytic model to identify what factors have a significant impact on system performance.

5.3 Verification of Simulation Computer Program Tech 1: Write and debug the computer program on modules or subprograms. Tech 2: More than one person review the computer program (structured walk­ through of the program). Tech 3: Run the simulation under a variety of settings of input parameters, and check to see that the output is reasonable. Tech 4: "trace", interactive debugger. Tech 5: The model should be run under simplifying assumptions for which its true characteristics are known or can easily be computed. Tech 6: Observe an animation of the simulation output. Tech 7: Compute the sample mean and variance for each simulation input probability distribution, and compare them with the desired mean and variance. Tech 8: Use a commercial simulation package to reduce the amount of programming required.

5.4 Techniques for Increasing Model Validity and Credibility (1) Collect high-quality information and data on the system Conversation with subject matter experts in MS, machine operators, engineers, maintenance personnel, schedulers, managers, vendors, … Observation of the system Data are not representative of what one really wants to model Data are not of the appropriate type or format Data may contain measurement, recording, or rounding errors Data may be biased because of self interest Data may be inconsistent Existing theory IID exponential random variables Relevant results from similar simulation study Experience and intuition of the modelers

5.4 Techniques for Increasing Model Validity and Credibility (2) Interact with the manager on a regular basis There may not be a clear idea of the problem to be solved at initiation of the study. The manager’s interest and involvement in the study are maintained. The manager’s knowledge of the system contributes to the actual validity of the model The model is credible since the manager understands and accepts the model’s assumptions. Maintain an assumptions document and perform a structured walk-through Validate components of the model by using quantitative techniques. Validate the output from the overall simulation model Animation

5.5. Management's Role in the Simulation Process Formulating problem objectives. Directing personnel to provide informationand data to the simulation modeler and to attend the structured walk-through. Interacting with the simulation modeler on a regular basis. Using the simulation results as an aid in the decision-making process.

5.6 Statistical Procedures for Comparing Real-world Observations and Simulation Output Data Inspection approach. Confidence-interval approach based on independent data. Time-series approach

5.6.1 Inspection Approach Statistics: sample mean, sample variance, the sample correlation function, histograms. dangerous! for sample size 1. Correlated inspection approach

Table 5.4 Results for three experiments with the inspection approach Experiment 1 0.90 0.70 0.20 2 0.71 -0.01 3 1.08 0.35 0.73

Historical system input data Historical system input data Actual system Simulation model System output data Compare Model output data Figure 5.2 The correlated inspection approach

Table 5.5 Results for the first 10 of 500 experiments with the correlated and basic Inspection approaches, and a summary for all 500 Experiment j 1 3.06 3.81 2.62 -0.75 0.44 2 2.79 3.37 2.05 -0.58 0.74 3 2.21 2.61 4.56 -0.40 -2.35 4 2.54 3.59 1.86 -1.05 0.68 5 9.27 11.02 2.41 -1.75 6.86 6 3.09 3.75 1.85 -0.66 1.24 7 2.50 2.84 1.13 -0.34 1.37 8 0.31 0.71 3.12 -2.81 9 3.17 3.94 5.09 -0.77 -1.92 10 0.98 1.18 1.25 -0.20 -0.27 Sample mean of all 500 2.10 2.85 2.70 -0.60 Sample variance 2.02 2.28 2.12 0.08 4.08

5.6.2 Confidence-Interval Approach based on Independent Data Condition: it is possible to collect a potentially large amount of data for both the model and the system.