03 - SYSC4005 - General Principles and Simulation Software
03 - SYSC4005 - General Principles and Simulation Software
Software
SYSC 4005/5001W
Discrete Simulation/Modeling
Winter 2024
1
General Principles
2
Chapter Overview
• The goal is to develop a common framework for
complex systems modeling using DES. Entities
and
attributes
• In DES, a system is modeled in terms of:
• its state at each point in time, the entities that
pass through it, the entities represent system DES
resources, and activities and events that Building
cause state change. Blocks
System • A collection of variables that contain all information necessary to describe the
state system at any time.
4
DES Concept of Dynamic & Stochastic Systems (2/3)
• The properties of a given entity (e.g., the priority of a waiting customer, the routing of
Attributes a job through a job shop)
Event • A record of an event to occur at the current or future time along with any associated
notice data necessary to execute the event (at a minimum, it has event type and time).
5
DES Concept of Dynamic & Stochastic Systems (3/3)
6
More on Lists
• Sometimes are called sets, queues, or
chains.
• Lists are used to hold both entities and event
notices:
• The entities are always ordered by some
rule, such as FIFO or LIFO, or are ranked
by some entity attribute, such as priority
or due date.
• The future event list (FEL) is always
ranked by the event time recorded in the
event notice.
7
More on Activities
• An activity represents a service time, an interarrival time, or any other
processing time.
• An activity’s duration may be specified in a number of ways:
1. Deterministic: e.g., always exactly 5 minutes;
2. Statistical: e.g., as a random draw from the set {2, 5, 7} with equal
probabilities;
3. A function depending on system variables and/or entity attributes,
e.g., loading time for an iron ore ship as a function of the ship’s
allowed cargo weight and the loading rate in tons per hour.
• Sometimes called an unconditional wait.
8
Durations of Activities
• A duration of an activity:
• is computable from its specification at the instant it begins, and
• is not affected by the occurrence of other events.
9
More on Delays
• Unlike an activity, a delay’s duration is not specified ahead of time, but
rather is determined by system conditions.
• A delay’s duration is measured and is one of the desired outputs of a
model run.
• A delay ends when some set of logical conditions becomes true or one or
more other events occur:
• e.g., a customer’s delay in a waiting line may be dependent on the
number and duration of service of other customers ahead in line as
well as the availability of servers and equipment.
• Sometimes called a conditional wait.
10
Primary vs. Secondary Events
* FEL contains all event notices for events that have been scheduled to occur
at a future time
11
Example – Call Center
Lecture: Simulation Examples – Slide 30
Consider the Able–Baker call center system. A discrete-event model has
the following components:
• System state
𝐿𝐿𝑄𝑄 (𝑡𝑡), the number of callers waiting to be served at time 𝑡𝑡;
𝐿𝐿𝐴𝐴 (𝑡𝑡), 0 or 1 to indicate Able as being idle or busy at time 𝑡𝑡;
𝐿𝐿 𝐵𝐵 (𝑡𝑡), 0 or 1 to indicate Baker as being idle or busy at time 𝑡𝑡.
• Entities
Neither the callers nor the servers need to be explicitly represented,
except in terms of the state variables, unless certain caller averages
are desired.
12
Example – Call Center
Lecture: Simulation Examples – Slide 30
• Events
Arrival event;
Service completion by Able;
Service completion by Baker.
• Activities
Interarrival time,
Service time by Able,
Service time by Baker,
• Delay
A caller’s wait in queue until Able or Baker becomes free.
13
Dynamic Description of DES Model
14
System Snapshots
• A DES is the modeling of a system over time;
• system’s state changes occur at discrete points in time (when an
event occurs.)
• A DES proceeds by producing a sequence of system snapshots that
represent the evolution of the system through time.
• A snapshot at a given time (CLOCK = 𝑡𝑡) includes:
15
System Snapshots – Prototype
16
The Event Scheduling/Time Advance Algorithm
This Algorithm shows the sequence of actions that DES must perform to:
1) advance the clock, and 2) build a new system snapshot.
• The mechanism for advancing simulation time and guaranteeing that all
events occur in correct chronological order is based on the FEL.
• Future event scheduling means that:
1. at the instant an activity begins, its duration is computed or drawn
as a sample from a statistical distribution, and
2. the end-activity event, together with its event time, is placed on FEL.
• Random future events are represented by the end of some activity, which
in turn is represented by statistical distribution.
17
The Event Scheduling/Time Advance Algorithm
18
The Event Scheduling/Time Advance Algorithm
19
Managing FEL
• The length and contents of FEL are constantly changing as simulation
progresses this requires an efficient management.
• List processing is how to manage a list. The major list processing
operations performed on a FEL are:
• removal of the imminent event, its removal is as efficient as possible,
• addition of a new event, and
• occasionally removal/cancellation of an event.
• Last two operations requires a search of the list. The efficiency of this
search depends on the logical organization of the list and on how the
search is conducted.
20
Managing FEL – An Illustration
21
Managing FEL – An Illustration (cont.)
22
System Snapshot Creation
• The system snapshot at time 0 is defined by
1. the initial conditions, which define the system state at time 0, and
2. the generation of exogenous events, such as an arrival to a
queueing system.
• At time 0, the first arrival event is generated and is scheduled on FEL.
• When the clock eventually is advanced to the time of this first arrival, a
second arrival event is generated. Three examples:
• bootstrapping,
• service completion event in a queuing simulation,
• alternate generation of runtimes and downtimes for a machine.
23
Generating Future Events
Bootstrapping
24
Generating Future Events
Service Completion Event in Queueing Simulation
25
Generating Future Events
Service Completion Event in Queueing Simulation
26
Generating Future Events
Alternate Generation or Runtime and Downtime
27
Ending the Simulation
• Every simulation must have a stopping event 𝐸𝐸 which defines how long
the simulation will run.
• There are two ways to stop a simulation:
1. at time 0, schedule a stop simulation event at a specified future time
𝑇𝑇𝐸𝐸 the simulation will run over the time interval [0, 𝑇𝑇𝐸𝐸 ].
2. run length 𝑇𝑇𝐸𝐸 is determined by the simulation itself. Generally, 𝑇𝑇𝐸𝐸 is
the time of occurrence of a specified event 𝐸𝐸.
• In case 2, 𝑇𝑇𝐸𝐸 is not known ahead of time. It could be one of the statistics
of primary interest to be produced by the simulation.
28
World Views
29
World View – Process Interaction
30
World View – Activity Scanning
• The focus is on the activities of a model and those conditions that allow
an activity to begin.
• At each clock advance, the conditions for each activity are checked, and,
if the conditions are true, then the corresponding activity begins.
• the repeated scanning to discover whether an activity can begin
results in slow runtime on computers the pure activity-scanning
approach has been modified by the three-phase approach
• it combines some of the features of event scheduling with activity
scanning
• it allows for variable time advance and the avoidance of scanning
when it is not necessary,
• it keeps the main advantages of the activity-scanning approach.
31
Manual Simulation Using Event Scheduling
• In the conducting of an event-
scheduling simulation, a simulation
table is used to record the successive
system snapshots as time advances.
32
Manual Simulation Using Event Scheduling
Example: Model Components – 1
• The model has the following components:
System state
1. 𝐿𝐿𝐿𝐿(𝑡𝑡) is the number of customers in the waiting line.
2. 𝐿𝐿𝐿𝐿(𝑡𝑡) is the number being served (0 or 1) at time 𝑡𝑡.
Entities: The server and customers are not explicitly modeled, except in
terms of the state variables.
Events:
1. Arrival (𝐴𝐴);
2. Departure (𝐷𝐷);
3. Stopping event (𝐸𝐸), scheduled to occur at time 60.
33
Manual Simulation Using Event Scheduling
Example: Model Components – 2
• Event notices:
1. (𝐴𝐴, 𝑡𝑡), representing an arrival event to occur at future time 𝑡𝑡,
2. (𝐷𝐷, 𝑡𝑡), representing a customer departure at future time 𝑡𝑡,
3. (𝐸𝐸, 60), representing the simulation stop event at future time 60.
• Activities:
1. Interarrival time.
2. Service time.
• Delay:
• Customer time spent in waiting line.
34
Execution of the
departure event
Execution of the
arrival event
35
Simulation table of
checkout counter
till CLOCK = 8
36
Event-Scheduling Algorithm
Implementation in Simulation Software
• Remarks:
• The software maintains just one set of system states and other
attribute values, that is, just one snapshot (the current one or partially
updated one).
• The following rule should be followed:
• a new snapshot can be derived only from: 1) the previous
snapshot, 2) newly generated random variables, and 3) the event
logic.
• past snapshots should be ignored for advancing of the clock.
• the current snapshot must contain all information necessary to
continue the simulation.
37
List Structures
38
Records Types
39
Main Operations on Lists
40
Storing Lists on a Computer
• Each is stored in a physical location in computer memory.
• There are two basic possibilities:
1. storing all records in arrays: arrays hold successive records in
contiguous locations in computer memory. They can be referenced
by an array index that can be thought of as a row number in a
matrix.
2. representing all records by structures (as in C) or classes (as in
Java), allocated from RAM memory as needed, and tracked by
pointers to a record or structure.
41
Simulation Software
42
Categories of Simulation Software
Simulation
Software
43
Simulation using General Purpose Programming
Languages
• They do not provide any facility directly aimed at aiding the simulation
analyst.
• All details of the event-scheduling/time-advance algorithm, the statistics-
gathering capability, the generation of samples from specified probability
distributions, and the report generator MUST be developed.
• Some languages have runtime libraries that provide random-number
generators.
• Example 2 (Chapter 4) shows how to use Java for Single-Server Queue
Simulation.
44
Overall structure of an event-
scheduling simulation program
45
Organization of Program (1/3)
46
Organization of Program (2/3)
• Then, the main program invokes event routine to ensure the following:
1. the system state is updated,
2. statistical counters are updated, and
3. the times of occurrence of future events are generated and added to
the event list.
• Generation of random observations from probability distribution is made
to determine these future event times using library routine.
47
Organization of Program (3/3)
• If yes, the report generator is invoked form the main program to compute
estimates of the desired measures of performance and to produce a
report.
• If not, control is passed back to the main program and the main program,
timing routine, main program, event routing, termination check cycle is
repeated until the stopping condition is eventually satisfied.
48
Questions?
49