+ simulation design. + types event-advance and unit-time advance. both these designs are event-based...

34
+ Simulation Design

Upload: jeffrey-bryan

Post on 02-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+

Simulation Design

Page 2: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Types

event-advance and

unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

The third design is activity- based.

Page 3: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Event-advance design

Described in previous weeks

Briefly The basic idea behind this design is that the status of the system

changes each time an event occurs. During the time that elapses between two successive events, the system's status remains unchanged.

it suffices to monitor the changes in the system's status. In order to implement this idea, each event is associated with a

clock. The value of this clock gives the time instance in the future that

this event will occur. upon completion of processing an event, say at time t1, regroups

all the possible events that will occur in the future and finds the one with the smallest clock value.

Page 4: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Cont.

The simulation model, therefore, moves through time by simply visiting the time instances at which events occur.

In the machine interference problem, Two Type of event

the event of an arrival at the repairman's queue, and the event of a departure from the repairman's

queue. primary events. Quite often the occurrence of a primary event may trigger

off the creation of a new event.

Page 5: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Basic Approach

Page 6: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Future event list Let us assume that a simulation model is currently at time t.

The collection of all events scheduled to occur in the future, i.e., events with clock greater than t, is known as the future event list.

For instance, in the case of the machine interference problem there were only two: an arrival to the repairman's queue and a service-ending (departure) event.

Naturally, it is important to have an efficient algorithm for finding the next event since this operation may well account for a large percentage of the total computations involved in a simulation program

Page 7: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Propertıes of Event List

Page 8: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Sequential arrays all future event times are stored sequentially in an

array. The simplest way to implement this, is to associate each event type with an integer number i.

The advantage of storing an

event list in a sequential array is

that insertions of new events

and deletions of caused events

can be done very easily

Page 9: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Linked lists Node

Link next data element of node

each node will consist of two data elements, namely a clock CLi showing the future time of an event, and a value i indicating the type of event. The nodes are arranged in an ascending order so that CLi ≤ CLj ≤ . . . ≤ CLn.

Page 10: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Implementation of a future event list as a linked list

Page 11: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Creating and deleting nodes

the structure can contain other

satellite data which may be specific

to each event.

Page 12: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Deletion of a node

Page 13: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Creating linked lists, inserting and removing nodes

The node can then be inserted into the list in an appropriate position such that the nodes are ordered according to a specified field.

Page 14: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Case 1 head is NULL

Page 15: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Case 2: head->clock > newNodePtr->clock

Page 16: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Case 3: Insertion between head and last node of the list

Page 17: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Removing a node from the linked list

The linked list is always maintained in an ascending order of the clock value. Therefore, the next event to occur is the first node of the linked list.

Page 18: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Time complexity of linked lists

Insert / Remove In order to insert a node in the linked list we have to

traverse the linked list and compare each node until we find the correct insertion position

The maximum number of nodes compared in the worst case will be the total number of nodes in the list. Thus the complexity of the insert operation is linear on n.

Searching a linked list might be time consuming if n is very large. In this case, one can employ better searching procedures. For example, a simple solution is to maintain a pointer B to a node which is in the middle of the linked list.

Page 19: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Doubly linked lists

Page 20: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Unit-time advance design

the master clock can be advanced in fixed increments of time, each increment being equal to one unit of time.

Each time the master clock is advanced by a unit time, all future event clocks are compared with the current value of the master clock.

If no clock is equal to the current value of the master clock, then no event has occurred and no action has to take place. In either case, the master clock is again increased by unit time and the cycle is repeated. This mode of advancing the simulation through time

Page 21: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+

Page 22: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Alternative Future Clock

future event clock is a variable which, as in the case of the vent-advance design, contains a future time with respect to the origin

Alternatively, a future clock can simply reflect the duration of a particular activity.

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.

Page 23: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+

Page 24: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Selecting a unit time

The unit time is readily obtained in the case where all future event clocks are represented by integer variables

For, each event clock is simply a multiple of the unit time.

frequently future event clocks are represented by real variables.

Page 25: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Complications

This introduces inaccuracies when estimating time parameters related to the occurrence of events.

Another complication that might arise is due to the possibility of having multiple events occurring during the same unit of time.

In general, a unit time should be small enough so that at most one event occurs during the period of a unit of time

However, 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.

simple heuristic rule such as setting the unit time equal to one-half of the smallest variate generated.

Page 26: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Cont.

For instance, one can start with a small unit time. Then, it can be slightly increased. If it is found to have no effect on the computed results, then it can be further increased, and so on.

Page 27: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Implementation

The main operation related to the processing of the future event list is to compare all the future event clocks against the master clock each time the master clock is increased by a unit time. An implementation using a sequential.

Page 28: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Event-advance vs. unit-time advance

where there are many events which occur at times close to each other

The best case, in fact, would occur when the events are about a unit time 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.

??

Page 29: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Activity-based simulation design

he system modelled is viewed as a collection of activities or processes.

a single server queueing system can be seen as a collection of the following activities: a) inter arriving, b) being served, and c) waiting for service

In an activity based design, one mainly concentrates on the set of conditions that determine when activities start or stop.

This design is useful when simulating systems with complex interactive processing patterns, sometimes referred to as machine-oriented models.

Page 30: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Example Single server Queue in the simulation model of the single server queue, an

arrival or a departure will change the status of the system STi the service Wti the waiting time of arrival ATi+1 be the interarrival time between the ith and (i+1)st

arrival assume that the ith arrival occurs at time ai, starts its

service at time si and ends its service at time si + STi,

Page 31: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Cont. assume that we know the waiting time WTi and the

service time STi of the ith customer Let ATi+1 be the inter-arrival time of the (i+1)st custom The (i+1)st arrival occurs during the time that the ith

arrival is waiting. The (i+1)st arrival occurs when the ith arrival is in service The (i+1)st arrival occurs after the ith arrival has departed

from the queue

For each of these three cases, the waiting time WTi+1 of the (i+1)st customer can be easily determined as follows:

TWi is the total waiting time in the system of customer i.

Page 32: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+

Having calculated WTi+1, we generate a service time STi+1 for the (i+1)st arrival, and an inter-arrival time ATi+2 for the (i+2)nd arrival.

The waiting time of the (i+2)nd arival can be obtained using the above expressions.

Page 33: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+

Page 34: + Simulation Design. + Types event-advance and unit-time advance. Both these designs are event-based but utilize different ways of advancing the time

+Examples ??

An inventory system

A round-robin queue