Agenda Main concepts in discrete-event simulation

Slides:



Advertisements
Similar presentations
Chapter 3 General Principles
Advertisements

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.
INTRODUCTION TO SIMULATION
 1  Outline  performance measures for a single-server station  discrete-event simulation  hand simulation  process-oriented simulation approach.
Lecture 3 Concepts of Discrete-Event Simulation. 2 Discrete Event Model  In the discrete approach to system simulation, state changes in the physical.
Event-drive SimulationCS-2303, C-Term Project #3 – Event-driven Simulation CS-2303 System Programming Concepts (Slides include materials from The.
Classification of Simulation Models
DISCRETE-EVENT SIMULATION CONCEPTS and EVENT SCHEDULING ALGORITHM
#11 QUEUEING THEORY Systems Fall 2000 Instructor: Peter M. Hahn
Components and Organization of Discrete-event Simulation Model
Simscript II.5 Building simulation model with SIMSCRIPT II.5.
Simulation with ArenaChapter 2 – Fundamental Simulation Concepts Discrete Event “Hand” Simulation of a GI/GI/1 Queue.
Simulation Software and Simulation in Java. Simulation languages & software Simulation Model Development General Purpose Languages Simulation Programming.
Simulating Single server queuing models. Consider the following sequence of activities that each customer undergoes: 1.Customer arrives 2.Customer waits.
Simulation Waiting Line. 2 Introduction Definition (informal) A model is a simplified description of an entity (an object, a system of objects) such that.
Queueing Models: Data Collection and Hand Simulation from Prof. Goldsman’s lecture notes.
CPSC 531: DES Overview1 CPSC 531:Discrete-Event Simulation Instructor: Anirban Mahanti Office: ICT Class Location:
Lecture 4 Mathematical and Statistical Models in Simulation.
Lab 01 Fundamentals SE 405 Discrete Event Simulation
Slide - 1 Dr Terry Hinton 6/9/05UniS - Based on Slides by Micro Analysis & Design An example of a Simulation Simulation of a bank: Three tasks or processes:
Introduction to Discrete Event Simulation Customer population Service system Served customers Waiting line Priority rule Service facilities Figure C.1.
(C) 2009 J. M. Garrido1 Object Oriented Simulation with Java.
Simulation Examples ~ By Hand ~ Using Excel
1 Performance Evaluation of Computer Networks: Part II Objectives r Simulation Modeling r Classification of Simulation Modeling r Discrete-Event Simulation.
Designing a Discrete Event Simulation Tool Peter L. Jackson School of Operations Research and Industrial Engineering March 15, 2003 Cornell University.
General Simulation Principles
ETM 607 – Discrete Event Simulation Fundamentals Define Discrete Event Simulation. Define concepts (entities, attributes, event list, etc…) Define “world-view”,
Chapter 3 General Principles Banks, Carson, Nelson & Nicol Discrete-Event System Simulation.
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.
+ Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time.
Dept. Computer Science, Tianjin Uni. 系统仿真 System Simulation 2008.
Chapter 2 – Fundamental Simulation ConceptsSlide 1 of 46 Chapter 2 Fundamental Simulation Concepts.
SIMULATION OF A SINGLE-SERVER QUEUEING SYSTEM
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.
NETW 707 Modeling and Simulation Amr El Mougy Maggie Mashaly.
1 Simulation Implementation Using high-level languages.
Chapter 2 Fundamental Simulation Concepts
MODELING EXAMPLES Types of model Conceptual Containing components that have not been clearly Identified in terms of theoretic categories such as state,
OPERATING SYSTEMS CS 3530 Summer 2014 Systems and Models Chapter 03.
Network Protocol Simulation: A look at Discrete Event Simulation Grant D. Lanterman 5/21/2004.
Discrete Event Simulation
Dr. Anis Koubâa CS433 Modeling and 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.
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.
Chapter 2 Basic Simulation Modeling
 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,
Chapter 3 General Principles Banks, Carson, Nelson & Nicol Discrete-Event System Simulation.
Unit 4 Simulation software. Introduction Software used to develop simulation models can be divided into 3 categories: – General-purpose programming languages:
MODELING AND SIMULATION CS 313 Simulation Examples 1.
Simulation Examples And General Principles Part 2
Simulation modelling real processes to make predictions.
CDA6530: Performance Models of Computers and Networks Chapter 8: Statistical Simulation ---- Discrete Event Simulation (DES) TexPoint fonts used in EMF.
Simulation. Types of simulation Discrete-event simulation – Used for modeling of a system as it evolves over time by a representation in which the state.
Discrete-Event System Simulation in Java. Discrete Event Systems New dynamic systems New dynamic systems Computer and communication networks Computer.
Ch 1: Simulation of Computer Networks. 1.1 Computer Networks and the Layering Concept Layering Concept Service Interface Protocol.
Simulation of single server queuing systems
Modeling and Simulation
Chapter 1 What is Simulation?. Fall 2001 IMSE643 Industrial Simulation What’s Simulation? Simulation – A broad collection of methods and applications.
Chapter 4 Simulation Software
OPERATING SYSTEMS CS 3502 Fall 2017
Discrete Event Simulation
Modeling and Simulation CS 313
More Explanation of an example in chapter4
Concepts In Discrete-Event Simulation
Discrete Event “Hand” Simulation of a GI/GI/1 Queue
MECH 3550 : Simulation & Visualization
Chapter 4: Simulation Designs
Presentation transcript:

Part 3: General Principles for Discrete-Event Simulations 4/16/2017 Part 3: General Principles for Discrete-Event Simulations

Agenda Main concepts in discrete-event simulation Event scheduling/Time advance List processing Stopping the simulation Java code example: single serve queue

1. Main Concepts (1) System: A collection of entities that interact together over time to accomplish one or more goals. Model: An abstract representation of a system, usually containing structural, logical, or mathematical relationships that describe a system in terms of state, entities and their attributes, sets, processes, events, activities, and delays. System state: A collection of variables that contain all the information necessary to describe the system at any time. Entity: Any object or component in the system that requires explicit representation in the model (e.g., a server, a customer, a machine). Attributes: The properties of a given entity (e.g., the priority of a waiting customer, the routing of a job through a job shop). List: A collection of (permanently or temporarily) associated entities, ordered in some logical fashion (such as all customers currently in a waiting line, ordered by "first come, first served," or by priority).

1. Main Concepts (2) Event: An instantaneous occurrence that changes the state of a system (such as an arrival of a new customer). Event notice: A record of an event to occur at the current or some future time, along with any associated data necessary to execute the event; at a minimum, the record includes the event type and the event time. Event list: A list of event notices for future events, ordered by time of occurrence; also known as the future event list (FEL). Activity: A duration of time of specified length (e.g., a service time or interarrival time), which is known when it begins (although it may be defined in terms of a statistical distribution). Delay: A duration of time of unspecified indefinite length, which is not known until it ends (e.g., a customer's delay in a last-in-first-out waiting line which, when it begins, depends on future arrivals). Clock: A variable representing simulated time

2. Event Scheduling and Time Advance (1) The mechanism for advancing simulation time and guaranteeing that all events occur in correct chronological order is based on the Future Event List (FEL). This list contains all event notices for events that have been scheduled to occur at a future time. Scheduling a future event means that, at the instant an activity begins, its duration is computed or drawn as a sample from a statistical distribution; and that the end-activity event, together with its event time, is placed on the future event list. In the real world, most future events are not scheduled but merely happen such as random breakdowns or random arrivals. In the model, such random events are represented by the end of some activity, which in turn is represented by a statistical distribution. At any given time t, the FEL contains all previously scheduled future events and their associated event times (called t1, t2, . .. ). The FEL is ordered by event time, meaning that the events are arranged chronologically, that is, the event times satisfy t < t1  t2  t3  ...  tn.

2. Event Scheduling and Time Advance (2) Time t is the value of CLOCK, the current value of simulated time. The event associated with time t1 is called the imminent event; that is, it is the next event that will occur. After the system snapshot at simulation time CLOCK = t has been updated, the CLOCK is advanced to simulation time CLOCK = t1, the imminent event notice is removed from the FEL, and the event is executed. Execution of the imminent event means that a new system snapshot for time t1 is created, one based on the old snapshot at time t and the nature of the imminent event. At time t1, new future events may or might not be generated, but if any are, they are scheduled by creating event notices and putting them into their proper position on the FEL. After the new system snapshot for time t1 has been updated, the clock is advanced to the time of the new imminent event and that event is executed. This process repeats until the simulation is over.

2. Event Scheduling and Time Advance (3): Single Server Queue Example Next-event time advance for the single-server queue ti = time of arrival of ith customer (t0 = 0) Ai = ti – ti-1 = interarrival time between (i-1)st and ith customers (a random variable from some probability distribution) Si = service-time requirement of ith customer (another random variable) Di = delay in queue of ith customer ci = ti + Di + Si = time ith customer completes service and departs ej = time of occurrence of the jth event (of any type), j = 1, 2, 3, …

3. List Processing (1) The length and contents of the FEL are constantly changing as the simulation progresses, and thus its efficient management in a computerized simulation will have a major impact on the efficiency of the computer program representing the model. The management of a list is called list processing. The major list processing operations performed on a FEL are removal of the imminent event, addition of a new event to the list, and occasionally removal of some event (called cancellation of an event).

3. List Processing (2): Basic Operations Removing a record from the top of the list Removing a record from any location on the list Adding an entity record to the top or bottom of ths list Adding a record at any arbitrary position in the list An entity along with its attributes or an event notice will be referred to as record

4. Stopping the Simulation Every simulation must have a stopping event, here called E, which defines how long the simulation will run. There are generally two ways to stop a simulation: At time 0, schedule a stop simulation event at a specified future time TE. Thus, before simulating, it is known that the simulation will run over the time interval [0, TE]. Example: Simulate a job shop for TE = 40 hours. Run length TE is determined by the simulation itself. Generally, TE is the time of occurrence of some specified event E. Examples: TE is the time of the 100th service completion at a certain service center; TE is the time of breakdown of a complex system; TE is the time of disengagement or total kill (whichever occurs first) in a combat simulation. TE is the time at which a distribution center ships the last carton in a day's orders

5. Single Server Queue in Java (1): Overall Structure

5. Single Server Queue in Java (2): Main Program public static void main(String argv[]) { MeanInterArrivalTime = 4.5; MeanServiceTime = 3.2; SIGMA = 0.6; TotalCustomers = 1000; long seed = Long.parseLong(argv[0]); stream = new Random(seed); // initialize rng stream FutureEventList = new EventList(); Customers = new Queue(); Initialization(); // Loop until first "TotalCustomers" have departed while(NumberOfDepartures < TotalCustomers ) { Event evt = (Event)FutureEventList.getMin(); // get imminent event FutureEventList.dequeue(); // be rid of it Clock = evt.get_time(); // advance simulation time if( evt.get_type() == arrival ) ProcessArrival(evt); else ProcessDeparture(evt); } ReportGeneration();

5. Single Server Queue in Java (3): Arrival Process public static void ProcessArrival(Event evt) { Customers.enqueue(evt); QueueLength++; // if the server is idle, fetch the event, do statistics // and put into service if( NumberInService == 0) ScheduleDeparture(); else TotalBusy += (Clock - LastEventTime); // server is busy // adjust max queue length statistics if (MaxQueueLength < QueueLength) MaxQueueLength = QueueLength; // schedule the next arrival Event next_arrival = new Event(arrival, Clock+exponential(stream, MeanInterArrivalTime)); FutureEventList.enqueue( next_arrival ); LastEventTime = Clock; }

5. Single Server Queue in Java (4): Departure Process public static void ScheduleDeparture() { double ServiceTime; // get the job at the head of the queue while (( ServiceTime = normal(stream, MeanServiceTime, SIGMA)) < 0 ); Event depart = new Event(departure,Clock+ServiceTime); FutureEventList.enqueue( depart ); NumberInService = 1; QueueLength--; } public static void ProcessDeparture(Event e) { // get the customer description Event finished = (Event) Customers.dequeue(); // if there are customers in the queue then schedule // the departure of the next one if( QueueLength > 0 ) ScheduleDeparture(); else NumberInService = 0; // measure the response time and add to the sum double response = (Clock - finished.get_time()); SumResponseTime += response; if( response > 4.0 ) LongService++; // record long service TotalBusy += (Clock - LastEventTime ); NumberOfDepartures++; LastEventTime = Clock;

5. Single Server Queue in Java (5): Report Generation public static void ReportGeneration() { double RHO = TotalBusy/Clock; double AVGR = SumResponseTime/TotalCustomers; double PC4 = ((double)LongService)/TotalCustomers; System.out.println( "SINGLE SERVER QUEUE SIMULATION - GROCERY STORE CHECKOUT COUNTER "); System.out.println( "\tMEAN INTERARRIVAL TIME " + MeanInterArrivalTime ); System.out.println( "\tMEAN SERVICE TIME " + MeanServiceTime ); System.out.println( "\tSTANDARD DEVIATION OF SERVICE TIMES " + SIGMA ); System.out.println( "\tNUMBER OF CUSTOMERS SERVED " + TotalCustomers ); System.out.println(); System.out.println( "\tSERVER UTILIZATION " + RHO ); System.out.println( "\tMAXIMUM LINE LENGTH " + MaxQueueLength ); System.out.println( "\tAVERAGE RESPONSE TIME " + AVGR + " MINUTES" ); System.out.println( "\tPROPORTION WHO SPEND FOUR "); System.out.println( "\t MINUTES OR MORE IN SYSTEM " + PC4 ); System.out.println( "\tSIMULATION RUNLENGTH " + Clock + " MINUTES" ); System.out.println( "\tNUMBER OF DEPARTURES " + TotalCustomers ); }

5. Single Server Queue in Java (6): Random Variates public static double exponential(Random rng, double mean) { return -mean*Math.log( rng.nextDouble() ); } public static double SaveNormal; public static int NumNormals = 0; public static final double PI = 3.1415927 ; public static double normal(Random rng, double mean, double sigma) { double ReturnNormal; // should we generate two normals? if(NumNormals == 0 ) { double r1 = rng.nextDouble(); double r2 = rng.nextDouble(); ReturnNormal = Math.sqrt(-2*Math.log(r1))*Math.cos(2*PI*r2); SaveNormal = Math.sqrt(-2*Math.log(r1))*Math.sin(2*PI*r2); NumNormals = 1; } else { NumNormals = 0; ReturnNormal = SaveNormal; return ReturnNormal*sigma + mean ;