Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
AN INTRODUCTION TODISCRETE-EVENT SIMULATION
Peter W. Glynn1 Peter J. Haas2
1Dept. of Management Science and EngineeringStanford University
2IBM Almaden Research CenterSan Jose, CA
IMA Workshop, May 12, 2008
CAVEAT: WE ARE NOT BIOLOGISTS OR CHEMISTS!
Outline
I Overview of discrete-event simulationI Basic models for discrete-event stochastic systems
I Generalized semi-Markov processes (GSMPs)I Continuous-time Markov chains (CTMCs)I Stochastic Petri nets (SPNs)
I Some important techniques for simulationI Efficiency improvementI Sensitivity estimationI Parallel simulation
Glynn and Haas3 IMA Workshop, May 12, 2008
Part I
Overview
Glynn and Haas4 IMA Workshop, May 12, 2008
Discrete-Event Stochastic Systems
I Finite or countably infinite set of statesI System changes state when events occur
I Stochastic state changesI At strictly increasing random times
I Underlying stochastic process {X (t) : t ≥ 0 }I X (t) = state of system at time t (a random variable)
I Ex: Xi (t) = # molecules of ith species at time t
Glynn and Haas5 IMA Workshop, May 12, 2008
Simulation: A Tool for Studying DESS Characteristics
I Characteristics often of the form α = E [Y ]I Y = f
(X (t)
), e.g., Y = I (X (t) = x)
I Y = (1/t)∫ t
0f(X (u)
)du
I Y = min{ t > 0: X (t) ∈ A }
Glynn and Haas6 IMA Workshop, May 12, 2008
Other Characteristics
I Nonlinear functions of means: g(α1, α2, . . . , αk)I Apply Delta Method, jackknifing, bootstrapping, etc.
I Steady-state characteristicsI Time-average limits:
α = limt→∞
1
t
∫ t
0
f(X (u)
)du
I Steady-state means:
α = E [f (X )], where X (t)⇒ X
I Apply regenerative method, batch means, STS methods, etc.I Key issues of stability and validity
I For more details: buy us a beer
Glynn and Haas7 IMA Workshop, May 12, 2008
Part II
Models for Discrete-Event Systems
Glynn and Haas8 IMA Workshop, May 12, 2008
Generalized Semi-Markov Processes
I Classical model for discrete-event stochastic systemsI Building blocks
I S = set of states (finite or countably infinite)I E = set of events (finite)I E (s) = active events in state sI p(s ′; s, e∗) = state-transition probability
I One clock per event: records remaining time until occurrence
Glynn and Haas9 IMA Workshop, May 12, 2008
Clocks (Event Scheduling)
I Active events compete to trigger state transitionI The clock that runs down to 0 first is the “winner”I Can have simultaneous event occurrence: p(s ′; s,E∗)
I At a state transition se∗→ s ′: three kinds of events
I New events: Clock for e′ set according to F (x ; s ′, e′, s, e∗)I Old events: Clocks continue to run downI Cancelled events: Clock readings are discarded
I Clocks run down at state-dependent speeds r(s, e)
Glynn and Haas10 IMA Workshop, May 12, 2008
The GSMP Process
I The continuous-time process: {X (t) : t ≥ 0 }I X (t) = the state at time tI A very complicated process
I Defined in terms of Markov chain { (Sn,Cn) : n ≥ 0 }I System observed after the nth state transitionI Sn = the stateI Cn = (Cn,1, . . . ,Cn,M) = the clock-reading vectorI Chain defined via GSMP building blocks
Glynn and Haas11 IMA Workshop, May 12, 2008
Definition of the GSMP
Glynn and Haas12 IMA Workshop, May 12, 2008
Generation of the GSSMC { (Sn, Cn) : n ≥ 0 }
1. [Initialization] Set n = 0. Generate state S0 and clockreadings C0,i for ei ∈ E (S0); set C0,i = −1 for ei 6∈ E (S0).
2. Determine holding time t∗(Sn,Cn) and trigger event e∗n .
3. Generate new state Sn+1 according to p( · ;Sn, e∗n).
4. Set clock-reading Cn+1,i for each new event ei according toF ( · ;Sn+1, ei ,Sn, e
∗n).
5. Set clock-reading Cn+1,i for each old event ei asCn+1,i = Cn,i − t∗(Sn,Cn)r(Sn, ei ).
6. Set clock-reading Cn+1,i equal to −1 for each cancelled eventei .
7. Set n← n + 1 and go to Step 2.
Can compute GSMP {X (t) : t ≥ 0 } from GSSMC
Glynn and Haas13 IMA Workshop, May 12, 2008
Implementation Considerations for Large-Scale GSMPs
I Use event lists (e.g., heaps) to determine e∗
I O(1) computation of e∗
I O(log m
)update time, where m = # of active events
Glynn and Haas14 IMA Workshop, May 12, 2008
Continuous-Time Markov Chains
I Time-homogeneous Markov property:
P{
X (t + h) = s ′ | X (t) = s,X (u) = x(u) for 0 ≤ u < t}
= P{
X (t + h) = s ′ | X (t) = s}
= ph(s, s′)
I CTMC specified by intensity matrix Q
Q(s, s ′) = limh↓0
ph(s, s′)
h, s 6= s ′
Q(s, s) = −∑s′ 6=s
Q(s, s ′)
I Define state intensity q(s) = −Q(s, s) =∑
s′ 6=s Q(s, s ′)
Glynn and Haas15 IMA Workshop, May 12, 2008
Simulating a CTMC (Gillespie Algorithm)
I Thm (path structure of a CTMC):I Sequence of visited states is a DTMCI Given states, holding times are indep. and exponential
1. [Initialization] Set n = 0. Generate state S0.
2. Generate holding time t∗(Sn) as Exponential(q(Sn)
).
3. Generate next state Sn+1 (6= Sn) according to Q(Sn, · )/q(Sn).
4. Set n← n + 1 and go to Step 2.
I A CTMC can be viewed as a GSMP with one exponentialclock!
Glynn and Haas16 IMA Workshop, May 12, 2008
CTMCs and GSMPs
I Theorem: Let {X (t) : t ≥ 0 } be a GSMP such that
F (x ; s ′, e ′, s, e∗) ≡ 1− e−λ(e′)x for each e ′
Then {X (t) : t ≥ 0 } is a CTMC with intensity matrix
Q(s, s ′) =∑
e∈E(s)
λ(e)r(s, e)p(s ′; s, e), s ′ 6= s
I Under conditions of theorem, GSMP simulation algorithm cansimplify to CTMC algorithm!
I OR can simulate CTMC using one exponential clock per eventI GSMPs with unit exponential clocks and time-varying speeds
I Glasserman (1991, Ch. 6): hazard-rate constructionI Anderson (2007): application to chemical reaction systems
Glynn and Haas17 IMA Workshop, May 12, 2008
Stochastic Petri Nets
I D = finite set of places
I E = finite set of transitions (timed and immediate)
I marking = assignment of token counts to places
Glynn and Haas18 IMA Workshop, May 12, 2008
Stochastic Petri Nets
I D = finite set of places
I E = finite set of transitions (timed and immediate)
I marking = assignment of token counts to places
Glynn and Haas18 IMA Workshop, May 12, 2008
Stochastic Petri Nets
I D = finite set of places
I E = finite set of transitions (timed and immediate)
I marking = assignment of token counts to places
Glynn and Haas18 IMA Workshop, May 12, 2008
Stochastic Petri Nets
I D = finite set of places
I E = finite set of transitions (timed and immediate)
I marking = assignment of token counts to places
Glynn and Haas18 IMA Workshop, May 12, 2008
Stochastic Petri Nets
I D = finite set of places
I E = finite set of transitions (timed and immediate)
I marking = assignment of token counts to places
Glynn and Haas18 IMA Workshop, May 12, 2008
Stochastic Petri Nets
s = (2, 1, 1)
d1 d2
d3
I D = finite set of places
I E = finite set of transitions (timed and immediate)
I marking = assignment of token counts to places
Glynn and Haas18 IMA Workshop, May 12, 2008
Transition Firing
I The marking changes when an enabled transition fires
I Removes 1 token per place from random subset of input places
I Deposits 1 token per place in random subset of output places
Glynn and Haas19 IMA Workshop, May 12, 2008
Transition Firing
I The marking changes when an enabled transition fires
I Removes 1 token per place from random subset of input places
I Deposits 1 token per place in random subset of output places
Glynn and Haas19 IMA Workshop, May 12, 2008
Transition Firing
I The marking changes when an enabled transition fires
I Removes 1 token per place from random subset of input places
I Deposits 1 token per place in random subset of output places
Glynn and Haas19 IMA Workshop, May 12, 2008
Transition Firing
I The marking changes when an enabled transition fires
I Removes 1 token per place from random subset of input places
I Deposits 1 token per place in random subset of output places
Glynn and Haas19 IMA Workshop, May 12, 2008
Transition Firing
I The marking changes when an enabled transition fires
I Removes 1 token per place from random subset of input places
I Deposits 1 token per place in random subset of output places
Glynn and Haas19 IMA Workshop, May 12, 2008
Transition Firing
I The marking changes when an enabled transition fires
I Removes 1 token per place from random subset of input places
I Deposits 1 token per place in random subset of output places
Glynn and Haas19 IMA Workshop, May 12, 2008
Transition Firing
p(s ′; s, e∗)
I The marking changes when an enabled transition fires
I Removes 1 token per place from random subset of input places
I Deposits 1 token per place in random subset of output places
Glynn and Haas19 IMA Workshop, May 12, 2008
SPNs and GSMPs
I SPN marking = GSMP state
I SPN transition firing = GSMP event occurrenceI Differences
I SPN has specific form of stateI SPN has restrictions on allowable state transitionsI SPN has immediate transitions
I SPN and GSMP have same modeling power
Glynn and Haas20 IMA Workshop, May 12, 2008
Bottom-Up and Top-Down Modeling
Glynn and Haas21 IMA Workshop, May 12, 2008
Bottom-Up and Top-Down Modeling
Glynn and Haas21 IMA Workshop, May 12, 2008
Bottom-Up and Top-Down Modeling
Glynn and Haas21 IMA Workshop, May 12, 2008
Bottom-Up and Top-Down Modeling
Glynn and Haas21 IMA Workshop, May 12, 2008
Bottom-Up and Top-Down Modeling
Glynn and Haas21 IMA Workshop, May 12, 2008
Bottom-Up and Top-Down Modeling
Glynn and Haas21 IMA Workshop, May 12, 2008
Other Modeling Features
Glynn and Haas22 IMA Workshop, May 12, 2008
Other Modeling Features
Concurrency:
Glynn and Haas22 IMA Workshop, May 12, 2008
Other Modeling Features
Concurrency: Synchronization:
Glynn and Haas22 IMA Workshop, May 12, 2008
Other Modeling Features
Concurrency: Synchronization:Synchronization:
Glynn and Haas22 IMA Workshop, May 12, 2008
Other Modeling Features
Concurrency: Synchronization:Synchronization:
Precedence:
Glynn and Haas22 IMA Workshop, May 12, 2008
Other Modeling Features
Concurrency: Synchronization:Synchronization:
Precedence:Precedence:
Glynn and Haas22 IMA Workshop, May 12, 2008
Other Modeling Features
Concurrency: Synchronization:Synchronization:
Precedence:Precedence:Precedence:
Glynn and Haas22 IMA Workshop, May 12, 2008
Other Modeling Features
Concurrency: Synchronization:Synchronization:
Precedence:Precedence:Precedence: Priority:
Glynn and Haas22 IMA Workshop, May 12, 2008
Implementation Advantages for Large-Scale SPNs
I Updating the state is often simpler in an SPN than a GSMPI Efficient techniques for event scheduling [Chiola91]
I Encode transitions potentially affected by firing of ei
I Parallel simulation of subnetsI E.g., Adaptive Time Warp [Ferscha & Richter PNPM97]I Guardedly optimisticI Slows down local firings based on history of rollbacks
Glynn and Haas23 IMA Workshop, May 12, 2008
For Further Details:
I Asmussen and Glynn: Stochastic Simulation: Algorithms andAnalysis, Springer, 2007
I MS-level lecture notes:http://eeclass.stanford.edu/msande223/
I Haas: Stochastic Petri Nets: Modelling, Stability, Simulation,Springer, 2002
Glynn and Haas24 IMA Workshop, May 12, 2008