Professional Documents
Culture Documents
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
Scheduled Arrivals
First customer
arrives at time 0
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
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
[
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:
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
I
• •
418 1
0 5 10 15 20 25 30 35 40 45 50
-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)
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
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
5 12 3
6 16 5
7 20 2
8 24 1
9 1