Dr. Anis Koubâa CS433 Modeling and Simulation

Slides:



Advertisements
Similar presentations
Discrete Event (time) Simulation Kenneth.
Advertisements

Introduction into Simulation Basic Simulation Modeling.
Parallel and Distributed Simulation
IE 429, Parisay, January 2003 Review of Probability and Statistics: Experiment outcome: constant, random variable Random variable: discrete, continuous.
Modeling & Simulation. System Models and Simulation Framework for Modeling and Simulation The framework defines the entities and their Relationships that.
Lab Assignment 1 COP 4600: Operating Systems Principles Dr. Sumi Helal Professor Computer & Information Science & Engineering Department University of.
 1  Outline  performance measures for a single-server station  discrete-event simulation  hand simulation  process-oriented simulation approach.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 19 Scheduling IV.
Lecture 3 Concepts of Discrete-Event Simulation. 2 Discrete Event Model  In the discrete approach to system simulation, state changes in the physical.
Queuing Theory For Dummies
Simulation Where real stuff starts. ToC 1.What, transience, stationarity 2.How, discrete event, recurrence 3.Accuracy of output 4.Monte Carlo 5.Random.
Queuing Analysis Based on noted from Appendix A of Stallings Operating System text 6/10/20151.
1 Performance Evaluation of Computer Networks Objectives  Introduction to Queuing Theory  Little’s Theorem  Standard Notation of Queuing Systems  Poisson.
Lecture 11 Queueing Models. 2 Queueing System  Queueing System:  A system in which items (or customers) arrive at a station, wait in a line (or queue),
Data Communication and Networks Lecture 13 Performance December 9, 2004 Joseph Conron Computer Science Department New York University
1 Queueing Theory H Plan: –Introduce basics of Queueing Theory –Define notation and terminology used –Discuss properties of queuing models –Show examples.
Discrete Event Simulation Event-Oriented Simulations By Syed S. Rizvi.
Parallel and Distributed Simulation Object-Oriented Simulation.
7/3/2015© 2007 Raymond P. Jefferis III1 Queuing Systems.
Lab 01 Fundamentals SE 405 Discrete Event Simulation

Graduate Program in Engineering and Technology Management
Location Models For Airline Hubs Behaving as M/D/C Queues By: Shuxing Cheng Yi-Chieh Han Emile White.
Introduction to Discrete Event Simulation Customer population Service system Served customers Waiting line Priority rule Service facilities Figure C.1.
1 Performance Evaluation of Computer Networks: Part II Objectives r Simulation Modeling r Classification of Simulation Modeling r Discrete-Event Simulation.
Probability Review Thinh Nguyen. Probability Theory Review Sample space Bayes’ Rule Independence Expectation Distributions.
CS433 Modeling and Simulation Lecture 13 Queueing Theory Dr. Anis Koubâa 03 May 2009 Al-Imam Mohammad Ibn Saud University.
CS433 Modeling and Simulation Lecture 15 Random Number Generator Dr. Anis Koubâa 24 May 2009 Al-Imam Mohammad Ibn Saud Islamic University College Computer.
Structure of a Waiting Line System Queuing theory is the study of waiting lines Four characteristics of a queuing system: –The manner in which customers.
Queuing Theory Basic properties, Markovian models, Networks of queues, General service time distributions, Finite source models, Multiserver queues Chapter.
Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities have a life of their.
Data Structures Using C++ 2E Chapter 8 Queues. Data Structures Using C++ 2E2 Objectives Learn about queues Examine various queue operations Learn how.
CS433 Modeling and Simulation Lecture 12 Queueing Theory Dr. Anis Koubâa 03 May 2008 Al-Imam Mohammad Ibn Saud University.
Chapter 2 – Fundamental Simulation ConceptsSlide 1 of 46 Chapter 2 Fundamental Simulation Concepts.
Parallel and Distributed Simulation Process Oriented Simulation.
Simulation Examples and General Principles
Discrete Event (time) Simulation. What is a simulation? “Simulation is the process of designing a model of a real system and conducting experiments with.
OPERATING SYSTEMS CS 3530 Summer 2014 Systems and Models Chapter 03.
Structure of a Waiting Line System Queuing theory is the study of waiting lines Four characteristics of a queuing system: –The manner in which customers.
Chapter 6 Queueing Models
Discrete Event Simulation
(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.
Queuing Theory.  Queuing Theory deals with systems of the following type:  Typically we are interested in how much queuing occurs or in the delays at.
CDA6530: Performance Models of Computers and Networks Chapter 8: Statistical Simulation ---- Discrete Event Simulation (DES) TexPoint fonts used in EMF.
Advantages of simulation 1. New policies, operating procedures, information flows and son on can be explored without disrupting ongoing operation of the.
CS433 Modeling and Simulation Lecture 09 – Part 02 Discrete Events Simulation Dr. Anis Koubâa 27 Dec 2008 Al-Imam.
Parallel and Distributed Simulation Process Oriented Simulation.
© 2015 McGraw-Hill Education. All rights reserved. Chapter 17 Queueing Theory.
1 CS 214 Modeling and Simulation Modeling. TERMINOLOGY lSystem –A group of objects that are joined together in some regular interaction or interdependence.
Mohammad Khalily Islamic Azad University.  Usually buffer size is finite  Interarrival time and service times are independent  State of the system.
Clock Synchronization (Time Management) Deadlock Avoidance Using Null Messages.
Simulation Examples And General Principles Part 2
CDA6530: Performance Models of Computers and Networks Chapter 8: Statistical Simulation ---- Discrete Event Simulation (DES) TexPoint fonts used in EMF.
Queuing Theory Simulation & Modeling.
Simulation Modeling & Simulation 33.  Simulation: It is a numerical technique for conducting experiments with certain types of mathematical models.
Introduction to Simulation What is a simulation? A system that represents or emulates the behavior of another system over time; a computer simulation is.
PDES Introduction The Time Warp Mechanism
OPERATING SYSTEMS CS 3502 Fall 2017
Data Structures Using C++ 2E
Parallel and Distributed Simulation
Modeling and Simulation (An Introduction)
Al-Imam Mohammad Ibn Saud University
ADVANTAGES OF SIMULATION
TexPoint fonts used in EMF.
Chapter 10 Verification and Validation of Simulation Models
Parallel and Distributed Simulation
COMP60611 Fundamentals of Parallel and Distributed Systems
Delays Deterministic Stochastic Assumes “error free” type case
Discrete Event “Hand” Simulation of a GI/GI/1 Queue
Queueing Theory 2008.
Presentation transcript:

Dr. Anis Koubâa CS433 Modeling and Simulation Al-Imam Mohammad Ibn Saud Islamic University College Computer and Information Sciences CS433 Modeling and Simulation Lecture 14 Discrete Events Simulation http://www.aniskoubaa.net/ccis/spring09-cs433/ Dr. Anis Koubâa 24 May 2009

Textbook Reading Chapter 2 Discrete Events Simulation

Objectives Understand the concept of simulation Understand the concept of discrete event simulation

The Airport System … A certain airport contains a single runway on which arriving aircrafts must land. Once an aircraft is cleared to land, it will use the runway, during which time no other aircraft can be cleared to land. Once the aircraft has landed, the runway is available for use by other aircraft. The landed aircraft remains on the ground for a certain period of time before departing.

Model Development Life Cycle Define goals, objectives of study Develop conceptual model Fundamentally an iterative process Develop specification of model Develop computational model Verify model Validate model

Conceptual Model: Single Server Queue customer server Customer (aircraft) Entities utilizing the system/resources Server (runway) Resource that is serially reused; serves one customer at a time Queue Buffer holding aircraft waiting to land

Objectives Objective: Evaluate the performance of the Airport System Performance Metrics Average waiting time: Average time that an aircraft must wait when arriving at an airport before they are allowed to land. Maximum number of aircraft on the ground: Helps to dimension the required surface for the parking area.

Conceptual Model: Single Server Queue customer server Customer (aircraft) Entities utilizing the system/resources Server (runway) Resource that is serially reused; serves one customer at a time Queue Buffer holding aircraft waiting to land

Specification Model (Queueing Networks) Customers What is the arrival process? Schedule of aircraft arrivals, e.g., log from specific dates (trace driven) Often, probability distribution defines time between successive customer arrivals (interarrival time) Assumes interarrival times independent, and identically distributed (iid) Not always true (e.g., customers may leave if lines are too long!) Customer attributes? Sometime different flavors, e.g., priorities or other properties Servers How much service time is needed for each customer? May use probability distribution to specify customer service time (iid) How many servers? Queue Service discipline - who gets service next? First-in-first-out (FIFO), Last-in-first-out (LIFO), random … May depend on a property of the customer (e.g., priority, “smallest” first) Preemption? Queue capacity? What if the queue overflows?

Specification Model (cont.) Assumptions Customers Poisson Arrival Process: Assume arrivals are i.i.d., following an exponential distribution for inter-arrival times with mean A Assume all customers are identical (no specific attributes) Servers Exponential service time (landing time) with mean L One server (one runway) Queue Assume first-in-first-out queue (FIFO) discipline Assume queue has unlimited capacity

Computational Model The System correspond to M/M/1 Queue Model. Performance evaluation Analytical: using queuing theory Simulation: using a computer program A computer simulation is a computer program that emulate the behavior of a physical system over time. How a computer simulation works? Define state variables: variables that represent a state of the system (e.g. N: number of customers in the queue) Define events: a event changes a state variable of the system (e.g. Arrival, Departure).

Computational Model Simulation time can progress by two means: The General Algorithm of a simulation program Define state variables Define the events For each Event do Change the corresponding state variables Create next events, if any Collect statistics Progress simulation time Simulation time can progress by two means: Regular progress: Time Step implementation Irregular progress: Event-based implementation

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

Time Step Implementation Advantage Simple Drawback Not efficient /* 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;}

Discrete Event Simulation Discrete Event Simulation (DES): computer model for a system where changes in the state of the system occur at discrete points in simulation time. Each Event has a timestamp indicating when it occurs. A DES computation: a sequence of events, where each event is assigned a timestamp, which to help to order/schedule the processing of events.

Discrete Event Simulation Computation Example: air traffic at an airport Events: aircraft arrival, landing, departure arrival 8:00 schedules processed event current event unprocessed event departure 9:15 arrival 9:30 landed 8:05 schedules simulation time 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?

Discrete Event Simulation System 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 Model of the physical system Independent of the simulation application

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)

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

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

Arrival Events 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. 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 Event: InTheAir := InTheAir+1; Schedule Arrival event @ Now + RandExp(A); If (RunwayFree) { RunwayFree:=FALSE; Schedule Landed event @ Now + RandExp(L); }

Landed Event Landing Process: An aircraft has completed its landing. 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 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;

Departure Event 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 Departure Event: OnTheGround := OnTheGround - 1;

Execution Example L=3 G=4 Processing: State Variables InTheAir OnTheGround Simulation Time State Variables RunwayFree InTheAir 1 2 3 4 5 6 7 8 9 10 11 true L=3 G=4 Time Event 1 Arrival F1 3 Arrival F2 Now=0 Processing: false 1 Time Event 4 Landed F1 3 Arrival F2 Arrival F1 Now=1 2 Time Event 4 Landed F1 Arrival F2 Now=3 Time Event Depart F2 Now=11 1 Time Event 11 Depart F2 Depart F1 Now=8 2 true Time Event 8 Depart F1 11 Depart F2 Landed F2 Now=7 1 Landed F1 Now=4 Time Event 8 Depart F1 7 Landed F2

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 OnTheGround: indicate the number of aircraft currently on ground Maximum “on the ground” = Max (OnTheGround). Average Waiting time Compute the Waiting time for each aircraft: Wi = Arrival time – Landing Time Compute the total sum of all waiting times: Wtotal= sum(Wi) Compute the total number of aircraft: Ntotal Compute the average waiting time: Wavg = Wtotal/sum(Wi)

Summary Methodology Key concepts: state variables and changes in state 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