Simulation Based on Law & Kelton, Simulation Modeling & Analysis, McGraw-Hill.

Slides:



Advertisements
Similar presentations
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. A PowerPoint Presentation Package to Accompany Applied Statistics.
Advertisements

Based on Law & Kelton, Simulation Modeling & Analysis, McGraw-Hill
Introduction into Simulation Basic Simulation Modeling.
1 CNPA B Nasser S. Abouzakhar Queuing Disciplines Week 8 – Lecture 2 16 th November, 2009.
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.
Event-drive SimulationCS-2303, C-Term Project #3 – Event-driven Simulation CS-2303 System Programming Concepts (Slides include materials from The.
Based on Law & Kelton, Simulation Modeling & Analysis, McGraw-Hill
Introduction to stochastic process
Simulation Where real stuff starts. ToC 1.What, transience, stationarity 2.How, discrete event, recurrence 3.Accuracy of output 4.Monte Carlo 5.Random.
Classification of Simulation Models
#11 QUEUEING THEORY Systems Fall 2000 Instructor: Peter M. Hahn
Performance Analysis and Monitoring Facilities in CPN Tools Tutorial CPN’05 October 25, 2005 Lisa Wells.
Discrete Event Simulation How to generate RV according to a specified distribution? geometric Poisson etc. Example of a DEVS: repair problem.
Components and Organization of Discrete-event Simulation Model
Simulation.
1 Validation and Verification of Simulation Models.
Simulating Single server queuing models. Consider the following sequence of activities that each customer undergoes: 1.Customer arrives 2.Customer waits.
7/3/2015© 2007 Raymond P. Jefferis III1 Queuing Systems.
CPSC 531: DES Overview1 CPSC 531:Discrete-Event Simulation Instructor: Anirban Mahanti Office: ICT Class Location:
Lab 01 Fundamentals SE 405 Discrete Event Simulation
Graduate Program in Engineering and Technology Management
Analysis of Simulation Results Andy Wang CIS Computer Systems Performance Analysis.
Simulation Output Analysis
Simulation II IE 2030 Lecture 18. Outline: Simulation II Advanced simulation demo Review of concepts from Simulation I How to perform a simulation –concepts:
1 Performance Evaluation of Computer Networks: Part II Objectives r Simulation Modeling r Classification of Simulation Modeling r Discrete-Event Simulation.
The Poisson Process. A stochastic process { N ( t ), t ≥ 0} is said to be a counting process if N ( t ) represents the total number of “events” that occur.
Capacity analysis of complex materials handling systems.
Verification & Validation
Continuous Probability Distributions  Continuous Random Variable  A random variable whose space (set of possible values) is an entire interval of numbers.
ETM 607 – Discrete Event Simulation Fundamentals Define Discrete Event Simulation. Define concepts (entities, attributes, event list, etc…) Define “world-view”,
© 2003, Carla Ellis Simulation Techniques Overview Simulation environments emulation exec- driven sim trace- driven sim stochastic sim Workload parameters.
0 K. Salah 2. Review of Probability and Statistics Refs: Law & Kelton, Chapter 4.
Network Design and Analysis-----Wang Wenjie Queueing System IV: 1 © Graduate University, Chinese academy of Sciences. Network Design and Analysis Wang.
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.
Modeling and Analysis of Computer Networks
Fair Queueing. 2 First-Come-First Served (FIFO) Packets are transmitted in the order of their arrival Advantage: –Very simple to implement Disadvantage:
1 Chapters 8 Overview of Queuing Analysis. Chapter 8 Overview of Queuing Analysis 2 Projected vs. Actual Response Time.
Chapter 2 – Fundamental Simulation ConceptsSlide 1 of 46 Chapter 2 Fundamental Simulation Concepts.
Simulation Tutorial By Bing Wang Assistant professor, CSE Department, University of Connecticut Web site.
SIMULATION OF A SINGLE-SERVER QUEUEING SYSTEM
Discrete Event (time) Simulation. What is a simulation? “Simulation is the process of designing a model of a real system and conducting experiments with.
Simulation & Confidence Intervals COMP5416 Advanced Network Technologies.
Chapter 2 Fundamental Simulation Concepts
Network Simulation Motivation: r learn fundamentals of evaluating network performance via simulation Overview: r fundamentals of discrete event simulation.
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.
Discrete Event Simulation
Dr. Anis Koubâa CS433 Modeling and Simulation
Network Performance modelling 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.
1 Queuing Delay and Queuing Analysis. RECALL: Delays in Packet Switched (e.g. IP) Networks End-to-end delay (simplified) = End-to-end delay (simplified)
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.
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,
MODELING AND SIMULATION CS 313 Simulation Examples 1.
Simulation Examples And General Principles Part 2
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.
Prepared by Lloyd R. Jaisingh
Modeling and Simulation (An Introduction)
Discrete Event Simulation
Modeling and Simulation CS 313
MECH 3550 : Simulation & Visualization
CSE 550 Computer Network Design
Where real stuff starts
Berlin Chen Department of Computer Science & Information Engineering
Presentation transcript:

Simulation Based on Law & Kelton, Simulation Modeling & Analysis, McGraw-Hill

Why Simulation? Test design when cannot analyze –System too complex –Can analyze only for certain cases (Poisson arrivals, very large N, etc.) Verify analysis Fast production of results

Simulation types Static vs. dynamic Deterministic vs. stochastic Continuous vs. discrete –Simulation model  system model

Discrete Event System Discrete system –The system state can change only in a countable number of points in time! –Event = an instantaneous change in state. Example: a queueing system –System state: Number of customer –At each time number of customer can only change by an integer

Continuous Simulation Simulating the flight of a rocket in the air –System state: rocket position and weight –State changes continuously in time (according to a partial differential equation)

Components of a discrete-event simulation model System state: the collection of state variables necessary to describe the system at a particular time. Simulation clock: a variable giving the current value of simulated time Event list: a list containing the next time when each type of event will occur. Statistical counters: variables used for storing statistical information about system performance –How many moments?

Components of a discrete-event simulation model (2) Initialization routine: a subprogram to initialize the simulation model at time 0. Timing routine: a subprogram that determines the next event from the event list and then advances the simulation clock to the time when the event is to occur. Event routine: A subprogram that updates the system state when a particular type of event occurs (one routine per event).

Components of a discrete-event simulation model (3) Library routine: A set of subprograms used to generate random observations from probability distributions that were determined as part of the simulation model. Report generator: A subprogram that computes estimates (from the statistical counter) of the desired performance measures when simulation ends.

Components of a discrete-event simulation model (4) Main program: a subprogram that invokes the timing routine to determine the next event and then transfers control to the corresponding event routine to update the system state. May also check for termination and invoke the report generator.

Flow control Init Determine next event Event 1Event n Done? report no

Example a single server queuing system System to be simulated –A i Interarrival times are I.I.D. –S i Service time are I.I.D. –FIFO service –Work preserving Initial state –Empty and idle –First arrival after A i time units from time 0 Termination after n customers left queue.

Performance measures d(n) = expected average delay in queue. –Customer point of view q(n) = expected time-average number of customers in queue. –System point of view –Note: average over time which is continuous!! u(n) = proportion of time server is busy

No. of customers in queue t Q(t)

No. of customers in queue t Q(t)

Performance measures (2) Averages are not always enough. Register max/min values. Register the entire “pdf” –histograms

Initialization Set simulation time to 0. Set initial state: –Server idle –Queue empty –Last event time Init event list –Generate 1st arrival Zero stat counters –Total delay and number delayed –Area under Q(t) and B(t).

1 st Event: customer arrival After init finished the arrival event is selected and time is advanced to this event Change server from idle to busy Add 0 to total delay, increment No of delayed. Generate two events: –This customer departure –Next arrival (generate as you go) Add 0 to the area under Q(t). Add 0 to the area under B(t).

2 nd Event: customer arrival Arrival event is selected and time is advanced to this event Server busy => put customer in queue with arrival time Set “No. in queue” to 1. Generate next-arrival events (don’t mess with dep.) Add 0 to the area under Q(t). Add (t 2 -t 1 ) to the area under B(t).

Remarks While handling an event time is standing But, order of operation is still important: –First update area under Q(t) then update “No. in queue” Two events at the same time –Order may change simulation result!

Determining Events In complex systems events sequence may not be trivial. Use of event graph to aim us is designing the events

Event Graph States are bulbs, connected with arrows Bold arrow: event may occur after nonzero time. Thin arrow: event may occur immediately. arrival depar- ture

Alternative Event Graph This design is correct as well! One more event => more complexity Simplification rule: –If an event node has incoming arcs that are all thin and smooth, it can be eliminated. A strongly connected component that has no incoming arcs from other nodes must be initialized. arrival Enter service depar- ture

Take care GIGO = garbage in garbage out –Realistic scenarios (arrival process, service time) –Full cover of system behavior Statistical confidence What to model –Not enough details => hurts accuracy –Too many details => slows simulation Attempt to verify correctness –Simulate cases you can analyze

Random Generator Make sure you can regenerate your random sequence, or debugging is hell. For long simulations, use 32 bit pseudo random generator. 16 bit is too short!

Statistical Confidence Better a few short runs than one long one. However, make sure run time is long enough to make end conditions negligible. Given a set of IID random variables we can calculate the confidence interval.

Confidence Interval X 1, X 2, …X n are IID random variables with finite mean  and finite variance  2 >0. By central limit theorem F n (z)  (z) (the std. Normal r.v.) For sufficiently large n, approx. 100(1-  ) percent confidence interval for  is given by F n (z)=P(Z n  z) is Dist. Func. of Z n

Area: 1- 

Confidence Interval for Small n For small number of observations, we need to correct the coefficient of the interval width The smaller n the larger t n-1,1-  /2 is. t n-1,1-  /2 is taken from a table.

Confidence Interval In general all plots has to have a confidence interval on every mark Exception: high confidence (mark size)

A good pseudo random generator float myrand() { b32 = ( *b ); if (b32<0) b32 = -b32; return( * b32); }

Generating Non-Uniform Distributions F(x), the PDF, of any distribution is a function to [0,1], => use the inverse transform –Generate U~U(0,1) –Return X=F -1 (U) P(X  x) = P(F -1 (U)  x)=P(U  F(x))=F(x) Since U is U(0,1) and 0  F(x)  1, P(U  y) = y

Generating the Exponential distribution Note we can use -  ln(u).

Simulating complex systems Systems often have many identical components –A queueing system with multiple queues –A switch with multiple ports running a distributed algorithm Must keep state for each component –Array of structures in C, –multiple instances of the basic object (C++) Keep the connectivity (when applicable)

Wet Exercise No. 1 Assume a 100MHz output port. The port is fed from four input ports each with its own queue. For this exercise we neglect all other traffic. Packets arrive at the input ports with inter packet space that is Exponentially distributed with parameter  (such that the total load is 20:20:120 percent). Packet length is distributed according to Internet mix. Scheduling between Qs: smooth deficit round robin, quota=3000. Every 250mS we send two back-to-back packets to measure the link capacity e.g., according to the method in Run each simulation for 25 Sec. Hand-ins: –Code transcript –Histogram of the one-way inter packet delay for the packet pairs. –Plot a graph of the capacity estimation as a function of the load and measurement packet size (use 3-5 sizes).

Remarks Code has to work anywhere (not just at home), especially in TAU. Make it portable. Oral exams through the semester. Send code to –Specify development env. (Unix/Visual C/..) –One tar/zip file with makefile etc. –Header: “EX1 PCN: stu-name”