Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS433 Modeling and Simulation Lecture 09 – Part 02 Discrete Events Simulation Dr. Anis Koubâa 27 Dec 2008 Al-Imam.

Similar presentations


Presentation on theme: "CS433 Modeling and Simulation Lecture 09 – Part 02 Discrete Events Simulation Dr. Anis Koubâa 27 Dec 2008 Al-Imam."— Presentation transcript:

1 CS433 Modeling and Simulation Lecture 09 – Part 02 Discrete Events Simulation Dr. Anis Koubâa http://10.2.230.10:4040/akoubaa/cs433/ 27 Dec 2008 Al-Imam Mohammad Ibn Saud University

2  Basic Concepts of Simulation  Why using simulations?  Advantages and drawback of simulations  Types of simulations  Steps in a simulation study  Discrete Event Simulation (DES) Outline

3  Simulation: It is a numerical technique for conducting experiments with certain types of mathematical models describing the behavior of complex systems on a digital computer over extended periods of time (Naylor 1971)  In a Simulation, a computer is used to evaluate a model numerically, and then gather data in order to estimate the desired characteristics of the model.  Example: A manufacturing firm that is thinking to build a large extension onto one of its plants.  Question: Will the potential gain in productivity justify the construction cost?  Problem: It would not be cost effective to build the extension and then remove it later if it does not work out.  Solution: Simulation! Basic Concepts

4  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, organizational, and environmental changes can be simulated.  The knowledge gained in designing a simulation model may be of great value toward suggesting improvement in the system under investigation.  Simulation can be used to experiment with new designs or policies prior to implementation (what if scenarios).  Experiments can be very expensive, dangerous …  The modern system is so complex that the interactions can be treated only through simulation. When and Why to use Simulations?

5  when the problem can be solved using common sense  when the problem can be solved analytically  when it is easier to perform direct experiments  when the costs exceed the savings  when the resources or time are not available  when the ability to verify and validate the model is very limited  when the system behavior is too complex or cannot be defined When Simulation Cannot be Used?

6 Application Areas of Simulation

7 Advantages/Drawbacks of Simulation Advantages  Advantages  Adequate for assessing models too complicated for analytical or numerical study;  New policies, decision rules, etc., can be explored without disrupting ongoing operations of the real system;  “What if” scenarios can be analyzed which are useful in the design of new systems.  Drawbacks  Sometimes very time consuming/costly;  To analyze a certain problem, better methods than simulation may exist;  Simulations provide “random output” (lots of misinterpretation possible).

8 Types of Simulation  Static vs. Dynamic  Does time have a role in the model?  Continuous-change vs. Discrete-change  Can the “state” change continuously or only at discrete points in time?  Deterministic vs. Stochastic  Is everything for sure or is there uncertainty?  Most operational models  Dynamic, Discrete-change, Stochastic

9 Types of Simulation

10 Concepts in Discrete Event Simulation

11 Steps of a Simulation Study

12 Steps in Simulation Study 1- Problem formulation: Every study should begin with a statement of the problem 2- Setting of objectives and overall project plan: The objectives indicate the questions to be answered by simulation. 3- Model conceptualization: The construction of a model of a system is probably as much art as science 4- Data collection: There is a constant interplay between the construction of the model and the collection of the needed input data [Shannon, 1975]. As the complexity of the model changes, the required data elements may also change

13 Steps in Simulation Study 5- Model translation: the model must be entered into a computer-recognizable format. 6- Verification: Is the computer program performing properly? 7- Validation: Does the simulation model replicate this system measure? 8- Experimental design: The alternatives that are to be simulated must be determined 9- Production runs and analysis: Production runs, and their subsequent analysis, are used to estimate measures of performance for the system designs that are being simulated.

14 10- More runs? determines if additional runs are needed and what design those additional experiments should follow. 11- Documentation and Reporting. 12- Implementation. Steps in Simulation Study

15 Discrete-Event Simulation

16 Outline  Time-stepped implementation: critique  Discrete event fundamentals  Simulation engine  Example: Airport Simulation  Discrete event simulation critique

17 State Variables State:  InTheAir : number of aircraft either landing or waiting to land  OnTheGround : number of landed aircraft  RunwayFree : Boolean, true if runway available customer queue server

18 Time Step Implementation /* ignore aircraft departures */ Float InTheAir : # aircraft landing or waiting to land Float OnTheGround : # landed aircraft Boolean RunwayFree : True if runway available Float NextArrivalTime : Time the next aircraft arrives Float NextLanding : Time next aircraft lands (if one is landing) For (Now = 1 to EndTime) { /* time step size is 1.0 */ if (Now >= NextArrivalTime) { /* if aircraft just arrived */ InTheAir := InTheAir + 1; NextArrivalTime := NextArrivalTime + RandExp(A); if (RunwayFree) { RunwayFree := False; NextLanding := Now + RandExp(L); } if (Now >= NextLanding) { /* if aircraft just landed */ InTheAir := InTheAir - 1; OnTheGround := OnTheGround + 1; if (InTheAir > 0) NextLanding := Now + RandExp(L) else {RunWayFree := True; NextLanding := EndTime+1;} }

19 Problems With Time Step Approach  State changes may occur between time steps  Use small time steps to minimize error  Multiple state changes within the same time step may be processed in the wrong order  Solvable by ordering state changes within time step (this imposes more work)  Inefficient  Many time steps no state changes occur, especially if small time steps

20 Discrete Event Simulation Discrete Event Simulation: computer model for a system where changes in the state of the system occur at discrete points in simulation time. Fundamental concepts: System state (state variables) State transitions (events) Each event has a timestamp indicating when it occurs. A DES computation can be viewed as a sequence of event computations, with each event computation is assigned a (simulation time) time stamp Each event computation can Modify state variables Schedule new events

21 Discrete Event Simulation Computation  Events that have been scheduled, but have not been simulated (processed) yet are stored in a pending event list  Events are processed in time stamp order; why?  Example: air traffic at an airport  Events: aircraft arrival, landing, departure arrival 8:00 departure 9:15 landed 8:05 arrival 9:30 schedules simulation time processed event current event unprocessed event schedules

22 Simulation Application state variables code modeling system behavior I/O and user interface software Simulation Engine event list management managing advances in simulation time calls to schedule events calls to event handlers Discrete Event Simulation System Model of the physical system Independent of the simulation application

23 Events  An event must be associated with any change in the state of the system  Airport example:  Event 1: Aircraft Arrival ( InTheAir, RunwayFree )  Event 2: Aircraft Landing ( InTheAir, OnTheGround, RunwayFree )  Event 3: Aircraft Departure ( OnTheGround )

24 Event-Oriented World View state variables Integer: InTheAir; Integer: OnTheGround; Boolean: RunwayFree; Event handler procedures Simulation Application Arrival Event { … } Landed Event { … } Departure Event { … } Pending Event List (PEL) 9:00 9:16 10:10 Now = 8:45 Simulation Engine Event processing loop While (simulation not finished) E = smallest time stamp event in PEL Remove E from PEL Now := time stamp of E call event handler procedure

25 Example: Air traffic at an Airport  Model aircraft arrivals and departures, arrival queuing  Single runway for incoming aircraft, ignore departure queuing  L = mean time runway used for each landing aircraft (exponential distrib.)  G = mean time on the ground before departing (exponential distribution)  A = mean inter-arrival time of incoming aircraft (exponential distribution)  States  Now: current simulation time  InTheAir : number of aircraft landing or waiting to land  OnTheGround : number of landed aircraft  RunwayFree : Boolean, true if runway available  Events  Arrival : denotes aircraft arriving in air space of airport  Landed : denotes aircraft landing  Departure : denotes aircraft leaving

26 Arrival Events Arrival Event: InTheAir := InTheAir+1; Schedule Arrival event @ Now + RandExp(A); If (RunwayFree) { RunwayFree:=FALSE; Schedule Landed event @ Now + RandExp(L); } A: mean interarrival time of incoming aircraft Now: current simulation time InTheAir: number of aircraft landing or waiting to land OnTheGround: number of landed aircraft RunwayFree: Boolean, true if runway available  Arrival Process: New aircraft arrives at airport.  If the runway is free, it will begin to land.  Otherwise, the aircraft must circle, and wait to land.

27 Landed Event Landed Event: InTheAir:=InTheAir-1; OnTheGround:=OnTheGround+1; Schedule Departure event @ Now + RandExp(G); If (InTheAir>0) Schedule Landed event @ Now + RandExp(L); Else RunwayFree := TRUE; L = mean time runway is used for each landing aircraft G = mean time required on the ground before departing Now: current simulation time InTheAir: number of aircraft landing or waiting to land OnTheGround: number of landed aircraft RunwayFree: Boolean, true if runway available Landing Process: An aircraft has completed its landing.

28 Departure Event Departure Event: OnTheGround := OnTheGround - 1; Departure Process: An aircraft now on the ground departs for a new destination. Now: current simulation time InTheAir: number of aircraft landing or waiting to land OnTheGround: number of landed aircraft RunwayFree: Boolean, true if runway available

29 Execution Example OnTheGround Simulation Time State Variables RunwayFree InTheAir 01234567891011 true 0 0 L=3 G=4 TimeEvent 1 Arrival F1 3 Arrival F2 Now=0 Processing: false 1 TimeEvent 4 Landed F1 3 Arrival F2 Arrival F1 Now=1 2 TimeEvent 4 Landed F1 Arrival F2 Now=3 1 1 Landed F1 Now=4 TimeEvent 8 Depart F1 7 Landed F2 0 2 true TimeEvent 8 Depart F1 11 Depart F2 Landed F2 Now=7 1 TimeEvent 11 Depart F2 Depart F1 Now=8 0 TimeEvent Depart F2 Now=11

30 Output Statistics Compute  The maximum number of aircraft that will be on the ground at one time  Average time an aircraft must wait before they are allowed to land Solution  Maximum on ground  Variable for airport indicating number currently on ground  Maximum “on the ground” so far  Wait time  Variables for airport indicating total wait time, number of aircraft arrivals  State variable for each aircraft indicating the arrival time

31 Discrete Event Simulation  Avoids problems of time stepped execution  Error when events lie between time steps  Time steps with no events  But…  Priority queue (pending event list) introduces some new computational overhead  What about events with the same time stamp? More important than one might initially think!

32 Summary  Methodology  Important to have a reasonably clear conceptual and specification model before moving to implementation (computational model)  Key concepts: state variables and changes in state  Simulation engine: largely independent of application  Simulation model: state variables and code to modify state  Time stepped vs. event driven execution  In principle, either can be used to model system  Discrete-event simulation approach more commonly used to model queuing systems


Download ppt "CS433 Modeling and Simulation Lecture 09 – Part 02 Discrete Events Simulation Dr. Anis Koubâa 27 Dec 2008 Al-Imam."

Similar presentations


Ads by Google