Design of discrete-event simulations

Similar documents
Discrete-event simulations

Variance reduction techniques

Variance reduction techniques

Uniform random numbers generators

Computer Simulation Techniques: The definitive introduction!

1.225J J (ESD 205) Transportation Flow Systems

GI/M/1 and GI/M/m queuing systems

Outline Resource Introduction Usage Testing Exercises. Linked Lists COMP SCI / SFWR ENG 2S03. Department of Computing and Software McMaster University

Simulation & Modeling Event-Oriented Simulations

Discrete Event Simulation. Motive

Queueing Theory and Simulation. Introduction

Verification and Validation. CS1538: Introduction to Simulations

Insert Sorted List Insert as the Last element (the First element?) Delete Chaining. 2 Slide courtesy of Dr. Sang-Eon Park

Ways to study a system System

Queuing Networks: Burke s Theorem, Kleinrock s Approximation, and Jackson s Theorem. Wade Trappe

Topic Contents. Factoring Methods. Unit 3: Factoring Methods. Finding the square root of a number

Clock-driven scheduling

4. Multilayer Perceptrons

Lecture 7: Simulation of Markov Processes. Pasi Lassila Department of Communications and Networking

M/G/1 and M/G/1/K systems

EE 368. Weeks 3 (Notes)

λ λ λ In-class problems

Chapter 2 Queueing Theory and Simulation

ISE/OR 762 Stochastic Simulation Techniques

Overall Plan of Simulation and Modeling I. Chapters

Algorithms and Complexity theory

1.225 Transportation Flow Systems Quiz (December 17, 2001; Duration: 3 hours)

Class 8: Numbers Exercise 3B

Queues. Principles of Computer Science II. Basic features of Queues

Computation Theory Finite Automata

How to deal with uncertainties and dynamicity?

Motivation Subgradient Method Stochastic Subgradient Method. Convex Optimization. Lecture 15 - Gradient Descent in Machine Learning

Introduction to Randomized Algorithms III

CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26. Homework #2. ( Due: Nov 8 )

Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I

Environment (E) IBP IBP IBP 2 N 2 N. server. System (S) Adapter (A) ACV

LECTURE 28. Analyzing digital computation at a very low level! The Latch Pipelined Datapath Control Signals Concept of State

Pipelined Computations

7 Variance Reduction Techniques

Lecture 13: Sequential Circuits, FSM

Hash tables. Hash tables

Skip Lists. What is a Skip List. Skip Lists 3/19/14

Networking = Plumbing. Queueing Analysis: I. Last Lecture. Lecture Outline. Jeremiah Deng. 29 July 2013

CDA6530: Performance Models of Computers and Networks. Chapter 8: Discrete Event Simulation (DES)

Searching, mainly via Hash tables

Exact Simulation of the Stationary Distribution of M/G/c Queues

Skip List. CS 561, Lecture 11. Skip List. Skip List

Continuous Time Processes

NEW FRONTIERS IN APPLIED PROBABILITY

Time Reversibility and Burke s Theorem

MATH 56A: STOCHASTIC PROCESSES CHAPTER 6

Lecture 20: Reversible Processes and Queues

Buzen s algorithm. Cyclic network Extension of Jackson networks

Slides for Chapter 14: Time and Global States

Computer Science, Informatik 4 Communication and Distributed Systems. Simulation. Discrete-Event System Simulation. Dr.

5. Sequential Logic x Computation Structures Part 1 Digital Circuits. Copyright 2015 MIT EECS

Chapter 11 Estimation of Absolute Performance

order is number of previous outputs

Generating Random Variates II and Examples

Chapter 6 Queueing Models. Banks, Carson, Nelson & Nicol Discrete-Event System Simulation

Recap. Probability, stochastic processes, Markov chains. ELEC-C7210 Modeling and analysis of communication networks

Queueing Theory I Summary! Little s Law! Queueing System Notation! Stationary Analysis of Elementary Queueing Systems " M/M/1 " M/M/m " M/M/1/K "

Logic Design II (17.342) Spring Lecture Outline

Chapter 3 Balance equations, birth-death processes, continuous Markov Chains

λ, µ, ρ, A n, W n, L(t), L, L Q, w, w Q etc. These

CHAPTER 3 STOCHASTIC MODEL OF A GENERAL FEED BACK QUEUE NETWORK

Today s Agenda: 1) Why Do We Need To Measure The Memory Component? 2) Machine Pool Memory / Best Practice Guidelines

5/15/18. Operations Research: An Introduction Hamdy A. Taha. Copyright 2011, 2007 by Pearson Education, Inc. All rights reserved.

Section 3.3: Discrete-Event Simulation Examples

EPoC UPSTREAM SYMBOL MAPPER OVERVIEW. Authors: Mark Laubach, Rich Prodan

1 Approximate Quantiles and Summaries

WHAT IS A SKIP LIST? S 2 S 1. A skip list for a set S of distinct (key, element) items is a series of lists

IEOR 6711, HMWK 5, Professor Sigman

UNIT 3: INTEGERS. Mónica Cárceles Alemán. IES Rector don Francisco Sabater García Positive and negative integers

RANDOMIZED ALGORITHMS

1 Poisson processes, and Compound (batch) Poisson processes

Readings: Finish Section 5.2

Vehicle Routing and Scheduling. Martin Savelsbergh The Logistics Institute Georgia Institute of Technology

1 ListElement l e = f i r s t ; / / s t a r t i n g p o i n t 2 while ( l e. next!= n u l l ) 3 { l e = l e. next ; / / next step 4 } Removal

0utline. 1. Tools from Operations Research. 2. Applications

Binary Convolutional Codes

Heaps and Priority Queues

Part I Stochastic variables and Markov chains

A STAFFING ALGORITHM FOR CALL CENTERS WITH SKILL-BASED ROUTING: SUPPLEMENTARY MATERIAL

Year 3. Year 3. Lesson Breakdown & Textbook Mapping Spring. Lesson Breakdown & Textbook Mapping

COMPUTER PROGRAMMING

Chapter 11. Output Analysis for a Single Model Prof. Dr. Mesut Güneş Ch. 11 Output Analysis for a Single Model

The exponential distribution and the Poisson process

Computer Science, Informatik 4 Communication and Distributed Systems. Simulation. Discrete-Event System Simulation. Dr.

ECEN 689 Special Topics in Data Science for Communications Networks

Exercises Stochastic Performance Modelling. Hamilton Institute, Summer 2010

Fundamental Algorithms

Lecture 13: Sequential Circuits, FSM

Massachusetts Institute of Technology

Course Outline Introduction to Transportation Highway Users and their Performance Geometric Design Pavement Design

Class Notes: Solving Simultaneous Linear Equations by Gaussian Elimination. Consider a set of simultaneous linear equations:

STA 4273H: Statistical Machine Learning

CS 798: Homework Assignment 3 (Queueing Theory)

IEOR 4106: Spring Solutions to Homework Assignment 7: Due on Tuesday, March 22.

So in terms of conditional probability densities, we have by differentiating this relationship:

Transcription:

Design of discrete-event simulations Lecturer: Dmitri A. Moltchanov E-mail: moltchan@cs.tut.fi http://www.cs.tut.fi/kurssit/tlt-2707/

OUTLINE: Discrete event simulation; Event advance design; Unit-time advance design; Lecture: Design of discrete-event simulations 2

1. Discrete event simulation The basic idea: only events change the state of the system; here is not need to track state of the system between these events. The whole system consists of the following components: system under consideration: stochastic process under considerations: product of other processes and RVs. system state: state of the stochastic process. simulation clock: tells the occurrence time of the next event. event list: holder for events. You may consider it as a two dimensional vector: time and event. Lecture: Design of discrete-event simulations 3

The idea of the event list is illustrated in the following figure: T i, i = 1, 2,..., are times; E i, i = 1, 2,..., are corresponding events. E 1 T 1 E 2 T 2 E 3 T 3... E i T i... Figure 1: The idea of the event list. Events are identified by event time and event type. There are two general types of events: basic events: these events modify the state of the system: arrivals/departures of customers. additional events: these are events needed by additional tasks of simulation: run, stoppage, collection of data. Lecture: Design of discrete-event simulations 4

Algorithm for discrete-event simulation: Initialization procedure: system clock should be set to zero; system state is assigned an initial value; generate list of the event and place the next event to this list. Handling of events during a simulation: system clock should be set to the occurrence time of the first (next) event in event list; handle the event making all appropriate actions associated with the event; update the system state. Stop of simulation. Note that the following is not included: storing of statistical data; statistical analysis of obtained data. Lecture: Design of discrete-event simulations 5

1.1. Time advance methods Time advance methods in discrete-event simulations: event-advance method; unit-advance method. unit-time advance: t 0 t 1 t 2 t 3 t 4 t 5 event advance: t 0 t 1 t 3 Figure 2: Time advance techniques in discrete-event simulations. Lecture: Design of discrete-event simulations 6

2. Event advance design This is the most popular design of discrete-event simulations. The idea: observe: state of the system changes each time an event occurs; therefore: during time between events state does not change; idea: we can just skip times between events! To implement this idea: each event is associated with a certain clock value; this value gives the time in the future when this event occurs. Treatment of the event: do everything what is needed for treatment of the event; regroup all events that will occur in the future according to values of their clocks; find the one with the smallest clock value; advance the master clock to the time of that event and treat it. Lecture: Design of discrete-event simulations 7

Machine interference problem: M unreliable machines; 1 repairmen. Figure 3: A full cycle of the machine. Figure 4: A model for downtime of the machine (queue is of D/D/1/ /M type). Lecture: Design of discrete-event simulations 8

Two types of events: arrival to the repairmen s queue; departure after the machine has been fixed. Lecture: Design of discrete-event simulations 9

2.1. Future event list Future event list: collection of events that occur in the future. Future event list contains: time of occurrence: determines when the events occurs. type of the event: determines what actions should be taken to process the events; these actions must be associated with all events. The problem: how to effectively determine the next event? we considered examples with only few events; there can be a lot of events; Efficiency of the finding algorithm depends on: amount information kept in the future list; the way how this information is organized. Lecture: Design of discrete-event simulations 10

What type of operation are performed in a list: locating the next event and its type: required when advancing the time. deleting the event: required when the events has already been treated. inserting the event in a list: required when generating new event; required when basic event generates conditional events. Basically, there are two ways of organizing a list: using sequential array; using linked list. Lecture: Design of discrete-event simulations 11

2.2. Sequential arrays The approach: all future event times are stored sequentially in array. How to implement: associate each event type with a certain integer i; clock associated with this event is stored in the ith position in array. Example: we need N positions in array: clock value of the type 1 event is stored in 1st position; clock value of the type 2 event is stored in 2nd position;... clock value of the type N event is store in Nth position; Figure 5: Using sequential array as a future event list. Lecture: Design of discrete-event simulations 12

How to find the next event: locate the smallest value in array of N elements. Example: find the smallest element and its index in array E[i], i = 0, 1,..., N 1: variable smallest returns the smallest element; variable index returns the index of the smallest element. smallest = E[0]; index = 0; for (i=1; i<n; i++) { if (E[i] < smallest) { smallest = E[i]; index = i; } } Lecture: Design of discrete-event simulations 13

How to deal with other functions: deletion: set the value of the clock associated with event of type i to very big one; not deleted physically! insertion: update the value of the clock associated with event of type i. not inserted physically! Advantages: insertion and deletion are made very easily; location of the next event depend on the number of event types: complexity is linear in time. Shortcoming: if the number of event types is large location is time consuming; in this case different organization of the future event list should be considered. Lecture: Design of discrete-event simulations 14

2.3. Linked list The idea: to access data elements in correct order we store data element; we store pointer to the next element. Definitions: pointer is referred to as link; data element and the link(s) are referred to as node. Example: node consists of two elements: one is data elements, the next one is link; link F points to the first element; link of the last node is set to zero. Figure 6: Using linked list as a future event list. Lecture: Design of discrete-event simulations 15

Linked lists: singly linked: nodes are connected by a single link; multiply linked: nodes can be connected by multiple links. Example: singly linked list: node consists of: two data elements: clock value CL i ; type of the event indicating by i. one link to the next element. Note: nodes are arranged in ascending order: CL i < CL j < < CL n. Figure 7: Usage of singly linked list in event advance discrete-event simulation. Lecture: Design of discrete-event simulations 16

Implementation example: arrange integer numbers in T in ascending order: create new array P of the same dimension; the content of P (i) is the link to location in T containing element larger than T (i); example: P (1) = 7, next larger after T (1) is T (7)... Notes: F (= 5) is the first element; node: location in T and corresponding location in P. Figure 8: Locating values in a singly linked list. Lecture: Design of discrete-event simulations 17

Locating element: we want to locate number 10 in T : using pointer F we check the value stored in the first node: (T (5), P (5)); using pointer P (5) we locate the second node: (T (3), P (3)); using pointer P (3) we locate the third node: (T (1), P (1)); pointer P (1) contains the address we are looking for; general: if we know address of the first node we can locate any element. Note: we can only move forward using singly linked link! Figure 9: Deletion of elements in a singly linked list. Lecture: Design of discrete-event simulations 18

Deletion: we want to delete number 10: change the value of the pointer of the previous node; previous node: (T (1), P (1)) = (5, 4); node containing 10 has the pointer P (7) = 4; to delete: set P (1) = P (7) = 4. Note: information is not physically deleted, just not accessible! Figure 10: Deletion of elements in a singly linked list. Lecture: Design of discrete-event simulations 19

Insertion: we want to insert number 6: locate two nodes between which we should put 6; starting from the first node we find them as: (5, 7) and (10, 4) (see previous slide); get unused location in T : T (2); set P (1) = 2 to go from T (1) = 5 to T (2) = 6; set T (2) = 6, P (2) = 7 to go from T (2) = 6 to T (7) = 10. Figure 11: Insertion of elements in a singly linked list. Lecture: Design of discrete-event simulations 20

2.4. Implementation of linked lists We have to be able: organize data elements and pointers into nodes; access node using pointer; create and delete nodes. There are two ways: use built-in commands to carry these operations (if any); set-up your own storage scheme. Notes: must be long enough to accommodate all events that might be generated; all unused nodes must be linked together to form a pool of free nodes. Lecture: Design of discrete-event simulations 21

2.5. Future event list using linked list General notes: nodes are organized such that CL i < CL j < < CL n ; the next event is given by pointer F (first node); when the event occurred and processed it should be deleted; if conditional events are generated they are place in linked list. Advantages: location and deletion is made easily: using linked lists in simulation we have to delete only the first node! Shortcomings we have to use location procedure to insert an event in a linked list; search of the linked lists might be time consuming if the number of event types is large; solution: use better location procedure (e.g. use pointer pointing to the middle of the list)! Lecture: Design of discrete-event simulations 22

2.6. Doubly linked lists The main problem of the singly linked lists: we can go only forward! Doubly linked lists: link two successive node with two pointers; we can go forward and backward! Note: there are some advantages for specific applications. Figure 12: Example of the doubly linked list. Lecture: Design of discrete-event simulations 23

3. Unit-time advance The basic idea: master clock is advanced in fixed increments of time. How it works: each time clock is advanced all future events clocks is compared to it; if any of these clocks is equal to the master clock this event is processed; if not, clock is advanced again. Note: this is less popular design. t 0 t 1 t 2 t 3 t 4 t 5 Figure 13: Unit-time advance design of discrete-event simulations. Lecture: Design of discrete-event simulations 24

Lecture: Design of discrete-event simulations 25

Notes of the event clocks: may contain future time with respect to the origin; may reflect the duration of the particular activity: e.g. departure clock may contain the duration of the service. If related clocks are used in simulation: when master clock is advanced by unit time: future clock is reduced by unit times; if any is zero we process the associated event. Lecture: Design of discrete-event simulations 26

Example: simulate a single server queue with finite population of customers: AT: interarrival times; ST: service time; MCL: master clock. Lecture: Design of discrete-event simulations 27

3.1. Selecting unit-time If all future events clocks are integer: event clocks must be a multiple of unit-time; unit-time must be a smallest common divisor. If some of future events are real we have a problem: some events may occur between two successive time instant of the master clock; occurrence of the events is not known to the master clock. Another problem: some events may occur at the same time instant of the master clock. Figure 14: Certain events may occur in between two successive times of the master clock. Lecture: Design of discrete-event simulations 28

Trade-off: time increment must be small enough to ensure that one event occurs in between; if it is too small, it is ineffective. Some rules for choosing unit-time: 1. set the time-unit to the half of the smallest variate generated: we know only probabilistically what will be the smallest variate generated. 2. run multiple pilot simulation with different unit-times to observe their effect: start with very small time-unit; increase it slightly; if there is no effect on results you may increase it again. Lecture: Design of discrete-event simulations 29

3.2. Notes on implementation of unit-time advance One can use for future event lists: sequential arrays; linked lists. Advantages: when events are approximately evenly separated from each other; the best case when events are about a unit-time from each other. Shortcomings: when there are few events and they are far apart from each other. Note: practically, no advantages comparing to event advance design. Lecture: Design of discrete-event simulations 30