Documente Academic
Documente Profesional
Documente Cultură
Introduction to Simulation
Ways to study a system
System
Experiment
with the
actual system
expensive,
system may not exist
not typical
in this context
Experiment
with a model
of the system
Physical
model
Mathematical
model
Analytical
solution
desirable if possible,
models easily get too complex
[NwSim] Winter 2012/2013
Simulation
method of last resort?
2
Introduction to Simulation
Classification of models
model: a representation of the system for the purpose of studying the system
static/dynamic
in a static model time plays no role (e.g., Monte-Carlo simulation for certain
integrations)
a dynamic model represents a system evolving over time
deterministic/stochastic
a deterministic model has no random component, although the output of the
model is deterministic it may be impossible to obtain it analytically (e.g., a
complicated system of differential equations)
a stochastic model has some random components
discrete/continuous
in a discrete model variables change instantaneously at separated points in
time (occurring of the events)
in a continuous model variables change continuously with respect to time
(normally described by differential equations)
it is a modeling decision which kind of model is chosen to represent the system
[NwSim] Winter 2012/2013
Introduction to Simulation
Kinds of simulation
dependent on the model type (static/dynamic,
deterministic/stochastic, continuous/discrete)
here we focus on dynamic, stochastic, discrete, commonly known
as discrete-event simulation (DES)
Introduction to Simulation
Steps in a Simulation Study
(similar to software engineering, with specific simulation aspects):
Formulate problem and plan the study
Collect data and define the model
Is the conceptual model valid?
Construct a computer program and verify
Make pilot runs
Is the programmed model valid?
Design experiments
Make production runs
Analyze output data
Document, present, and use results
Disadvantages of simulation
each run of a stochastic simulation model produces only estimates of a
models true characteristics
simulation models are often expensive and time-consuming to develop
sometimes excessive run-times
the large volume of output data or the realistic animation often creates a
tendency to place more confidence in a studys result than justified
[NwSim] Winter 2012/2013
Organization of DES
Typical components in DES:
system state: the collection of state variables necessary to describe the
system at a particular time
simulation clock: a variable giving the current value of simulated time
event list: a list containing the next time when each type of event will occur
statistical counters: variables used for storing statistical information about
system performance
initialization routine: a subprogram to initialize the simulation model at
time 0
timing routine: a subprogram that determines the next event from the
event list and then advances the simulation clock to the time when that
event is to occur
Organization of DES
event routine: a subprogram that updates the system state when
a particular type of event occurs (there is one event routine for
each event type)
library routines: a set of subprograms used to generate random
observations from probability distributions that were determined
as part of the simulation model (and other statistical features)
report generator: a subprogram that computes estimates (from
the statistical counters) of the desired measures of performance
and produces a report when the simulation ends
main program: a subprogram that invokes the timing routine to
determine the next event and then transfers control to the
corresponding event routine to update the system state
appropriately. The main program may also check for termination
and invoke the report generator when the simulation is over
Organization of DES
Flow of control
10
empirical distribution
use data values to define a connect-the-dots distribution and
sample from it when needed in the simulation
fairly valid, simple, fairly direct
may limit range of generated variants, difficult to change
theoretical distribution
fit a theoretical distribution (e.g., exponential, gamma, ...) and
sample from it when needed in the simulation
compact representation with few parameters, smoothes out data
may be difficult to find good fit
[NwSim] Winter 2012/2013
11
histogram of measured
service times
(622 in this example)
12
Types of simulations
terminating simulations
specific initial and stopping conditions
measures depend on initial and stopping conditions
similar to transient analysis (but not equivalent)
13
14
15
16
customers depart
from system
waiting room
(queue)
service unit
scenario:
customers arrive randomly
infinite waiting room (unbounded queue)
one service unit with a random service time
abstract model of many systems, e.g.:
an information desk at an airport
a station in a manufacturing cell
a router in the Internet
...
the hello world of simulation and modeling
[NwSim] Winter 2012/2013
17
18
N(t)
3
2
1
0
events:
interarrival
times:
service times:
c1
t1
A2
A1
times in system:
t2
t3
A3
S1
D1
c2
A4
c3
S3
D2
t5
A5
S2
t4
W3
D3
19
Main principles
Input modeling (!)
characterization of randomness by input parameters
based on data fitting with measurements
Computer representation
model paradigm (textual/visual, event-/process-/object-oriented, ...)
random number generation
event list processing (!)
20
histogram of measured
service times
(622 in this example)
21
Algorithm:
initialization
routine
timing routine
event routine
(one per event type)
report generator
22
t
0
t1
c1
t2
t3
c2
t4
t5
c3
23
24
D vs. U:
(steep increase as U 1)
Results from discrete
simulation
15
10
5
0
0.2
0.4
0.6
0.8
25