Lecture 09 - Discrete System Simulation (1)
Lecture 09 - Discrete System Simulation (1)
Chapter 9
Discrete System Simulation
a l
ep
itn
1
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
1
Introduction
Event
Change in the state of the system
Discrete Systems
- Systems having discrete nature
- Can be of two types
1. Fixed time step – a timer or clock exists
2. Event-to-event (discrete event simulation) – the event
works as the clock i.e. self clocking
(figure 1.2, Law & Kelton, page 9)
a l
Clock time
ep
Number recorded time
itn
2
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
2
Introduction
Attributes
Properties of a given entity
Event notice
A record of an event to occur at the current or some
future time, along with any associated data
necessary to execute the event
Event list
A list of event notices for future events, ordered by
time of occurrence; also known as the future event
list (FEL)
Delay (conditional wait)
a l
A duration of time of unspecified indefinite length
ep
which is not known until it ends.
itn
3
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
3
Introduction
Duration of activity
- Deterministic (given exact duration)
- Statistical (random draw from specified set with equal
a l
probability of picking an element)
ep
- Functional (defined by a function of any kind)
itn
4
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
4
Introduction
a l
ep
itn
5
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
5
Fixed time-step vs. Next-event
Start
Start
t = t + dt
Find next potential event, and its time of occurrence
Find all events that occur, if any, during period (t, t + dt)
Let the event occur. Update the system state and clock
Let all these events occur. Update the system state
Extract its effect on statistics being gathered
Extract their effect on statistics being gathered
End of No
End of No simulation?
simulation?
l
Yes
a
Yes
Output desired statistics
ep
Output desired statistics
itn
Stop 6
Stop
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
6
Components of next-event time-advance approach
System state
The collection of state variables necessary to describe
the system at a particular time
Simulation clock
A variable giving the current value of simulated time
Event list
A list containing the next time when each type of
event will occur
Statistical counters
Variables used for storing statistical information about
system performance
a l
Initialization routine
ep
itn
A subprogram to init the simulation model at time 0 7
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
7
Components of next-event time-advance approach
Timing routine
A subprogram that determines the next event from the
event list and then advances the simulation clock to
the time when that event is to occur
Event routine
A subprogram that updates the system state when a
particular type of event occurs i.e. one event
routine for each event type
Library routines
A set of subprograms used to generate random
observations from probability distributions that
a l
were determined as part of the simulation model
ep
itn
8
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
8
Components of next-event time-advance approach
Report generator
A subprogram that computes estimates (from the
statistical counters) of the desired measures of
performance and produces a report when the
simulation ends
Main program
A subprogram that invokes the timing routine to
determine the next event and then transfers
control to the corresponding event routine to
update the system state appropriately.
a l
ep
itn
9
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
9
Generation of Arrival Patterns
a l
executed and the arrival time of next entity is calculated
ep
from inter-arrival distribution
itn
10
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
10
Generation of Arrival Patterns
a l
- But if attributes do affect the event execution, they must
ep
be assigned at the arrival time and retained until the
itn
event execution is finished. 11
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
11
Simulation Programming Tasks
1. Generate model
2. Simulate
GENERATE
3. Report SYSTEM IMAGE ROUTINES
MODEL
a l
Simulation algorithms – procedures that execute the
ep
cycle of actions
itn
12
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
12
Simulation Algorithm
CREATE MODEL
Steps
1. Find the next potential
FIND NEXT POTENTIAL EVENT 1
event
2. Select an activity SELECT ACTIVITY 2
event
4. Change the system Y
l
MORE?
image
a
ep
5. Gather statistics N
itn
GENERATE REPORT 13
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
13
Gathering Statistics
a l
one part of the system to some other part
ep
itn
14
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
14
Counters and Summary Statistics
a l
ep
itn
15
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
15
Measuring Utilization and Occupancy
a l
1
U = .∑ (t f − tb ) r
ep
T r =1
itn
16
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
16
Measuring Utilization and Occupancy
l
∑
a
For a group of such items; A = . n .(t − t )
ep
r r +1 r
T r =1
itn
17
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
17
Measuring Utilization and Occupancy
la
ep
For large number of active entities, utilization cost more (time
and space) as compared with occupancy
itn
18
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
18
Recording Distributions and Transit Times
l
a
entity reaches a point from which transit time is started,
ep
the arrival time is noted. Later when the entity reaches
itn
to end point, the difference is computed 19
(C) Pramod Parajuli, 2005
cs
Source: www.csitnepal.com
19