Chapter 4: Simulation Designs

Slides:



Advertisements
Similar presentations
Modeling & Simulation. System Models and Simulation Framework for Modeling and Simulation The framework defines the entities and their Relationships that.
Advertisements

Data Structures: A Pseudocode Approach with C
Chapter 3: CPU Scheduling
Chapter 6: CPU Scheduling
+ Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time.
1 Simulation Implementation Using high-level languages.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
 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,
Simulation Examples And General Principles Part 2
LINKED LISTS.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
Lecture 6 of Computer Science II
Review Array Array Elements Accessing array elements
Chapter 4 Linked Structures.
Data Structures Using C++ 2E
Data Structures Using C, 2e
Queues.
Data Structure By Amee Trivedi.
CPU SCHEDULING.
Process concept.
Dan C. Marinescu Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.
CHP - 9 File Structures.
Data Structures Using C++ 2E
Memory Allocation The main memory must accommodate both:
Program based on queue & their operations for an application
Design & Analysis of Algorithm Priority Queue
Review Deleting an Element from a Linked List Deletion involves:
Operating Systems (CS 340 D)
MIS 215 Module 1 – Unordered Lists
Data Structure Dr. Mohamed Khafagy.
UNIT-3 LINKED LIST.
Lectures Queues Chapter 8 of textbook 1. Concepts of queue
Data Structures Interview / VIVA Questions and Answers
Data Structures Using C++ 2E
Operating Systems (CS 340 D)
Introduction to Data Structure
LINKED LISTS CSCD Linked Lists.
Chapter 6: CPU Scheduling
Introduction to Linked Lists
CMSC 341 Lecture 10 B-Trees Based on slides from Dr. Katherine Gibson.
Process Scheduling B.Ramamurthy 11/18/2018.
Arrays and Linked Lists
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
More Explanation of an example in chapter4
Further Data Structures
Linked Lists.
3: CPU Scheduling Basic Concepts Scheduling Criteria
Process Scheduling B.Ramamurthy 12/5/2018.
Chapter5: CPU Scheduling
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
CPU SCHEDULING.
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
Chapter 17: Linked Lists.
Chapter 5: CPU Scheduling
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 4/11/2019.
Queueing Theory Chapter 1
Process Scheduling B.Ramamurthy 4/7/2019.
Uniprocessor scheduling
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Data Structures & Algorithms
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
CSCS-200 Data Structure and Algorithms
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Presentation transcript:

Chapter 4: Simulation Designs COE 755: Queuing Theory Dr. Wissam Fawaz Safaa El Hajj

Introduction Event Based Design Activity Based Design Event-Advance Unit-Time Advance three different designs for building simulation models Event based designs utilize different ways of advancing the time The event-advance design is probably the most popular simulation design

I- Event Advance Design The status of the system changes each time an event occurs Moves through time by simply visiting the time instances at which events occur  so it is event- advance design status of the system changes each time an event occurs - between two successive events, the system's status remains Unchanged each event is associated with a clock - The value of this clock gives the time instance in the future that this event will occur.

I- Event Advance (Cont’d) - For instance, the occurrence of an arrival at the repairman's queue may trigger off the creation of a departure event if this arrival occurs at a time when the repairman is idle. Such triggered events are known as conditional events. - The basic approach of the event-based design is shown in the flow chart in figure 4.1.

I- Event Advance (Cont’d) Future Event List The collection of all events scheduled to occur in the future Save Operations Time Occurrence (CLK) Locate next event time and type - However, when simulating complex systems, the number of events may be very large. In such cases, finding the next event might require more than a few comparisons. algorithm for finding the next event Store information in a list where these operations can be efficiently executed Delete an event after it is occurred Type of Event Inserting newly scheduled events

I- Event Advance (Cont’d) Future Event List 1) Sequential Arrays Event occurrence Event type type1 type2 type3 … type n Find the minimum in the list : it is the next event

I- Event Advance (Cont’d) Future Event List 1) Sequential Arrays Min CLK - Locating the smallest number in an array does not take much time if the array is small. However, if the array is large, it becomes time consuming. Event type

I- Event Advance (Cont’d) Future Event List 1) Sequential Arrays Deletion : Event is not deleted from the array after it has occurred clock can be set to a very large value Insertion: Newly-scheduled event j is inserted in the list Simply updating its clock given by A(j) + Insertion and deletion Constant time O(1) - Locating next event: minimum depends on the size of array O(n)

I- Event Advance (Cont’d) Future Event List 2) Linked List Singly Linked List Ascending order Node Link One link : singly linked list Operations: a. Organize information such as data elements and pointers into a node. b. Access a node through the means of a pointer. c. Create a new node(s) or delete an existing unused node(s). d. Add a node to the linked list. e. Remove a node from the linked list. Event type

I- Event Advance (Cont’d) Future Event List 2) Linked Lists Create Node: CLK, Type and next node dynamically allocated each time a new event is created Create List: nodes should form an ordered list Insert node : Head is null : this node is the new head Insert between two nodes All codes and functions and codes

I- Event Advance (Cont’d) Future Event List 2) Linked Lists Remove node: just remove the Head of the list. Easy to delete an event, jut remove the head

I- Event Advance (Cont’d) Future Event List 2) Linked Lists + Locating next event Constant time O(1) + Dynamic allocation of memory - Insertion depends on the size of List O(n) - Can only be traversed in one direction - Searching a linked list might be time consuming if n is very large. In this case, one can employ better searching procedures. - Dynamic allocation, Thus, we no longer need contiguous memory locations and data can be dynamically added at runtime

I- Event Advance (Cont’d) Future Event List 2) Linked Lists Doubly Linked List Pointer to Previous node Pointer to Next node

II- Unit-Time Advance The master clock can be advanced in fixed increments of time Each increment being equal to one unit of time Compare all the future event clocks against the master clock Sequential Array -In the event-advance simulation, the master clock is advanced from event to event Here: the master clock can be advanced in fixed increments of time, each increment being equal to one unit of time

II- Unit-Time Advance (Cont’d) - Instead of a future clock with respect to the origin, the future clock is a duration of the service

II- Unit-Time Advance (Cont’d) - ST service time AT interarrival time - Alternatively, a future clock can simply reflect the duration of a particular activity. For instances, in the machine interference problem, the departure clock will simply contain the duration of a service, rather than the future time at which the service will be completed - Each time the master clock is advanced by a unit of time, the value of each future clock is decreased by a unit time. If any of these clocks becomes equal to zero, then the associated event has occurred and appropriate action has to take place.

II- Unit-Time Advance (Cont’d) Select the Unit Time When all future event clocks are integer variables each event clock is simply a multiple of the unit time Frequently, future event clocks are represented by real variables event may occur in between two successive time instants of the master clock

II- Unit-Time Advance (Cont’d) Select the Unit Time Choose the unit time carefully! small that at most one event occurs during unit time not too small, most of the time system is non-productive Another complication that might arise is due to the possibility of having multiple events occurring during the same unit of time. if it is too small, the simulation program will spend most of its time in non-productive mode, i.e. advancing the master clock and checking whether an event has occurred or not.

II- Unit-Time Advance Designs (Cont’d) Select the Unit Time Heuristic and Analytic methods Setting the unit time equal to one-half of the smallest variate generated several simulation runs, each with a different unit time one can start with a small unit time. Then, it can be slightly increased

Event-advance vs. unit-time advance Many events which occur at times close to each other Event-advance Few events that are far apart from each other The worst case for the unit-time advance method is when there are few events and they are far apart from each other. In this case, the unit-time advance design will spend a 94 Computer Simulation Techniques lot of non-productive time simply advancing the time and checking if an event has occurred. In such cases, the event-advance design is obviously preferable.

III- Activity-Based Design System modelled is viewed as a collection of activities or processes Queueing system Example: inter arriving being served waiting for service activity based rather than event based - In an activity based design, one mainly concentrates on the set of conditions that determine when activities start or stop

III- Activity-Based Design (Cont’d) 1. The (i+1)st arrival occurs during the time that the ith arrival is waiting. 2. The (i+1)st arrival occurs when the ith arrival is in service 3. The (i+1)st arrival occurs after the ith arrival has departed from the queue

III- Activity-Based Design (Cont’d) TWi+1 = WTi +STi TW = waiting + service times of previous request TWi is the total waiting time in the system of customer i

Round-Robin Queue - Since the user never becomes idle, it continuously cycles through a think time and a CPU time - a) arrival of a request at the CPU queue, and b) service completion at the CPU

Round-Robin Queue (Cont’d) Event-Advance + Unit-time Advance designs New arrivals at the CPU queue event time - List 1: The event time simply shows the time at which the user will stop thinking and will access the CPU - List 2: Each node contains the number of quanta required by a request and its terminal identification number. CPU queue Required quanta

Round-Robin Queue (Cont’d) The simulation model operates under the unit-time advance design during the period of time that the CPU is busy. During the time that CPU is idle, the simulation model switches to an event-advance design. Note that tarr gives the time of the next new arrival at the CPU queue. The remaining details of this program.