Contemporary methods of discrete event simulation Mike Pidd Department of Management Science Lancaster University Management School UK [email protected]
Contemporary methods of discrete event simulation
Mike Pidd
Department of Management Science
Lancaster University Management School
UK
2
Some simulation application areas
Manufacturing - plant layout & sizing, plant
'optimisation', process design
Health care - clinic planning, blood transfusion
services, AIDS transmission, renal dialysis services
Business process improvement
Air travel - airport operations, air traffic control
Road transport - traffic simulations, on-line traffic
control
Emergency planning - evacuation modelling
Military - battle plans, scenario analysis
3
Why simulate?
Mathematical models
may be too simplified
often intractable
Real experimentation
expensive
slow (or too fast!)
dangerous
may be illegal
often can‟t be replicated
Surely
there‟s a
better way?
To support the careful analysis of decisions and
plans before any implementation
4
Computer simulation: basics
Dynamic
model(s)
Inputs (policies) Outputs (responses)
Interaction
Experimentation on a dynamic system model
Activities in computer simulation5
Modelling
ComputingExperimenting
Abstracting and
representing the main
features of the system
of interest
Producing a
model than can
be run on a PC
or other
computer
Using the
model to
explore
options or gain
understanding
It often becomes difficult to separate these
Discrete event simulation Stochastic behaviour
Next event time handling
Focus on individual entities (e.g. machines, people, vehicles)
Software: Micro Saint, Simul8, Witness etc
System dynamics Deterministic behaviour
Time slicing
Focus on rates of change of populations (e.g. birth rates, sales rates)
Software: Vensim, Powersim, IThink
Multi-agent based Focus on large number of (semi) autonomous agents
Time slicing
Rules govern agent interactions and behaviour
Software: Swarm, Repast etc
Simulation approaches in management science
6
7
Discrete event simulation models
Discrete entities: e.g. people, machines, vehicles, jobs, orders, patients Change state as the simulation proceeds
State changes individually tracked during the simulation
Discrete events: times at which the entities change state.
E.g. 2:00 pm lecture stats, 3:00 pm patient discharged Some may be exogenous (externally generated)
e.g. injecting new customers into a simulation
Some will be endogenous (internally generated by the interaction of entities)
e.g. repairman starts work on damaged machine
System is simulated by managing the state changes of the entities
8
DES time-handling options
Fixed time increment - time slicing
Move time along in pre-determined chunks
Analogy – time-lapse photography
PROBLEM : need to know time slice in advance, but system's activity may vary.
Variable time increment - next event technique
Keep track of when events are due
Move from event to event, ignoring in-between
System activity drives the simulation
9
Time slicing
Time
x
Time-sliced approximation
Data series
10
Simple job-shop
Machine
A
Machine
B
Orders Finished jobs
Time = 1 + (batch size)/50 Time = 3 + (batch size)/100
Order number Batch size Day expected
1 200 1
2 400 8
3 100 14
4 200 18
11
Job-shop: time slicing
Job # Due TimeA TimeB
1 1 5 5
2 8 9 7
3 14 3 4
4 18 5 5
Day QA QB OnA OnB
1
2
3
4
5
6
7
8
9
10
- 1- -
- - -1
- - -
1
- - -
1- - -1
- - - 1
- - - 1
- -
1
2
- -
1
2
- - 12
12
Next event simulation
Job
# Arrival day
Machine A Machine B
Start day End day Start day End day
1
2
3
4
13
Time slicing simulation, 32 events
Day Jobs queuing Jobs in progress Day Jobs queuing Jobs in progress
for m/c A for m/c B m/c A m/c B for m/c A for m/c B m/c A m/c B
1 - - 1 - 17 - - 3 2
2 - - 1 - 18 4 - 3 2
3 - - 1 - 19 4 - 3 2
4 - - 1 - 20 - 3 4 2
5 - - 1 - 21 - 3 4 2
6 - - - 1 22 - 3 4 2
7 - - - 1 23 - 3 4 2
8 - - 2 1 24 - - 4 3
9 - - 2 1 25 - 4 4 3
10 - - 2 1 26 - 4 - 3
11 - - 2 - 27 - 4 - 3
12 - - 2 - 28 - - - 4
13 - - 2 - 29 - - - 4
14 3 - 2 - 30 - - - 4
15 3 - 2 - 31 - - - 4
16 3 - 2 - 32 - - - 4
14
DES modelling: next event time handling
Variable time increment -next event technique
Keep track of when events are due
Move from event to event, ignoring in-between
System activity drives the simulation
Start, time, t=0
Do all events due
at time t
Simulation
over?
Stop
No
Yes
Schedule
future events
on calendarFind time of
next event(s)
in calendar
Move t to time
of next event
Requires
•„Diary‟ for future
commitments (event calendar,
event list, event queue, …)
•Simulation executive
15
DES modelling: stochastic behaviour
Deterministic
All durations of activities entirely predictable and
known. System runs like clockwork.
Stochastic
Durations of activities can only be known
probabilistically.
Hence need to simulate this variation by taking
samples from appropriate probability distributions.
The simulation is a sampling experiment which needs
to be replicated.
Dangers in stochastic simulations
Profit
Prob
Profit
Prob
A BA B
Large risk of
wrong inference
Random sampling leads to sampling variation and to
sampling errors. Need careful analysis.
16
-1200
-1000
-800
-600
-400
-200
0
200
400
600
800
1000
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49
Cost Diff
Mean
UCL
LCL
The problem of inference…
17
Notice we‟re still unable to be sure if
Z is +ve or –ve, after 50 replications
Simple example: 2 policies, (A & B) which produce most profit?
Suppose Z = Profit(A) – Profit(B)
18
Problem of sampling variation
Confidence in results improves with number
of independent replicates (n)
But only with the square root of n
The sequence in which the replicates occur
can make a difference
Need to be very careful when analysing DES
output
nsreplicatiot independen n from meanx where
. CIn
sx α
GMP OCRSim
Time handling
Next event technique throughout
Each call handled individually
Each police response is individual
Stochastic sampling
Call volumes (vary by day & time of day)
Time to deal with each call
19
20
No specialties
By specialty
DGHPSim: time handling & sampling20
Emergencies
to A&EA&E model Admit?
Discharged
Inpatient
waiting list
model
Inpatient
model
Emergency GP referrals
Outpatient
model
Diagnostics
Admit?GP elective
referrals
DGHPSim time handling
Time handling
Accident & emergency: next event technique, individual patients &
treatment
Outpatient model: daily arrivals and clinics (time slicing)
Inpatient model: next event technique, individual patients &
treatments from waiting list.
Stochastic sampling
Patient arrivals (vary by day & time of day)
Treatment times (inpatient & outpatient)
Type of patient (case mix)
Time spent on wards
Movement between wards
21
22
Discrete event simulation software
Two main options
Write a
simulation
program
Use a visual
interactive
modelling system
(VIMS)
23
Writing a simulation program
Can use almost any programming language
General purpose: e.g. C, C++, C#, Java, Pascal, VB
Simulation language: e.g. MODSIM, Simscript, Simula
Can develop a library for re-use
Allows bespoke application development
BUT
Requires good programming skills
Program development is slow
Rarely done outside defence & academe
24
Features of VIMS
Graphical interface Pre-defined objects
Drag & drop
Property sheets
Some degree of programmability Own „language‟
Relatively self-contained Model building
Model execution
Experimental control & analysis
Hide the hard bits
Arena
Automod
Extend
GoldSim
Micro Saint
ProModel
SimProcess
Simul8
Taylor II
Witness
…etc…
25
Micro Saint Sharp: a typical VIMS
Network diagram: sequence of tasks through which
entities flow
State changes (events) occur at task beginning or end, e.g.
Begin Inspect: Joe from Idle to Busy, Queue reduced by 1
End Inspect: Joe from Busy to Idle, Car leaves or waits for repair
26
VIMS are great … but …
Often over-sold
“In just x minutes (x <10) you can build a fully
working model …”
Need programming skills for realistic modelling
Knowing Excel macros may not be enough
Built-in languages usually proprietary
Why do this when dot.net allows other approaches?
Can be useful to know how the engine works
27
Some current research at Lancaster
Component-based modelling Users assemble only the components they need
Possible pay per use basis
Integration through Microsoft .net or similar
Distributed simulation For large problems on high performance computers
Policy modelling Health care – but not at clinic or specialty level
Use to check feasibility of options: e.g. waiting times for elective surgery
Conceptual modelling Developing representations that are independent of computer
software
Value of agent-based modelling