Discrete Event Simulation. Motive

Similar documents
CPU Scheduling. CPU Scheduler

Generating Random Variables

Discrete-event simulations

Generating Random Variates II and Examples

Divide-and-Conquer Algorithms Part Two

Design of discrete-event simulations

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

Scheduling I. Today Introduction to scheduling Classical algorithms. Next Time Advanced topics on scheduling

Scheduling I. Today. Next Time. ! Introduction to scheduling! Classical algorithms. ! Advanced topics on scheduling

λ λ λ In-class problems

CPU scheduling. CPU Scheduling

TDDB68 Concurrent programming and operating systems. Lecture: CPU Scheduling II

Priority queues implemented via heaps

Advanced topic: Space complexity

CS418 Operating Systems

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

Module 5: CPU Scheduling

Simulation of Process Scheduling Algorithms

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

Chapter 6: CPU Scheduling

Online Supplement to Creating Work Breaks From Available Idleness

Online Supplement to Creating Work Breaks From Available Idleness

Verification and Validation. CS1538: Introduction to Simulations

Discrete Event Simulation

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm

Computer Simulation Techniques: The definitive introduction!

ArcGIS Enterprise: What s New. Philip Heede Shannon Kalisky Melanie Summers Shreyas Shinde

Queuing Theory. The present section focuses on the standard vocabulary of Waiting Line Models.

CS 161: Design and Analysis of Algorithms

Introduction to Queueing Theory with Applications to Air Transportation Systems

IS 709/809: Computational Methods in IS Research Fall Exam Review

Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn

CSE 380 Computer Operating Systems

Session-Based Queueing Systems

Season Finale: Which one is better?

CHAPTER 5 - PROCESS SCHEDULING

Description of the ED library Basic Atoms

Complexity Theory Part I

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

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

COMP9334: Capacity Planning of Computer Systems and Networks

Exercises Solutions. Automation IEA, LTH. Chapter 2 Manufacturing and process systems. Chapter 5 Discrete manufacturing problems

Queueing Theory and Simulation. Introduction

On Two Class-Constrained Versions of the Multiple Knapsack Problem

Comp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 45

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

Problem Set 4 Solutions

CS5314 Randomized Algorithms. Lecture 15: Balls, Bins, Random Graphs (Hashing)

CSE613: Parallel Programming, Spring 2012 Date: May 11. Final Exam. ( 11:15 AM 1:45 PM : 150 Minutes )

Section 3.3: Discrete-Event Simulation Examples

Massachusetts Institute of Technology

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Ways to study a system System

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

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

TDDI04, K. Arvidsson, IDA, Linköpings universitet CPU Scheduling. Overview: CPU Scheduling. [SGG7] Chapter 5. Basic Concepts.

Chapter 10 Verification and Validation of Simulation Models. Banks, Carson, Nelson & Nicol Discrete-Event System Simulation

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

Exercises Stochastic Performance Modelling. Hamilton Institute, Summer 2010

CPU SCHEDULING RONG ZHENG

15 Closed production networks

MULTIPLE CHOICE QUESTIONS DECISION SCIENCE

INF2220: algorithms and data structures Series 1

/463 Algorithms - Fall 2013 Solution to Assignment 4

Mon Tue Wed Thurs Fri

The Greedy Method. Design and analysis of algorithms Cs The Greedy Method

Joint MISTRAL/CESI lunch workshop 15 th November 2017

Quiz Queue II. III. ( ) ( ) =1.3333

Introduction. An Introduction to Algorithms and Data Structures

ArcGIS Enterprise: What s New. Philip Heede Shannon Kalisky Melanie Summers Sam Williamson

Discrete Event Systems Exam

7. Queueing Systems. 8. Petri nets vs. State Automata

CS Data Structures and Algorithm Analysis

Dijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker

N/4 + N/2 + N = 2N 2.

EECS 150 Homework 8 Solutions Fall Problem 1: CLD2 Problem 8.2, showing BOTH methods (row matching and implication chart).

Integrated Electricity Demand and Price Forecasting

IOE 202: lectures 11 and 12 outline

CS 21 Decidability and Tractability Winter Solution Set 3

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

Process Scheduling. Process Scheduling. CPU and I/O Bursts. CPU - I/O Burst Cycle. Variations in Bursts. Histogram of CPU Burst Times

CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Nov 30. Final In-Class Exam. ( 7:05 PM 8:20 PM : 75 Minutes )

Calculation of Steady-State Probabilities of M/M Queues: Further Approaches. Queuing Theory and Applications (MA597)

Minimum Spanning Trees

COMP 182 Algorithmic Thinking. Algorithm Efficiency. Luay Nakhleh Computer Science Rice University

Timing Driven Power Gating in High-Level Synthesis

Binary Decision Diagrams and Symbolic Model Checking

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

TRANSPORT PHENOMENA AND UNIT OPERATIONS

Exam 1. March 12th, CS525 - Midterm Exam Solutions

PBW 654 Applied Statistics - I Urban Operations Research

Heaps and Priority Queues

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

Advanced Computer Networks Lecture 3. Models of Queuing

Comp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 40

Delay bounds (Simon S. Lam) 1

Knapsack and Scheduling Problems. The Greedy Method

Computer Systems Modelling

15 Closed production networks

QUEUING MODELS AND MARKOV PROCESSES

Transcription:

Discrete Event Simulation These slides are created by Dr. Yih Huang of George Mason University. Students registered in Dr. Huang's courses at GMU can make a single machine-readable copy and print a single copy of each slide for their own reference, so long as each slide contains the copyright statement, and GMU facilities are not used to produce paper copies. Permission for any other use, either in machinereadable or printed form, must be obtained from the author in writing. CS 656 1 Motive Many real-world systems are too difficult to analyze. For such systems, one can create a virtual reality where the system can be tested and its performance measured. How real should it be? A good simulator reproduces the essence of the timing behaviors of the system. More than that wastes processor cycles Less than that produces inaccurate results. CS 656 2 1

The Time Obviously, we need a clock in the simulation. However, this is not the system clock of the machine running the simulation. Image simulating on a single workstation a 1,000-router network connecting 5,000 hosts. It may take hours to simulate just 1 minute of activates of the entire network. We must create a virtual clock and arrange events in the simulated network accordingly CS 656 3 Simulating M/M/1 Customer Arrival (CA) events Event List (sorted by time) Service Completion (SC) events Next event, at time clock CA Dispatcher SC CA Event Processing SC Event Processing New events New events CS 656 4 2

Processing CA Events Generate an exponential random number E. Schedule the next CA event at time clock+e. Increase occupied_q_slot by 1. If server-busy == FALSE, then Generate an exponential random variable S. Schedule a Service Completion (SC) event at time clock+s. Decrease occupied_q_slot by 1. CS 656 5 Processing SC Events If occupied_q_slot > 0, then Generate an exponential random variable S. Schedule a SC event at time clock+s. Decrease occupied_q_slot by 1. Otherwise, set server-busy to FALSE. CS 656 6 3

Example Consider 4 customers whose arrival times are 1, 5, 6, and 8, and whose service times are 5, 3, 10, 1. Show the contents of the event list during the course of the simulation: Clock=0: (CA,1) As seen, the clock makes quatum jumps; hence the name discrete time simulation. CS 656 7 More Sophisticated Events At a minimum, an event contains a type and occurrence time. It may contain additional information. if customers arrive in batch (say, 3 customers arrive at the same time), then an CA event needs to contain the number of arriving customers. Some simulation packages give different names and use different APIs for more sophisticated events. In CSIM, for example, a mail is an event with user-defined extra information. CS 656 8 4

Maintaining The Event List Why the big deal? Sorted array/linked-list? Using it, you will be fired on spot. Heap (Priority Queue) O(log N) time event addition/removal, where N is the number of events in the list. Many other tree/heap variations. Calendar Queue O(1) time event addition/removal This is according to empirical studies, confirmed by experiences CS 656 9 The Calendar Queue --- Basic Idea One schedules an event on a desk calendar by writing it on the appropriate page, one page for each day. Events can be scheduled more than a year in advance if one writes the date besides each event. To find the next event, start from the page of today and search for the event with the smallest date. The calendar is made circular and used indefinitely. CS 656 10 5

Implementation Each page is a sorted linked list; list nodes are events with their occurrence times. The calendar is simply an array of pointers (to list nodes). The definition of a day is flexible. You can make a day N time units. The definition of a year is flexible. You can make a year M days. CS 656 11 Example 1 day = 5 time units, and 1 year = 8 days. Page 0 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 (SC, 122) (CA, 123) (CA, 130) (CA, 135.6) (CA, 106) (CA, 107.2) (SC, 108) (SC, 425) (CA, 111) (CA, 113.5) (SC, 157.5) CS 656 12 6

Adjustment of Calendar Size What happens when the number of events in the calendar is much smaller than the number of pages? What happens when the number of events in the calendar is much larger than the number of pages? CS 656 13 The solution is to allow the number of days Copy events onto another calendar whenever the # of events exceeds twice the # of days. The new calendar will have twice the days too. This occurs only with the enqueue operation (adding new event to the calendar). Copy events onto another calendar whenever the # of events is less than half the # of days. The new calendar will have only half the days too. This occurs only with the dequeue operation (finding and removing the next event). CS 656 14 7

Cost Analysis Isn t copying the entire calendar costly? Consider a calendar with N days and N events in it. The next N enqueues will not cause copying. The (N+1)-th enqueue will cause copying, with complexity O(N). Thus, the amortized cost of copying per enqueue operation is only O(1). By the same token, the amortized cost of copying per dequeue operation is also O(1). CS 656 15 Adjusting Day Length If the day length is much greater than the average separation of adjacent events, the events will be clustered in a small number of days near today and the rest will be empty. Consequence? If the day length is too small, most events will not be in the current year. Consequence? The length of a day is adjusted each time the event queue is copied to a new calendar. CS 656 16 8

How? Just find the next several events and calculate the average separation. This is where we cannot guarantee performance with proof. However, empirical studies show that the heuristic works extremely well. CS 656 17 A Special Case It may happen that the next event is N years away, forcing the dequeue operation to scan the entire calendar N times. What happens when N=10,000? Solution: If a dequeue operation cycles through all days of a year and fails to locate the next event, it must scan the entire calendar again, looking for the next event without regarding to the year. CS 656 18 9

Examples of Simulation Packages Csim: a set of extensions to the C language to enable (virtual) parallel processes and events handling. It is not only a library. The C runtime environment has to be modified too. Ns2: a combination of C++ and OTCL (object TCL) extensions. Use C++ in performance critical parts/modules Use a high-level script language, OCTL, to facilitate putting modules together Flexible and extensible. OPNET: a commercial simulation environment CS 656 19 10