Download presentation
Presentation is loading. Please wait.
1
Chapter 4: Simulation Designs
COE 755: Queuing Theory Dr. Wissam Fawaz Safaa El Hajj
2
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
3
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.
4
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.
5
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
6
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
7
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
8
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)
9
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
10
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
11
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
12
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
13
I- Event Advance (Cont’d)
Future Event List 2) Linked Lists Doubly Linked List Pointer to Previous node Pointer to Next node
14
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
15
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
16
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.
17
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
18
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.
19
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
20
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.
21
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
22
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
23
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
24
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
25
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
26
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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.