Dept. Computer Science, Tianjin Uni. 系统仿真 System Simulation 2008.

Slides:



Advertisements
Similar presentations
Introduction into Simulation Basic Simulation Modeling.
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.
 1  Outline  performance measures for a single-server station  discrete-event simulation  hand simulation  process-oriented simulation approach.
(Monté Carlo) Simulation
Agenda Main concepts in discrete-event simulation
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.
Simulation. Example: A Bank Simulator We are given: –The number of tellers –The arrival time of each customer –The amount of time each customer requires.
1 6.3 Binary Heap - Other Heap Operations There is no way to find any particular key without a linear scan through the entire heap. However, if we know.
COSC2006 Chapter 8 Queues III
DISCRETE-EVENT SIMULATION CONCEPTS and EVENT SCHEDULING ALGORITHM
Components and Organization of Discrete-event Simulation Model
Simulation.
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.
Introduction to Simulation. What is simulation? A simulation is the imitation of the operation of a real-world system over time. It involves the generation.
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.
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
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 Management Science
(C) 2009 J. M. Garrido1 Object Oriented Simulation with Java.
Simulation Examples ~ By Hand ~ Using Excel
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 System Performance and Models. 2 Systems and Models The concept of modeling in the study of the dynamic behavior of simple system is be able.
Structure of a Waiting Line System Queuing theory is the study of waiting lines Four characteristics of a queuing system: –The manner in which customers.
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.
Data Structures Using C++ 2E Chapter 8 Queues. Data Structures Using C++ 2E2 Objectives Learn about queues Examine various queue operations Learn how.
Chapter 2 – Fundamental Simulation ConceptsSlide 1 of 46 Chapter 2 Fundamental Simulation Concepts.
Data Structures Using Java1 Chapter 7 Queues. Data Structures Using Java2 Chapter Objectives Learn about queues Examine various queue operations Learn.
SIMULATION OF A SINGLE-SERVER QUEUEING SYSTEM
OPERATING SYSTEMS CS 3530 Summer 2014 Systems with Multi-programming Chapter 4.
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
1 CMPSCI 187 Computer Science 187 Introduction to Introduction to Programming with Data Structures Lecture 13: Queues Announcements.
Chapter 3 System Performance and Models Introduction A system is the part of the real world under study. Composed of a set of entities interacting.
MODELING EXAMPLES Types of model Conceptual Containing components that have not been clearly Identified in terms of theoretic categories such as state,
Stevenson and Ozgur First Edition Introduction to Management Science with Spreadsheets McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies,
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.
SIMULATION EXAMPLES. Monte-Carlo (Static) Simulation Estimating profit on a sale promotion Estimating profit on a sale promotion Estimating profit on.
 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,
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
Discrete-Event System Simulation in Java. Discrete Event Systems New dynamic systems New dynamic systems Computer and communication networks Computer.
One More Try Another Example with Some Tweaks. Fall 2001IMSE 643 Industrial Simulation Two Job Types and a second Workstation Machine Inspection Arrivals.
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
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
Data Structures Using C++ 2E
Modeling and Simulation (An Introduction)
Discrete Event Simulation
Modeling and Simulation CS 313
Chapter 10 Verification and Validation of Simulation Models
Lecture 2 Part 3 CPU Scheduling
Concepts In Discrete-Event Simulation
Discrete Event “Hand” Simulation of a GI/GI/1 Queue
Presentation transcript:

Dept. Computer Science, Tianjin Uni. 系统仿真 System Simulation 2008

What’s simulation A simulation is The imitation of the operation of a real-world process or system over time. A technique, whereby a model of a system, is run in compressed time, to perform experimentation for analyzing system performance. Whether done by hand or on a computer, simulation involves the generation of an artificial history of a system, and the observation of that artificial history to draw inferences concerning the operating characteristics of the real system.

Discrete system simulation

Simulation Category General-purpose programming languages FORTRAN, C, C++ “ build your own, use someone else ’ s “ Simulation programming languages ns-2, QualNet/GloMoSim, Opnet, RTSS GPSS/H, SIMAN V Simulation technology Time-driven simulation  They work on a strictly unit-time basis  automatically scanning thousands of fixed time units to discover the next significant change Event-driven simulation  automatically skip to the next known event  saving execute-time

Use Queuing models to Describe the behavior of queuing systems Evaluate system performance Model Queuing System Queuing System Queue Server Customers

Time Arrival event Delay Begin service Arrival event Delay Activity End service Customer n+1 Customer n Interarrival

example Single-server queue simulation Mean Interarrival time 4.5 Mean Service Time 3.2 Standard Deviation of Service Times 0.6 Number of Customers served 1000 Server Utilization Maximum Line Length 9 Average Response Time Proportion who Spend Four Minutes or More in System Simulation RunLength Number of Departures 1000

RTSS Simulator -- A model contains two parts First, a set of processors The simulation software stores the processor parameters, such as service rate etc., in a set of arrays – “the processor table”. Each processor has his own queue to store waiting jobs. Second, the characterization of the workload (i.e. jobs) The job parameters, such as job arriving time, job length of a job etc., are stored in a set of arrays - ”the job table”. The job parameters can be either deterministic or probabilistic.

RTSS Simulator

events All events can be divided into three types Type 1 marks the arrival of a job in the system Type 2 corresponds to a job’s entering a server Type 3 corresponds to a job’s exiting from a server The event service routines are the arrival routine, the incoming routine and the outgoing routine There is an event list to drive the simulation process Each event has 3 elements in the event list One element is an event identifier which is used for identifying the event type. The second element is the event time The third element is a pointer to the job table

control routine The control routine is the heart of the simulator, its loop is executed once for each event handled At the start of each loop, the control routine selects the earliest event in the event list calls the corresponding event service routine advances the simulation clock to the event time, removes the event from the event list The event service routine performs the required processing for the job determines its next event, calculates the event time and inserts the next event in the event list returns control to the control routine

arrival routine the arrival routine corresponds to event type 1, and does the following things: 1. The next event (type 2) for the arriving job is inserted in the event list. 2. If the arriving job belongs to a job sequence and it is not the last job of the sequence, a new job of the sequence is generated and inserted in the job table. 3. The event (type 1) for the new job is inserted in the event list. Random-variant generators Routines to generate samples from desired probability distributions

incoming routine The incoming routine corresponds to event type 2, and simulates a job entering a processor; it does the following things: 1. If the processor is busy, the input job enters a processor queue. 2. If the processor is not busy, it serves the input job. The next event (type 3) to occur for the input job is inserted in the event list. 3. The states of the job and processor are updated Random-variant generators Routines to generate samples from desired probability distributions

outgoing routine The outgoing routine corresponds to event type 3, and simulates a job exiting from a processor; it does the following things: 1. The processor is released by the output job, 2. Then, the queue of the released processor is examined; if there are jobs waiting, the one which has the highest priority is selected from the queue and scheduled to be served

report routine A group of variables describes the simulator state when the simulation clock is advanced by the occurrence of a series of events. The report routine records these variables, so that analysis and statistic programs give the final simulation result.

Simulation in C++ Main program Provides overall control of the event- scheduling algorithm Clock  A variable defining simulated time Initialization subroutine A routine to define the system state at time 0 Min-time event subroutine A routine that identifies the imminent event, FEL

Simulation in C++ Event subroutines For each event type, a subroutine to update system state (and cumulative statistics) when that event occurs Random-variant generators Routines to generate samples from desired probability distributions Report generator A routine that computers summary statistics from cumulative statistics and prints a report at the end of the simulation

example Single-server queue simulation

Definitions tab. 4.6, p. 108 Variables System state  QueueLength  NumberInService Entity attributes and sets  Customers

Variables(cont’d) Future event list  FutureEventList Activity duration  Service time

Variables(cont’d) Input Parameters  MeanInterarrivalTime  MeanServiceTime  SIGMA, Standard deviation of service time  TotalCustomers, stopping criteria

Variables(cont’d) Simulation variables  Clock Statistical Accumulators  LastEventTime  TotalBusy  MaxQueueLength

Statistical Accumulators  SumResponseTime  NumberOfDepartures  LongService, Number of customers who spend 4 or more minutes

Variables(cont’d) Summary statistics RHO = BusyTime/Clock AVGR : average response time PC4 : Proportion of customers who spend 4 or more minutes at the checkout counter

Functions exponential ( mu ) normal ( xmu, SIGMA )

Subroutines Initialization ProcessArrival ProcessDeparture ReportGeneration

Class Event{ Friend bool operator < (const Event& e1, const Event& e2); Friend bool operator == (const Event& e1, const Event& e2); public: Event(){}; enum EvtType { arrival, departure };

Event ( EvtType type, double etime) : _type(type), _etime(etime){}; EvtType get_type() { return _type;} double get_time() { return _etime;} protected: EvtType _type; double _etime; };

…… priority_queue FutureEventList Queue Customers

Main( int argc, char* argv[ ] ){ MeanInterArrivalTime = 4.5 …… Long seed = atoi ( argv[1] ); SetSeed(seed); Initialization();

While ( NumberOfDeparture < TotalCustomers ){ Event evt = FutureEventList.top(); FutureEventList.pop(); Clock = evt.get_time(); If ( evt.get_type() == Event::arrival ) ProcessArrival ( evt ); Else ProcessDeparture ( evt ); } ReportGeneration();}

Void Initialization (){ Clock = 0; QueueLength = 0; …… Event evt( Event::arrival, exponential ( MeanInterArrivalTime ) ); FutureEventList.push ( evt ); }

Void ProcessArrival( Event evt ){ Customer.push ( evt ); QueueLength ++; If ( NumberInService == 0 ) ScheduleDeparture (); Else TotalBusy += ( Clock – LastEventTime ); If ( MaxQueueLength < QueueLength ) MaxQueueLength = QueueLength;

Event next_arrival ( Event::arrival, Clock + exponential ( MeanInterArrivalTime ) ); FutureEventList.push ( next_arrival ); LastEventTime = Clock; }

Void scheduleDeparture () { double ServiceTime; while( ( ServiceTime = normal ( MeanServiceTime, SIGMA )) < 0 ); Event depart ( Event::departure, Clock + ServiceTime ); FutureEventList.push ( depart ); NumberInservice = 1; QueueLength --; }

Void ProcessDeparture ( Evevt evt) { Event finished = Customers.front (); Customers.pop (); if ( QueueLength ) ScheduleDeparture (); else NumberInService = 0;

double response = Clock – finished.get_time (); SumResponseTime + = response; …… NumberOfDepartures ++; LastEventTime = Clock; }

Void ReportGeneration (){ double RHO = TotalBusy/Clock; double AVGR = SumResponseTime/ TotalCustomers; double PC4 = ((double)LongService)/ TotalCustomers; …… }

Mean Interarrival time 4.5 Mean Service Time 3.2 Standard Deviation of Service Times 0.6 Number of Customers served 1000 Server Utilization Maximum Line Length 9 Average Response Time 6.739

Proportion who Spend Four Minutes or More in System Simulation RunLength Number of Departures 1000