You are on page 1of 65

Instructor: Dr.

Mohammad Hamasha
Office Location:
Office Phone:
Email: mhamasha@hu.edu.jo
What is a simulation?
• A simulation is a mode/ that behaves like the
real system. It is the imitation of an operation of
a real process or system over time.
• Examples:
— Flight training simulators for pilots. —
Pilot plants for chemical processes —
Wind tunnels
— Solid models
— Computer models of car crashes
— Climate models
Purpose
Why Simulation?
• To experiment with the system.
• Can simulate without having to:
Build the real system
Pay for the operation of the real system
— Wait for the system to operate in real time
Model all trivial aspects of the system
• That is, it is EASIER, CHEAPER and
FASTER
V\Then
• Common since is sufficient.
• An analytical solution exists in simple
forms.
• Direct experiments can be performed

• Cost of simulation is very high.


Discrete Events...
• What is Discrete Event Simulation?
• A means by which certain system events
can be simulated.
• What kind of systems?
Systems with some or all of
the following features:
• The system operates over time: it is a process.
• Randomness is involved.
• Scarce resources
• Entities which flow through the system requiring
resources
• in order to perform activities.
• Waiting lines (queues) where the entities wait for
needed
• resources to become available.
• Priority rules for the flow of entities and the use
of resources.
How do we handle the random
stuff?
• Random number generation.
• Some statistics background.
• Familiarity with probability distributions.
• Little knowledge of all of above is enough..
Example: An Assembly
Operation
• Entities: The assembly and its parts and
subassemblies.
• Resources: Machines, tools, operators and
workstations needed to assemble parts.
• Activities: The various assembly tasks.
• Queues: Buffer space between work stations.
• Randomness:
— Assembly task times —
Machine breakdowns —
Demand for products
Example: A Warehouse
• Resources:
— A storage location — A
fork lift. AGV. etc. — A
spot on a conveyor
• Entities
— The items to be stored
— Orders
• Priorities: Rush orders
• Queues:
— Queues for items awaiting transportation
— Queues for orders waiting to be picked
• Randomness:
— The arrival of orders
— Move times for transporters
Example: A Hospital
• Resources:
— A had
— A doctor, nurse
— Laboratory facilities —
The operating room
• Entities:
— Patients
• Attributes (data values specific to each entity)
— Disease type
— Age, sex. 'weight
— Insurance carrier
• Priorities
— Emergency vs. critical vs. elective patients —
Insurance carrier
• Randomness
— Arrival of patients to hospital
— Time to get well
Example: A Job Shop
• Resources:
— Machines
— Operators
— Transportation devices
• Entities
— A job/order (a part to be made)
• Randomness
— Machining times
— The arrival of orders —
Machine breakdowns
• Priorities
— Rush orders
• Queues
— Storage locations between machines.
Other Examples
- Customers through a bank, store, restaurant, etc.
- Traffic through a road system
- Military equipment through operations
- Calls through a phone network
- Jobs through a computer
- Planes and travelers through an airport
- Particles through a radiation field
- A steel making operation
- A military battle
- Distribution and inventory systems
- The economy
- A river basin
What outputs are available?
• Statistics on system state variables:
Utilization rates of resources
Throughput of entities through the system
Time spent by entities in various parts of the
system
Number of customers turned away by long
lines
—Time spent in waiting lines
• Outputs are typically random variables
(expectations).
Statistics might include:
Averages
Standard deviations
Frequency histograms
• Broken down by:
The type of entity
The resource
The queue
What purpose do these models
serve?
• Prototyping: How will the system operate and
perform?
— Can orders be met in a timely manner?
— What will the throughput be?
— Are there any unanticipated glitches?
• Sensitivity Analysis: ("What ifs")
— HoiAt much will throughput increase if \Aie add another
machine?
— What will happen if the machine breakdown rate is
higher than planned?
— Should a third shift be added?
• Comparing alternative systems
system ces gr yield higher pro' t.
or B?
• Determining "optimum" system design
Ho\A. mary s are reeoec?
Ho\!.: maly so. see pais shoLdo e procLoed?
Which priority rt,,le should be useo to soheode
jobs on Tachires?
Which stoeage e 1•ield the sr oetest
retrieval time?
Cont.,
• Simulation as a design tool
A design is a description of all relevant
features of the problem in question.
In order to build a simulation model, all
relevant system features must be specified
Often many problems and details of a
proposed system are discovered during
simulation model building.
Discrete Event Simulation
Languages
• The primary tool of discrete event
simulation is the discrete event simulation
language. These are special purpose
languages designed for building discrete
event simulations
• First generation languages:
GPSS, SIMAN, SLAM, GASP, SIMSCRIPT
• Now: Graphical user interface driven
ARENA, Witness, Promodel.
• Animation Capabilities
Example:
• Customers arrive to a barbershop at a rate
of I customer each 10 minutes. The
barber service time is constant and equals
to 20 minutes. Perform a manual
simulation of such process.
Solution:
• The first customer arrive at time 0.
• The second customer arrives at time 10.
• The third customer arrives at time 20.
• And so on...
• The customers will be serviced
immediately if there are no customers
waiting in line (Queue).
Schedule the arrival events:

Scheduled Arrivals
First customer
arrives at time 0

...• Second customer


I arrives at time 10,

ttt
0 10 20 30
ttt
40 50 60 70
tt
80 90 100
The following chart shows the
solution...
Customer -I gets into
--- service immediately

c
• Customer 1

11,0 110 Customer 2


aN•
Customer is being serviced

0—low, Customer is in queue

0
Customer 2 has to

0
Customer 3
wait 10 minutes to
get serviced Customer 4

.
Customer 3 has to Customer 5
wait 20 minutes to
get serviced 1.1. ■111111*.

11111
1
T=35
Customer 5 arrives
at T=40

0 10 20 30 ; 40 50
60 70 80 90 100
41111 i 1•1 •

T=65
Queue and Average Queue size

Average 0 over the given

[
period =2.5 customers.

al

I v. w r w r 1

0 10 20 30 40 50 60 70 80 90 100
Observations
Note:
• At T=35,
— Customer #1 is already out of the system (disposed). —
Customer #2 is being serviced.
— Customer #3 is waiting in Q.
— Customer #4 is waiting in Q.
— Customer #5 is schedule to arrive at T=50.
• At T= ,
— 3 customers are in queue,
— Customer #4 is in service.
Observations, cont.
Note:
• At T=65,
Customer #1 is disposed.
Customer #2 is disposed.
Customer #3 is disposed.
Customer #4 is being serviced.
Customer #5, 6, 7 are all in Q.
Customer #8 is scheduled to arrive at T=
Using First Generation Language:

• Note first that:


Interarrival time between customers 10 in
Service time = 20 min.
Entities type: customers
Resource: Barber.
Queue: Barber Queue
First Generation Language Code:

• It is the Old-timer's code:


CREATE CONST(10)
QUEUE: Barber Queue
SEIZE: Barber
DELAY: CONST(20)
RELEASE: Barber
DISPOSE: Customer
But ARENA is way simpler!
• In ARENA software, we simply do the
following model:

Dispose 2
Another Example:
• Customers arrive to a bank teller. The
teller service time is constant and equals
to 8 minutes. Simulate this process
manually for 5 customers. The interarrival
time between the 5 customers is given by
the following stream: 4, 4, 12, 20.
Manual simulation
Scheduled Arrivals

First customer
/ arrives at time 0
..- Second customer
arrives at time 4 Fifth customer
arrives at time 40
4

Third customer
41fr
4

• arrives at time 8 Fourth customer
arrives at time 20

0 5 10 15 20 25 30 35 40

4 4 12 20
interarrival times
Manual Simulation Cont.,

[
A T=8
Customer is being serviced
0
-110 Customer is in queue
• Customer 9 T=16 T=35
110—+ Customer 2 T=24 1=32
• Customer 3
• lib Customer 41
+ Customer 5

0 5 10 15 20 25 30 35 40 45 50

Note: at T=3 the server is idle.


Queue size and average Q size
Q

Average 0 size =WM-4M +(24-20}9} /48=0.333

I
• •
418 1
0 5 10 15 20 25 30 35 40 45 50

• Average Q size =IQ dt /Interval =0.32


Manual Simulation Cont.,
• At T=8, here is what happens:
The first customer gets disposed.
The barber is release.
The second customer gets into service, and
therefore:
The barber is seized ( i.e. gets busy again)
Interarrival time distribution
• In the previous example, the interarrival time was a
stream: 4 4 12 20.
• How do we get such stream?
- We can get it from random variables
• Random variables can be generated from
probability distributions.
• For example an exponential distribution may give
the interarrival time.
• Expo(5) for instance, provides interarrival times
that are exponentially distributed with average of 5.
Interarrival time dist. Cont.
• Its the responsibility of the simulation
software to provide such stream of values.
• If the interarrival time is Normally
distributed then we model as : Norm(p, c5)
or N(p_, 175)
• If Uniform then U(a, b)
Interarrival time dist. Cont.
Normal Distribution
3

-4 .7 4
f1.-0 pr, P I (171-20

Uniform Distribution
p(x)

Exponential Distribution
Interarrival time dist. Cont..
Example: A Simple Flow Shop
• Two successive operations that are done on
machine 1 and machine 2.
Parts

,1 Machine 1 Machine 2
N(10, 4) N(10, 4)
Expo(10)

• Parts arrive following Expo 10 in hours.


• Processing times of jobs:
— Machine 1 processing time: Norm(10,4), that is: mean
= 10, std=4.
— Machine 2 processing time: Norm (10,4)
• First come, first served policy.
The Code:
• Resources: Machinel, Machine2
• Queues: Linel, Line2
• Entities: Jobs
• Here is the code:
CREATE Expo (10)
QUEUE: Linel
SEIZE: Machinel
DELAY: Norrn(10,4)
RELEASE: Machinel
Code, cont.
QUEUE: Line2
SEIZE: Machine2
DELAY: Norm(10,4)
RELEASE: Machine2
DISPOSE: 100
ARENA Model

Create customers
1

A
Machine 1

o
Machine 2

0
1 ispose customers

I)
Verification and Validation of
Simulation Models
• Neither permits a
magic solution (Real System)

• Common Sense
Conceptual Model
prevails
if
Verification

Validation

vt.
@omputer Prograrr)
Verification:
• Check that the computer program does
what it is supposed to.
• Use sound programming techniques
• Check output for reasonableness
• View animations
Validation:
• Check that the model accurately reflects
the real system
• Compare model output to real system
output
• Involve system experts and model users
throughout development
• Explicitly state and verify all model
assumptions
• View animation
Basic Steps in a Simulation Study
• Define the purpose of the study
• Model building
— Define relevant system features
— State necessary assumptions
• Data collection
• Programming
• Verification
• Validation
• Experimental Design
• Experiment
• Analyze results
Alternatives to system modeling

• Simulation
• The real system
• Analytic methods (e.g. Queuing Systems
analysis)
Advantages and Disadvantages
of Simulation
• Advantages
Can model intricate details of the real system
Can experiment with the system before
wasting lots of time and money
Simulation is easy to apply in theory
Can maintain better control on experiments
(e.g. replicate conditions)
Simulation can compress time
Disadvantages
• Complex models take time and money
• Due to randomness, only estimates are
produced
• Verification and validation are hard to
prove
• Can only perform experiments. Solutions
can only be inferred.
Some State variables to keep in mind:
• These variables vary with time and tell us
what is going on in the system at any
given time.
Servers: cash

busy

Queue: cash_q
busy
■■■■■■■■ MR(cash)= 4
NR(cash)= 3
busy NQ(cash_c)= 8

Idle
State variables to keep in mind:
E. g.
• NQ(Line 1) =The number of entities in
queue 1.
• NR(Machine 1) =The number of busy
units of resource 1.
• Resources can have more than one unit.
• MR(Machine 1) =Number of available
resources.
State variables cont,
• For example, consider a parking lot. It can
serve more than one car at the same time.
• Another example is a bank with 4 tellers.
The resource "tellers" can serve up to four
customers at a time.
How does a simulation end?
• At a prespecified time :
(ARENA) >Run >Setup >Replication
Parameters
• After a prespecified number of entities are
DISPOSE
• When no entities are current or scheduled
(can "turn off' the create block)
Example:
• Customers arrive to a single server.
• Use the interarrival stream:
5 7 1 4 10
• Use the service time stream for the first 6
customers:
7 3 5 6 8 7
• Simulate the arrival of the 6 customers
by
graphical aid simulation.
excel sheet simulation.
Graphical simulation:

.111 11p.

C t.

0 2 4 6 8 10 12 14 15 18 20 22 24 26 28 30 32 34 36 38 40

Notes:
Server total idle time = 2
4 customers had to wait in Q.
Total service time = 7+3+5+6+8+7=36
Total time customers wait in 0 = 2+4+6+4=16
Total time customers stay in system = 7+5+5+10+14+11=52
Simulation using Excel sheet,
Max(F1 C2) E+D E-C LE2-F1 F-C
time
service
B
inter
C E
I time
ends F G
time 'idle time
7
Custome arrival arrive service service customer 9head of time in
10
r# time time time begins wait in Q customer system
17
1 5 0 7 0 0 0 7
23
2 7 5 3 7 2 2 5
31
3 1 12 5 12 0 0 5
38
4 4 13 6 17 4 0 10
5 10 17 8 23 6 14
27 7 31 4 11
36 16 52

Total
Simulation
Time
Results:
Average waiting time Total time customers
wait in q/ total # of
customers.

16/6 = 2.67
Probability a Number of customers
customer has to wait who wait/ total # of
customers.

4/6 0.67
Results, cont.,

2/38 0.052

Average service Total service time/ total


time number of customers.

36/6=6
Results, cont.,
Average time Total time customers
customer spends spend in the system/ total
in the system number of customers.
Average waiting time +
average service time

8.67
Histograms:
Histograms
• Solution:

1 2 3 4 5 6 7 8
• Normalized: divide by the total
# of observations, that is 13.

3/13

2, 2/13

1113
How to create A histogram of a
random stream in Excel
B C
• 1. Identify a range of
Trained Staff
data on which you want 5 Ward A 12

to perform your 6 Ward B 14

frequency analysis. 7 Ward C 8


8 Ward D 15
(05:016). 9 Ward E 4
10 Ward F 14
11 Ward G 19
12 Ward H 22
13 Ward I 14
14 Ward K 15
15 Ward L 20
16 Ward NI 27
Histogram, cont.
• 2. Create a vertical range of
cells containing the upper
bandings with which you wish
to group your data (i.e. 0-12,
13-16, 17-20, 21-24).
• 3. Highlight a vertical range of E F
cells in which you wish the 4 Bandings Frequency

analysis to be reported (F5:F9). 5 12

Note that by extending this 6 16

output range by one extra cell, 7 20

you can capture all values 24

above the maximum banding 9

(i.e. over 24).


Histogram, cont.
• 4. With the whole output range highlighted,
type the formula.
FREQUENCY(C5:C16, E5:E8) .
• 5. Do not press enter. This is an array
function and therefore requires you to use
the alternative key strokes of <Ctrl> +
<Shift> + <Enter> F
4 landings Frequency

5 12 3

6 16 5

7 20 2

8 24 1
9 1

You might also like