Discrete-Event System Simulation in Java. Discrete Event Systems New dynamic systems New dynamic systems Computer and communication networks Computer.

Slides:



Advertisements
Similar presentations
Introduction into Simulation Basic Simulation Modeling.
Advertisements

Parallel and Distributed Simulation
Chapter 3 General Principles
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.
INTRODUCTION TO SIMULATION
 1  Outline  performance measures for a single-server station  discrete-event simulation  hand simulation  process-oriented simulation approach.
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.
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.
Classification of Simulation Models
DISCRETE-EVENT SIMULATION CONCEPTS and EVENT SCHEDULING ALGORITHM
Components and Organization of Discrete-event Simulation Model
SIMULATION EXAMPLES. SELECTED SIMULATION EXAMPLES 4 Queuing systems (Dynamic System) 4 Inventory systems (Dynamic and Static) 4 Monte-Carlo simulation.
Copyright © 2005 Department of Computer Science CPSC 641 Winter Simulation Methodology Plan: –Introduce basics of simulation modeling –Define terminology.
Simulation Software and Simulation in Java. Simulation languages & software Simulation Model Development General Purpose Languages Simulation Programming.
Probabilistic Verification of Discrete Event Systems Håkan L. S. Younes.
Simulating Single server queuing models. Consider the following sequence of activities that each customer undergoes: 1.Customer arrives 2.Customer waits.
CPSC 531: DES Overview1 CPSC 531:Discrete-Event Simulation Instructor: Anirban Mahanti Office: ICT Class Location:
Lab 01 Fundamentals SE 405 Discrete Event Simulation
Basic Simulation Modeling II
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:
(C) 2009 J. M. Garrido1 Object Oriented Simulation with Java.
1 Performance Evaluation of Computer Networks: Part II Objectives r Simulation Modeling r Classification of Simulation Modeling r Discrete-Event Simulation.
Verification & Validation
Exponential and Chi-Square Random Variables
General Simulation Principles
Automata. Summary Deterministic Automata  Languages Stochastic Automata Other Automata Formalisms  Automata with input and output Protocol Representation.
ETM 607 – Discrete Event Simulation Fundamentals Define Discrete Event Simulation. Define concepts (entities, attributes, event list, etc…) Define “world-view”,
Chapter 3 General Principles Banks, Carson, Nelson & Nicol Discrete-Event System Simulation.
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.
+ Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time.
Dept. Computer Science, Tianjin Uni. 系统仿真 System Simulation 2008.
Chapter 2 – Fundamental Simulation ConceptsSlide 1 of 46 Chapter 2 Fundamental Simulation Concepts.
SIMULATION EXAMPLES QUEUEING SYSTEMS.
Interconnect simulation. Different levels for Evaluating an architecture Numerical models – Mathematic formulations to obtain performance characteristics.
NETW 707 Modeling and Simulation Amr El Mougy Maggie Mashaly.
1 Simulation Implementation Using high-level languages.
Chapter 2 Fundamental Simulation Concepts
MODELING EXAMPLES Types of model Conceptual Containing components that have not been clearly Identified in terms of theoretic categories such as state,
CONCURRENT SIMULATION: A TUTORIAL Christos G. Cassandras Dept. of Manufacturing Engineering Boston University Boston, MA Scope of.
Network Protocol Simulation: A look at Discrete Event Simulation Grant D. Lanterman 5/21/2004.
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.
CDA6530: Performance Models of Computers and Networks Chapter 8: Statistical Simulation ---- Discrete Event Simulation (DES) TexPoint fonts used in EMF.
SIMULATION EXAMPLES. Monte-Carlo (Static) Simulation Estimating profit on a sale promotion Estimating profit on a sale promotion Estimating profit on.
Chapter 2 Basic Simulation Modeling
ENM 307 Simulation Department of Industrial Engineering Anadolu University SPRING 2016 Chapter 1 Basic Simulation Modeling Onur Kaya END 201, Ext: 6439.
 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,
Chapter 3 General Principles Banks, Carson, Nelson & Nicol Discrete-Event System Simulation.
Unit 4 Simulation software. Introduction Software used to develop simulation models can be divided into 3 categories: – General-purpose programming languages:
Simulation Examples And General Principles Part 2
CDA6530: Performance Models of Computers and Networks Chapter 8: Statistical Simulation ---- Discrete Event Simulation (DES) TexPoint fonts used in EMF.
Ch 1: Simulation of Computer Networks. 1.1 Computer Networks and the Layering Concept Layering Concept Service Interface Protocol.
Modeling and Simulation
Chapter 1 What is Simulation?. Fall 2001 IMSE643 Industrial Simulation What’s Simulation? Simulation – A broad collection of methods and applications.
Discrete Event Simulation
Basic Simulation Modeling II
Simulation Carey Williamson Department of Computer Science
SIMULATION EXAMPLES QUEUEING SYSTEMS.
More Explanation of an example in chapter4
SIMULATION EXAMPLES QUEUEING SYSTEMS.
Discrete Event “Hand” Simulation of a GI/GI/1 Queue
Javad Ghaderi, Tianxiong Ji and R. Srikant
Carey Williamson Department of Computer Science University of Calgary
MECH 3550 : Simulation & Visualization
Chapter 4: Simulation Designs
SIMULATION EXAMPLES QUEUEING SYSTEMS.
Presentation transcript:

Discrete-Event System Simulation in Java

Discrete Event Systems New dynamic systems New dynamic systems Computer and communication networks Computer and communication networks Automated manufacturing systems Automated manufacturing systems Air traffic control systems Air traffic control systems … Operational rules designed by humans Operational rules designed by humans Laws of nature are inappropriate Laws of nature are inappropriate Dynamics characterized by asynchronous occurrences of discrete events Dynamics characterized by asynchronous occurrences of discrete events Hitting a keyboard key Hitting a keyboard key Sending a message packet Sending a message packet Equipment failure Equipment failure

Modeling Frameworks for Discrete Event Systems Automata Automata Petri Nets Petri Nets Markov Chains Markov Chains Queues Queues

Automata q r f (q, e ) = r Given Event sequence {e 1, e 2, …} Initial State q 0 We can determine the state sequence {q 0, f (q 0, e 1 ), f (f (q 0, e 1 ), e 2 ), …}

Stochastic Timed Automata

Example M/M/1/K M/M/1/K 0 1K d aa d … a aaa ddd STATE EVENTS V a,3 V d,2 V d,3 V d,1 V a,

Discrete Event System Simulation Concerns with modeling of a DES as it evolves over time by a representation in which the system variables change at discrete points on time Characteristics: time is a part of simulation (Dynamic) time is a part of simulation (Dynamic) contains random elements (Stochastic) contains random elements (Stochastic)

World Views for Model Development Event-scheduling approach Event-scheduling approach Concentrates of events and their effects on system state Concentrates of events and their effects on system state e.g. simulation in Java, hand-simulation e.g. simulation in Java, hand-simulation Process-interaction approach Process-interaction approach Concentrates on entities, and their life cycles Concentrates on entities, and their life cycles Life cycles consist of events, activities and delays Life cycles consist of events, activities and delays Activities might require resources that are limited. Activities might require resources that are limited. e.g. Arena e.g. Arena Activity-scanning approach Activity-scanning approach Concentrates on activities and conditions that allow them to begin Concentrates on activities and conditions that allow them to begin e.g. some simulation packages popular in UK and Europe e.g. some simulation packages popular in UK and Europe

Time Advance Advancing simulation time Fixed time advanceVariable time advance Advances the clock by one unit time & examines the conditions to decide whether any activities can begin (NOT EFFICIENT) Activity-scanning approach Advances the clock to the most imminent event time & examines the system state Event-scheduling Approach Process-interaction Approach

Event Scheduling Approach Step 0: Initialize STATE to q 0, simulation TIME to zero Populate the Scheduled Event List (SEL) with feasible events for q 0 while setting their scheduled event times as t e = v e,1 Reorder SEL based on a smallest-scheduled-time-first scheme. Step 1: Remove the first entry (e 1, t 1 ) from the SEL Step 2: Update simulation TIME by advancing it to the new event time t 1 Step 3: Update STATE according to the state transition function q ’=f (q, e 1 ) Step 4: Delete from the SEL any entries corresponding to infeasible events in the new state Step 5: Add to the SEL any feasible event which is not already scheduled (possibly including the triggering event removed in the first step). The scheduled event times are calculated by t e = TIME + v e Step 6: Reorder the updated SEL. Go to Step 1.

INITIALIZE STATE q TIME t SCHEDULED EVENT LIST e1e1 t1t1 e2e2 t2t2 :: UPDATE STATE q’ = f (q, e 1 ) UPDATE TIME t’ = t 1 q’ q t’ DELETE INFEASIBLE (e k, t k ) ADD NEW FEASIBLE (e k, t’ + v k ) AND REORDER q’t’ RANDOM VARIATE GENERATOR New Event Lifetime v k

Simulation in Java Common Components Clock : A variable defining simulated time Initialization Method: A method to define the system state at time 0 Min-time event method: A method that identifies the imminent event, the element of the SEL that has the smallest scheduled event time Event methods: For each event type, a method to update system state (and cumulative statistics) when that event occurs Random-variate generators: Methods to generate samples from desired probability distributions Main program: To maintain overall control of the event-scheduling algorithm Report generator: A method that computes summary statistics from cumulative statistics and prints a report at the end of the simulation

Event Scheduling Flow Chart

Stopping Criteria Simulation Run Length Fixed time Variable time Example: 2 weeks 1 year 1 shift Example: 1000 job completions 50 departures 4000 arrivals

Java Simulation of M/M/1

Main Program in Java public static void main(String argv[]) { Initialization(); //Loop until first "TotalCustomers" have departed while (NumberofDepartures < TotalCustomers) { Event evt = FutureEventList[0]; //get imminent event removefromFEL(); //be rid of it Clock = evt.get_time(); //advance in time if (evt.get_type() == arrival) ProcessArrival(); else ProcessDeparture(); } ReportGeneration(); }

Arrival Event Arrival event Update Statistics Increase number in the system Set service time & schedule departure Increase entity number in queue Make server busy Is server busy? NOYES L(t)=L(t)+1 Q(t)=Q(t)+1 B(t)=1 Schedule next arrival

Arrival Event public static void ProcessArrival() { //Update Statistical Accumulators updateStats(arrival); Entity newEntity = new Entity(Clock); //create a new entity if (NumberInService == 0)//if the server is idle { custinService = newEntity;//fetch the entity ScheduleDeparture(newEntity); //schedule its departure } else custQueue.Enqueue(newEntity); //add the new entity to the queue //schedule the next arrival Event next_arrival=new Event(arrival,Clock+exponential(stream,MeanInterArrivalTime)); addtoFEL(next_arrival); LastEventTime=Clock; }

Departure Event Departure event Decrease number in system Set service time & schedule departure for entity in service Make server idle Decrease number in queue Is queue empty? NOYES L(t)=L(t)-1 Q(t)=Q(t)-1 B(t)=0 Update Statistics

Departure Event public static void ProcessDeparture() { updateStats(departure); //update statistical accumulators //if there are customers in the queue then schedule // the departure of the next one QueueLength = custQueue.get_Count(); if (QueueLength > 0) { Entity newEntity = (Entity)custQueue.Dequeue(); ScheduleDeparture(newEntity); custinService = newEntity; } else { NumberInService = 0; custinService = null; } LastEventTime = Clock; }