Chapters 1, 2 & 3: A Brief...
Transcript of Chapters 1, 2 & 3: A Brief...
![Page 1: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/1.jpg)
1
Chapters 1, 2 & 3:A Brief Introduction
©Barry L. NelsonNorthwestern University
July 2017
![Page 2: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/2.jpg)
Why do we simulate?
• We typically choose to simulate a dynamic, stochastic system when the performance measure we want…– Is not analytically tractable.– Is not computationally tractable.– Cannot be approximated with a bound on the
error.
• Let's start with a very simple example to remind us what we are doing and why.
2
![Page 3: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/3.jpg)
3
Discrete-event simulation example
![Page 4: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/4.jpg)
4
![Page 5: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/5.jpg)
5
![Page 6: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/6.jpg)
6
Features
![Page 7: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/7.jpg)
7
Outputs
![Page 8: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/8.jpg)
8
Time averages
![Page 9: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/9.jpg)
9
Performance measures
![Page 10: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/10.jpg)
10
This book
![Page 11: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/11.jpg)
Structure of a discrete-event simulation
• Main program– Initialize state variables,
clock, statistics– Schedule at least one
future event– Simulation loop: Until
ending condition met• Call Timer to find next
event• Call event subprogram
– Final update of statistics and report results
• Timer subprogram– Remove next event from
event calendar– Advance clock– Return event type
• Event subprograms– Update state variables– Schedule any future
events– Update statistics
![Page 12: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/12.jpg)
12
Dim Clock As Double ' simulation clockDim NextFailure As Double ' time of next failure eventDim NextRepair As Double ' time of next repair eventDim S As Double ' system stateDim Slast As Double ' previous value of the system stateDim Tlast As Double ' time of previous state changeDim Area As Double ' area under S(t) curve
Private Function Timer() As StringConst Infinity = 1000000
' Determine the next event and advance timeIf NextFailure < NextRepair Then
Timer = "Failure"Clock = NextFailureNextFailure = Infinity
ElseTimer = "Repair"Clock = NextRepairNextRepair = Infinity
End IfEnd Function
Global declarations
Programming quick start
![Page 13: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/13.jpg)
13
Private Sub TTF()' Program to generate a sample path for the TTF example
Dim NextEvent As StringConst Infinity = 1000000Rnd (-1)Randomize (1234)
' Initialize the state and statistical variablesS = 2Slast = 2Clock = 0Tlast = 0Area = 0
' Schedule the initial failure eventNextFailure = WorksheetFunction.Ceiling(6 * Rnd(), 1)NextRepair = Infinity
' Advance time and execute events until the system failsDo Until S = 0
NextEvent = TimerSelect Case NextEventCase "Failure"
Call FailureCase "Repair"
Call RepairEnd Select
Loop
' Display outputMsgBox ("System failure at time " _
& Clock & " with average # functional components " & Area / Clock)End
End Sub
![Page 14: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/14.jpg)
14
Private Sub Failure()' Failure event' Update state and schedule future events
S = S - 1If S = 1 Then
NextFailure = Clock + WorksheetFunction.Ceiling(6 * Rnd(), 1)NextRepair = Clock + 2.5
End If
' Update area under the S(t) curveArea = Area + Slast * (Clock - Tlast) Tlast = ClockSlast = S
End Sub
Private Sub Repair()' Repair event' Update state and schedule future events
S = S + 1If S = 1 Then
NextRepair = Clock + 2.5NextFailure = Clock + WorksheetFunction.Ceiling(6 * Rnd(), 1)
End If
' Update area under the S(t) curveArea = Area + Slast * (Clock - Tlast) Tlast = ClockSlast = S
End Sub
![Page 15: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/15.jpg)
Important Computer Simulation Concepts
15
U X YSource of randomness, usually assumed i.i.d. U(0,1)
Input random variables with known distributions that we specify; ex: component TTF is DU(1,2,3,4,5,6)
Output random variables whose properties we want to estimate; ex: system TTF
algorithm logic
![Page 16: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/16.jpg)
Random-number generation
16
![Page 17: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/17.jpg)
Random-variate generation
17
![Page 18: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/18.jpg)
Replications
18
![Page 19: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/19.jpg)
19
Private Sub TTFRep()' Program to generate a sample path for the TTF example
Dim NextEvent As StringConst Infinity = 1000000Rnd (-1)Randomize (1234)
' Define and initialize replication variablesDim Rep As IntegerDim SumS As Double, SumY As DoubleSumS = 0SumY = 0For Rep = 1 To 100
' Initialize the state and statistical variablesS = 2Slast = 2Clock = 0Tlast = 0Area = 0
' Schedule the initial failure eventNextFailure = WorksheetFunction.Ceiling(6 * Rnd(), 1)NextRepair = Infinity
' Advance time and execute events until the system failsDo Until S = 0
NextEvent = TimerSelect Case NextEvent
Case "Failure"Call Failure
Case "Repair"Call Repair
End SelectLoop
' Accumulate replication statisticsSumS = SumS + Area / ClockSumY = SumY + Clock
Next Rep' Display output
MsgBox ("Average failure at time " _& SumY / 100 & " with average # functional components " & SumS / 100)
EndEnd Sub
Replication version of TTF
Initialize random number generator
![Page 20: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/20.jpg)
Canonical examples
• To illustrate things as we go along we will use 4 ½ small examples that are– Easy to simulate.– Don't actually need to be simulated (they are
pretty tractable).
• This will allow us to see the issues that arise in general without getting buried in details.
• These examples are also useful for testing new ideas in simulation.
20
![Page 21: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/21.jpg)
M(t)/M/∞ queue
• A queue with "ample" (infinite) servers. Used to design systems that should have adequate capacity nearly always.
• Arrivals are described by a nonstationaryPoisson arrival process with rate λ(t).
• Service times are independent and identically distributed exponential with finite mean τ.
• Examples: parking lot for large mall; cell phone system.
21
![Page 22: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/22.jpg)
22
More on M(t)/M/∞
![Page 23: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/23.jpg)
23
λ(t)
Mean number of cars in the garage m(t)
Distribution of number in the garage at mean m*
![Page 24: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/24.jpg)
Simulation issues
• How do we simulate a nonstationary arrival process?
• How do we program a simulation that could (conceptually) have nearly an infinite number of "car departure" events?
• What relevant performance measure can we actually get out of a simulation?
24
![Page 25: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/25.jpg)
25
Stochastic activity network (SAN)
![Page 26: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/26.jpg)
26
More on the SAN
![Page 27: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/27.jpg)
27
Simulation issues
![Page 28: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/28.jpg)
M/G/1 queue
• A single-queue, first-come-first-served service system with one server.
• Arrivals are described by a stationary Poisson arrival process (interarrivals exponential 1/λ)
• Service times are independent and identically distributed with finite mean τ and standard deviation σ.
• Examples: video kiosk, ticket window, ATM machine, receptionist.
28
![Page 29: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/29.jpg)
29
M/G/1 & Lindley's equation
![Page 30: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/30.jpg)
30
What is known?
![Page 31: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/31.jpg)
Simulation issues
• The quantities of interest are defined in the limit; easy (sometimes) mathematically; hard (nearly always) in simulation.
• The experiment design is not so clear: One very long run or multiple replications?
• As ρ→ 1 both the mean and the variability of Y explode (e.g., the standard deviation of Ygrows as 1/(1-ρ)).
31
![Page 32: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/32.jpg)
The AR(1) surrogate model
32
![Page 33: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/33.jpg)
33
Asian option
![Page 34: Chapters 1, 2 & 3: A Brief Introductionusers.iems.northwestern.edu/~nelsonb/IEMS435/Chapter1-2-3.pdf · Chapters 1, 2 & 3: A Brief Introduction ©Barry L. Nelson. Northwestern University.](https://reader033.fdocuments.net/reader033/viewer/2022051808/600a78780a7467252d26f2ec/html5/thumbnails/34.jpg)
Simulation issues
34