Discrete-event simulations

Similar documents
Design of discrete-event simulations

Uniform random numbers generators

Variance reduction techniques

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

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

Variance reduction techniques

Queueing Theory and Simulation. Introduction

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

Performance Evaluation of Queuing Systems

Introduction to Queueing Theory with Applications to Air Transportation Systems

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

NICTA Short Course. Network Analysis. Vijay Sivaraman. Day 1 Queueing Systems and Markov Chains. Network Analysis, 2008s2 1-1

Chapter 2 Queueing Theory and Simulation

Discrete Event Simulation. Motive

Simulation & Modeling Event-Oriented Simulations

Session-Based Queueing Systems

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 "

Ways to study a system System

1.225J J (ESD 205) Transportation Flow Systems

EE 368. Weeks 3 (Notes)

CPSC 531: System Modeling and Simulation. Carey Williamson Department of Computer Science University of Calgary Fall 2017

Buzen s algorithm. Cyclic network Extension of Jackson networks

Analysis of Software Artifacts

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

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

Computer Simulation Techniques: The definitive introduction!

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

CS 798: Homework Assignment 3 (Queueing Theory)

Generating Random Variates II and Examples

6 Solving Queueing Models

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

Computer Networks More general queuing systems

Dynamic resource sharing

The exponential distribution and the Poisson process

IEOR 6711, HMWK 5, Professor Sigman

CDA5530: Performance Models of Computers and Networks. Chapter 4: Elementary Queuing Theory

QUEUING SYSTEM. Yetunde Folajimi, PhD

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

Queueing systems. Renato Lo Cigno. Simulation and Performance Evaluation Queueing systems - Renato Lo Cigno 1

EP2200 Course Project 2017 Project II - Mobile Computation Offloading

Queuing Theory. Richard Lockhart. Simon Fraser University. STAT 870 Summer 2011

Link Models for Circuit Switching

57:022 Principles of Design II Final Exam Solutions - Spring 1997

Queueing Theory. VK Room: M Last updated: October 17, 2013.

Continuous Time Processes

Queues and Queueing Networks

Slides 9: Queuing Models

LIMITS FOR QUEUES AS THE WAITING ROOM GROWS. Bell Communications Research AT&T Bell Laboratories Red Bank, NJ Murray Hill, NJ 07974

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

Stochastic Models in Computer Science A Tutorial

IEOR 8100: Topics in OR: Asymptotic Methods in Queueing Theory. Fall 2009, Professor Whitt. Class Lecture Notes: Wednesday, September 9.

Introduction to Markov Chains, Queuing Theory, and Network Performance

PBW 654 Applied Statistics - I Urban Operations Research

Time Reversibility and Burke s Theorem

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

ON THE LAW OF THE i TH WAITING TIME INABUSYPERIODOFG/M/c QUEUES

Transient Analysis of a Series Configuration Queueing System

Part I Stochastic variables and Markov chains

Introduction to Queueing Theory

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

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

IEOR 6711: Stochastic Models I, Fall 2003, Professor Whitt. Solutions to Final Exam: Thursday, December 18.

Overall Plan of Simulation and Modeling I. Chapters

Introduction to queuing theory

A PARAMETRIC DECOMPOSITION BASED APPROACH FOR MULTI-CLASS CLOSED QUEUING NETWORKS WITH SYNCHRONIZATION STATIONS

Lecturer: Olga Galinina

Non Markovian Queues (contd.)

The Queue Inference Engine and the Psychology of Queueing. ESD.86 Spring 2007 Richard C. Larson

IOE 202: lectures 11 and 12 outline

BIRTH DEATH PROCESSES AND QUEUEING SYSTEMS

Readings: Finish Section 5.2

ISE/OR 762 Stochastic Simulation Techniques

MATH 56A: STOCHASTIC PROCESSES CHAPTER 6

Queuing Theory. 3. Birth-Death Process. Law of Motion Flow balance equations Steady-state probabilities: , if

NEW FRONTIERS IN APPLIED PROBABILITY

Introduction to Queuing Networks Solutions to Problem Sheet 3

A FAST MATRIX-ANALYTIC APPROXIMATION FOR THE TWO CLASS GI/G/1 NON-PREEMPTIVE PRIORITY QUEUE

Probability and Statistics Concepts

Introduction to Queuing Theory. Mathematical Modelling

Simulation. Where real stuff starts

Network Simulation Chapter 5: Traffic Modeling. Chapter Overview

14 Random Variables and Simulation

CSE 4201, Ch. 6. Storage Systems. Hennessy and Patterson

Stochastic Models of Manufacturing Systems

Queuing Theory. Using the Math. Management Science

Operations Research Letters. Instability of FIFO in a simple queueing system with arbitrarily low loads

MULTIPLE CHOICE QUESTIONS DECISION SCIENCE

Introduction to Queueing Theory

Kendall notation. PASTA theorem Basics of M/M/1 queue

CS418 Operating Systems

Queuing Analysis. Chapter Copyright 2010 Pearson Education, Inc. Publishing as Prentice Hall

Link Models for Packet Switching

Simulation. Where real stuff starts

Contents Preface The Exponential Distribution and the Poisson Process Introduction to Renewal Theory

Introduction to Queueing Theory

Lecture 20: Reversible Processes and Queues

Solutions to COMP9334 Week 8 Sample Problems

Name of the Student:

E-Companion to Fully Sequential Procedures for Large-Scale Ranking-and-Selection Problems in Parallel Computing Environments

A Study on Performance Analysis of Queuing System with Multiple Heterogeneous Servers

Transcription:

Discrete-event simulations Lecturer: Dmitri A. Moltchanov E-mail: moltchan@cs.tut.fi http://www.cs.tut.fi/kurssit/elt-53606/

OUTLINE: Why do we need simulations? Step-by-step simulations; Classifications; Simulation program; Discrete-event simulations; Example: GI/G/1 queuing system; Event advance design; Unit-time advance design. Lecture: Discrete-event simulations 2

1. Why do we need simulations? Two ways to estimate performance metrics in networks: analytical analysis; simulation studies. Example: analysis of queuing system: modeling of arrival process as a stochastic process; modeling of service time are a stochastic process; representation of interactions of these processes as a Markov process. What is important for analytical analysis: often analytical analysis of the queue is too complicated or even not possible; requires very restrictive assumptions to be introduced. Lecture: Discrete-event simulations 3

1.1. Example: GI/G/1 queuing system We know how to analyze analytically: M/M/-/-/- type of systems; G/M/-/-/- and M/G/-/-/- systems. You have to note: arrival and service processes can be general; this is the case in telecommunications networks. Examples: IP router serving user s traffic from a number of access connections; interarrival times are not exponential; size of IP packet varies and cannot be approximated by exponential distribution. Question? how to analyze GI/G/1 queuing system? Lecture: Discrete-event simulations 4

1.2. Simulations vs. analytic: queue example Analysis of a queue consists of: representation of the arrival process as a stochastic one; representation of service time as a stochastic process; analysis of a system!; getting conclusions. What is analysis part for simulations? simulation execution; data collection and analysis. What is analysis part for analytical approach? annoying math... Lecture: Discrete-event simulations 5

1.3. Advantages/shortcomings of simulations Advantages: does not require restrictive assumption or require less of them; model structure, algorithms and variables can be changed quickly; models of traffic and service times can be used as is just from measurements; may provide results which are not obtainable using analytical techniques. Shortcomings: time consuming, may take much more time that analytic; results may be inaccurate when time of analysis is not sufficient; validation of results take additional time; simulations may be of higher complexity than required; relationship between variables is hard to visualize and explain; sensitivity analysis is difficult. Lecture: Discrete-event simulations 6

1.4. Advantages/shortcomings of analytical analysis Advantages: results are straightforward (they are analytical in nature); exact (accurate) results are produced; allows optimization tasks; gives deep insights to the behavior of the system; relationship and inter-influence of variables are explainable; often analysis is fast (M/M/1 queue, for example). Shortcomings: often requires restrictive assumptions; sometimes very hard; often impossible at all. Lecture: Discrete-event simulations 7

2. Step-by-step simulations approach Define the problem Validate model Analyze data Design experiments Formulate submodels Run the simulator Combine submodels Collect the results Write the program Estimate statistics Debug Make conclusions Lecture: Discrete-event simulations 8

3. Classification: involved processes Based on the nature of involved stochastic processes: discrete-time discrete-state simulations; discrete-time continuous-state simulations; continuous-time discrete-state simulations; continuous-time continuous-state simulations. # of cust. in the system amount of fuel in the tank t t Figure 1: Continuous-time discrete-state and continuous-time continuous-state simulations. Lecture: Discrete-event simulations 9

4. Classification: time usage Continuous simulations: real time is used (note that computer time is discrete); time increments as fine as possible: to capture all state changes. Discrete simulations: system is observed at discrete times t 0, t 0 + t, t 0 + 2 t,.... Discrete event simulations: we focus on system changes only at event times; after processing the current event, the system clock is forwarded to another event simulation moves from the current system state to the event occurring next; event list holds all the future events. Lecture: Discrete-event simulations 10

Discrete-event t 0 t 1 t 3 Discrete t 0 t 1 t 2 t 3 t 4 t 5 Continuous t 0 t 1 t 2 t 3 t 4 t 5 t 6 t 7... Figure 2: Illustration of different types of simulations. Lecture: Discrete-event simulations 11

5. Simulation program Simulation program can be implemented using: general purpose programming languages: C: suitable for one purpose simulations; C++, Java, Python: suitable for writing multiple purposes simulations. +: very flexible languages; : there are no specific functions (GNU Scientific Library may help). simulation oriented programming languages: OPNET: general networks; OMNET++: ad hoc networks; ns2/ns3: general networks: +: include a plenty of models and scenarios; : sometimes not fast (incorporate a lot of functionality;) : sometimes limited to specific functionality; : one more language to learn. Lecture: Discrete-event simulations 12

6. Basics of discrete event simulation The basic idea: only events change the state of the system; there is no 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 evolving in time; includes many variables. 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: Discrete-event simulations 13

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 3: The idea of the event list. Events are identified by event time and event type. There are two types of events: basic events: they modify the system state: e.g. arrivals/departures of packets for a queue. additional events: these are events needed by additional tasks of simulation: run, stoppage, collection of data. Lecture: Discrete-event simulations 14

General algorithm: 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: Discrete-event simulations 15

6.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 4: Time advance techniques in discrete-event simulations. Lecture: Discrete-event simulations 16

7. Example: GI/G/1 queue Assume that we are given a queuing system: arrival process is renewal one; interarrival times are gamma distributed with mean E[A] and CDF A; service times are gamma distributed with mean E[D] and CDF D; there is only one server (link); the capacity of the system is infinite (there are infinitely many waiting positions). arrivals... inifnitely many waiting positions server Figure 5: Queuing system under consideration. Note: for the system to be stable we assume that ρ = E[D]/E[A] < 1. Lecture: Discrete-event simulations 17

What kind of analysis can we use? These are: first analytical approach consider GI/G/1 or G/G/1 system; only approximate results are available. another analytical approach: approximate interarrival and service times by mix of exponentials; analyze PH/PH/1 queuing system. one more analytical one: approximate by simpler distributions, e.g. exponential; most probably results will be incorrect. simulation approach: always possible; could be time-consuming, but it always works. Lecture: Discrete-event simulations 18

Simulation program for GI/G/1 queue consists of: initialization: system state N(0) = 0; generate time till the next arrival from distribution A. handling of arrival event: update the system state N(t) = N(t 0) + 1; generate time till the next arrival from distribution A. handling of departure event: update the system state N(t) = N(t 0) 1; if N(t) > 0 generate time till the next departure from service-time distribution D. stoppage: after every handling you may check the condition T > T max?. If yes: program is terminated; alternatively, you may handle program termination as an event. NOTE! Process {N(t), t > 0} for GI/G/1 is NOT Markov but who cares? Lecture: Discrete-event simulations 19

Here is the trace of data that may be obtained from simulation. N(t) time time Figure 6: Arrivals, departures and N(t) as a function of time. Lecture: Discrete-event simulations 20

Discrete-event simulation of G/G/1 queue INITIALIZATION time:=0; queue:=0; sum:=0; throughput:=0; generate first interarrival time; MAIN PROGRAM while time < runlength do case nextevent of arrival event: time:=arrivaltime; add customer to a queue; start new service if the service is idle; generate next interarrival time; departure event: time:=departuretime; throughput:=throughtput + 1; remove customer from a queue; if (queue not empty) sum:=sum + waiting time; start new service; OUTPUT mean waiting time = sum / throughput Lecture: Discrete-event simulations 21

Simulation of G/G/1 based on Lindley s eqn: W n+1 =max(w n +B n -A n,0) INITIALIZATION n:= 0; w:= 0; sum:= 0; MAIN PROGRAM while time < max do a:= new interarrival time; b:= new service time; w:= max(w+b-a,0); sum:= sum+w; n:= n+1; end OUTPUT mean waiting time = sum / n not always we have such a simple relation; may not suitable for other performance measures! Lecture: Discrete-event simulations 22

8. Event list design AKA 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. 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: number of events associated with the system; the way how this information is organized. Lecture: Discrete-event simulations 23

8.1. Operations over an event list What types of operations are performed over 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. There are two ways of organizing a list: using sequential array; using linked list; more complex structures. Lecture: Discrete-event simulations 24

8.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 7: Using sequential array as a future event list. Lecture: Discrete-event simulations 25

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: Discrete-event simulations 26

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: Discrete-event simulations 27

8.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 8: Using linked list as a future event list. Lecture: Discrete-event simulations 28

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 9: Usage of singly linked list in event advance discrete-event simulation. Lecture: Discrete-event simulations 29

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 10: Locating values in a singly linked list. Lecture: Discrete-event simulations 30

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 11: Deletion of elements in a singly linked list. Lecture: Discrete-event simulations 31

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 12: Deletion of elements in a singly linked list. Lecture: Discrete-event simulations 32

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 13: Insertion of elements in a singly linked list. Lecture: Discrete-event simulations 33

8.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: Discrete-event simulations 34

8.5. 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: Discrete-event simulations 35

8.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 14: Example of the doubly linked list. Lecture: Discrete-event simulations 36

9. 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 a way less popular design. t 0 t 1 t 2 t 3 t 4 t 5 Figure 15: Unit-time advance design of discrete-event simulations. Lecture: Discrete-event simulations 37

9.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 as they happen on random Another problem: some events may occur at the same time instant of the master clock. Figure 16: Certain events may occur in between two successive times of the master clock. Lecture: Discrete-event simulations 38

9.2. Trade-offs and rules-of-thumb Trade-offs: 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: Discrete-event simulations 39