Professional Documents
Culture Documents
Unit 2
Unit 2
1
Contents of Module 2
Time Advance Mechanism
Components and Organization of a Discrete Event
Simulation Model
Selected Illustrative Examples of Simulation Application
Models
2
System , Models, Simulation
Types of Systems
Discrete
State variables change instantaneously at separated points in time.
For eg. Bank model: State changes occur only when a customer arrives
or departs.
Continuous
State variables change continuously as a function of time.
For eg. Airplane flight: State variables like position, velocity change
continuously. Many systems are partly discrete, partly continuous. 3
Simulation Model
4
Deterministic and Stochastic
● Deterministic Model is one whose behavior is entire
predictable. The system is perfectly understood, then it
is possible to predict precisely what will happen.
5
Discrete or Continuous Models
● Discrete Model: In this the state variables change only at a
countable number of points in time. These points in time are
the ones at which the event occurs/change in state.
6
Simulation Model
7
Time Advances Mechanism
Time advances mechanism is a science of dynamic
system which depicts the time dependence of a point
and it can be studied by two categories:
8
Discrete Event Simulation (DES):
10
DES Example 1
• Consider a service facility with a single server
Consider a service facility with a single server---e.g. an information
desk at an airport-for which we would like to estimate the (expected)
average delay in queue (line) of arriving customers, where the delay in
queue of a customer is the length of the time interval from the instant
of his arrival at the facility to the instant he begins being served.
• The status of the server, i.e., either idle or busy, the number of
customers waiting in queue to be served (if any), and the time of
arrival of each person waiting in queue.
• The status of the server is needed to determine, upon a customer's
arrival, whether the customer can be served immediately or must join
the end of the queue.
11
Cont..
• When the server completes serving a customer, the number of customers in the
queue is used to determine whether the server will become idle or begin
serving the first customer in the queue.
• The time of arrival of a customer is needed to compute his delay in queue,
which is the time he begins being served (which will be known) minus his time
of arrival.
• There are two types of events for this system: the arrival of a customer and the
completion of service for a customer, which results in the customer's departure.
• An arrival is an event since it causes the (state variable) server status to change
from idle to busy or the (state variable) number of customers in the queue to
increase by 1. Correspondingly, a departure is an event because it causes the
server status to change from busy to idle or the number of customers in the
queue to decrease by 1.
12
Cont..
Example 2
We assume a sheep farm that currently operates with 100 sheep. The
sheep population growth rate is 5% per year. The objective of the study
is to understand how the sheep population of the farm changes over time.
Given that only the yearly growth rate of the sheep population is known,
what we can study in this case is the change of stock population in each
year, which is actually a discrete time process. First, some variables can
be defined based on the above problem statement:
• A variable representing time t, t ∈ {0, 1, 2, ...}.
• A system state variable (xt), which is the sheep population size in
year t.
13
Cont..
14
Cont..
For year 0, the initial sheep population size is 100, which can be denoted by x 0 = 100.
xt is the population size of year t, then the population size of the next year is x t+1
The yearly population growth rate (r), which equals 5%.
The relationship between the population size in the current year and the next year can be easily constructed using
the growth rate, r, as below:
xt+1 = xt + r × xt
This equation describes how the system state x changes occur at discrete time steps. Considering the initial
population (x0= 100) and the growth rate (r = 5%) and we can obtain the yearly sheep population size, as
illustrated in Table 8.1.
We can clearly see in this example how variables – the sheep population (x t), the input (yearly growth rate r) and
the output (yearly increment of sheep population (xt × r) – are defined only for discrete time points, t. Therefore,
the sheep population of the farm in this example can be viewed as a discrete time system. Based on this example,
the definition of a discrete time system can be given as follows:
A discrete time system is a system for which the state, input, and output variables are defined only for discrete
moments in time.
15
Discrete Time System and Modelling
By the definition, the time domain of a discrete time system is discrete. This means
that the spacing between successive time points may be arbitrary or uniform. In the
sheep farm example, the time space, t, was divided uniformly into years: t ∈ {0, 1,
2, ...}. However, time can also be partitioned using arbitrary intervals, as in the case of
discrete event systems, where the system clock ticks at the time point when a particular
event happens. Hence, from this point of view, a discrete event system is a special case
of a discrete time system.
To model and simulate a discrete time system, a particular type of simulation – called
discrete time simulation (DTS) – is typically employed. The resultant DTS will use a
time-advancing mechanism that can be either a fixed-increment time-advancing
mechanism (uniform spacing) or a next-event time-advancing mechanism
(arbitrary) due to the discrete nature of the real-world system to be simulated.
16
Cont..
At each simulation clock tick, the state of a discrete time system may be changed by its input and may produce
some output, with a subsequent effect. The system state, input, and output are measurable variables of the
system; thus, we can collect the data by taking measurements at specific time points over a period, such as the
share prices in a stock market each day, the sheep population of a farm at the beginning of a year and the
voltage and currents of an electric circuit.
Let us consider that the input variable, u, is a function of time:
u(tk)= {u1(tk), u2(tk), ..., up(tk)}, k ∈ {0, 1, 2, ..., n}.
The initial state can be represented as in the following equation:
x(t0) = x0.
We note that the initial state does not depend on the input variable, while all other states do. The state of the
system at time (tk+1) is a time function of the input variables and the system state at the previous time point (tk):
x(tk+1) = f(x(tk), u(tk), tk) , k ∈ {0, 1, 2, ..., n}
where f(⋅) is a time function that can change the system state based on the system state and input at the time
instant (tk). Similarly, the system output variable y can be defined as a time function as well:
y (tk)= { y1(tk), y2(tk), ..., yq(tk) }
17
Cont..
The output at arbitrary time points y(tk), is determined by the input
and system state variables and can be expressed as:
y(tk) = g (x(tk), u(tk), tk), k ∈ {0, 1, 2, ..., n}
18
Fig. Discrete time system – input, output, state.
Cont..
where g(⋅) is the function that produces the output from a system, using the system state and
input to the system at time point tk.
Through the above examples, we introduced the basic methods to construct a DTS for a
discrete time system, considering the very simple objectives assumed in these examples.
However, DTS may be employed for a variety of purposes; hence, various objectives need to
be taken into account. Sometimes, we are interested in the behaviors of a discrete time
system. On some other occasions, we would like to evaluate the effects on the environment
of a discrete time system over a period, or solve some problems. To achieve these objectives,
it is important to collect data about input, system state and output variables, and then conduct
relevant analysis of these data.
19
Discrete Time Simulation and Discrete Event
Simulation
• DES is a special case of DTS, as mentioned earlier in this chapter.
The dynamics of DES are driven by a set of discrete events that
occur at specific time instants. Therefore, DES can be seen as a
special case of DTS, in which the intervals between time points
are defined by the event occurrence times.
• In the following, we use another example – the simulation of a
vending machine – to describe the differences between a DES
approach and a DTS approach.
20
Cont..
For eg. A vending machine is used for selling various soft drinks to
customers. To keep this example intuitive, we include the following
simplifying assumptions: all drinks are priced at one dollar, the vending
machine accepts only one-dollar coins, and the machine provides a soft
drink once a customer inserts a coin and makes selection.
DES approach is perfectly fine for this vending machine because its states
are driven by a set of discrete events {COIN INSERTED, SELECTION
MADE, DRINK TAKEN}. Further, a FSM can be used for modelling the
operation of this DES.
21
Cont..
• There are three system states of the vending machine: ‘waiting coins’,
‘waiting selection’, and ‘vending drink’. The events of ‘coin inserted’,
‘selection made’, and ‘drink taken’ trigger the vending machine state to
change from one to another.
• For example, the state of the machine changes from ‘waiting coin’ to
‘waiting selection’ when the event ‘coin inserted’ occurs, and changes to
‘vending drink’ once a selection is made by the customer. The machine
then moves again to ‘waiting coin’ state after the chosen drink is taken by
the customer.
22
Cont..
24
Cont..
• To apply a DTS approach, we could use a flowchart to model the system
behavior with consideration of an internal clock ticking. Unlike the FSM
(DES) approach, the time concept is explicitly introduced in the DTS
approach.
• A ‘null’ event is also introduced to represent the situation in which there is
no event happening when the clock ticks. The clock in the vending
machine keeps ticking. If any event except the ‘null’ event occurs before
each clock tick, the vending machine’s state changes.
25
Flowchart Representation of a DTS Approach for the
Vending Machine
27
Cont..
• In the vending machine example, DES has certain advantages
over DTS. This is mainly due to the nature of the vending
machine system, which is driven by events.
• DTS has advantages over DES in some cases where the system
time space is discrete and the time intervals between state
changes are uniform.
• The sheep farm example presented earlier in this chapter is a
good case in which DTS should be us
28
Cont..
• DES is used for systems where the state of a system changes in discrete
points in time.
• A system can change in only countable number of points in time.
• Makes use of a Time-Advance Algorithm.
29
Differences
34
Cont..
35
Simulation of a Single-Server Queueing System
• Queues arise when the short term demand for service exceeds the capacity
• Most often caused by random variation in service times and the times between
customer arrivals.
• If long term demand for service > capacity the queue will explode!
36
Why is Queuing Analysis Important?
• Capacity problems are very common in industry and one of the main drivers of process
redesign
• Need to balance the cost of increased capacity against the gains of increased productivity and
service
• Queuing and waiting time analysis is particularly important in service systems
• Large costs of waiting and of lost sales due to waiting
37
Examples of Real World Queuing Systems
• Commercial Queuing Systems
• Commercial organizations serving external customers
• Ex. Dentist, bank, ATM, gas stations, plumber, garage …
• Transportation service systems
• Vehicles are customers or servers
• Ex. Vehicles waiting at toll stations and traffic lights, trucks or ships waiting to be loaded, taxi cabs,
fire engines, elevators, buses …
• Business-internal service systems
• Customers receiving service are internal to the organization providing the service
• Ex. Inspection stations, conveyor belts, computer support …
• Social service systems
• Ex. Judicial process, the ER at a hospital, waiting lists for organ transplants or student dorm rooms
…
38
Components of a Basic Queuing Process
39
Components of a Basic Queuing Process
41
Single channel queuing systems Problems
Problem 1: A small grocery store has only one checkout counter. Customers arrive at this checkout counter at random from
1 to 8 minutes apart. Each possible value of inter-arrival time has the same probability of occurrence. The service times
vary from 1 to 6 minutes with the probabilities shown in table 5. The problem is to analyze the system by simulating
the arrival and service of 6 customers.
1 0.10
2 0.20
3 0.30
4 0.25
5 0.10
6 0.05
42
Calculate
1) The average waiting time for a customer
2) The probability that a customer has to wait in the queue
3) The fraction of the idle time of the server
4) The average service time
5) The average time between arrivals
6) The average waiting time of those who wait
7) The average time a customer spends in the system
Use the following sequence of random number. Assume that the first customer arrives at
time 0.
Random 913 727 15 948 309 922
digits for
arrival
Random 84 10 74 53 17 79
digits for
service time
43
Solution:
Step 1: Calculate the arrival and service time table and get the random
number Assignment
Time between Probability Cumulative probability Random digit
arrival (In Assignment
minutes)
1 0.125 0.125 0-125
2 0.125 0.250 126-250
3 0.125 0.375 251-375
4 0.125 0.500 376-500
5 0.125 0.625 501-625
6 0.125 0.750 626-750
7 0.125 0.825 751-815
8 0.125 1.000 816- 1000
44
Note: Cumulative probability = Current probability + addition of the value above it
45
Step 2: Detemining time between arrival
46
Customer Inter A.T A.T S.T Time Waiting Time Total time Idle time of
Service Time Service Ends spent in the server
Begin system
1 ----- 0 4 0 0 4 4 0
2 8 8 1 8 0 9 1 4
3 6 14 4 14 0 18 4 5
4 1 15 3 18 3 21 6 0
5 8 23 2 23 0 25 2 2
6 3 26 4 26 0 30 4 1
Total 18 3 21 12
47
• Average waiting time = total time customer waits in queue
total no of customers
= 3/6
= 0.5 minutes
48
• Average Service Time = Total service time
# of customers
= 18/6
= 3 minutes
• Average time between arrivals = Sum of all time between the arrival
# of arrival - 1
= 26/5
= 5.2 minutes
• Average waiting time of those who wait = total time customers waited in queue
Total # customer who actually wait
= 3/1
=3
49
• Average time customer spends in the system = # time customer spends in the system
# of customers
= 21/6
= 3.5 minutes
50
Problem 2: For the following data find the queue statistics (time in minutes): IAT denotes the inter-arrival time
and ST denotes the service time. Assume the first customer arrives at Time t=0.
IAT --- 8 6 1 8 3 8 7 2 3
ST 4 1 4 3 2 4 5 4 5 3
51
Solution:
1 --- 0 4 0 0 4 4 0
2 8 8 1 8 0 9 1 4
3 6 14 4 14 0 18 4 5
4 1 15 3 18 3 21 6 0
5 8 23 2 23 0 25 2 2
6 3 26 4 26 0 30 4 1
7 8 34 5 34 0 39 5 4
8 7 41 4 41 0 45 4 2
9 2 43 5 45 2 50 7 0
10 3 46 3 50 4 53 7 0
Total 46 35 9 44 18
Simulation table 52
• Average waiting time for customer = 9/10 = 0.9
• Probability cutomer has to wait = 3/10 = 0.3
• Probability of idle server = 18/53 = 0.34
• Average service time = 35/10 = 3.5
• Average time between arrival = 46/9 = 5.11
• Waiting time for customer = 9/3 = 3
• Time spend on system = 44/10 = 4.4
• Max queue length = 1
53
Thank You
54