Discrete Event Simulation
Speaker: Lee, Chia-Peng Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.tw TEL: +886-2-33664888#538
Discrete Event Simulation Speaker: Lee, Chia-Peng Advisor: Phone - - PowerPoint PPT Presentation
Discrete Event Simulation Speaker: Lee, Chia-Peng Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.tw TEL: +886-2-33664888#538 Grading Midterm Exam 35% Final Exam 30% Final Project 30% Step 1: Find a paper
Discrete Event Simulation
Speaker: Lee, Chia-Peng Advisor: Phone Lin MCN Lab., Dept. of CSIE, NTU Email: jet.lee@pcs.csie.ntu.edu.tw TEL: +886-2-33664888#538
Grading
Midterm Exam 35% Final Exam 30% Final Project 30%
the paper
via simulation or analytical models).
Report 5%
2
Grading
Find a paper with the analytical model
http://portal.acm.org/
3
Outline
Introduction to Simulation
Simulation Implementation A Simulation Example
4
What is Simulation?
Simulation is the imitation of some real thing, state of affairs, or process. Simulation is defined as the process of creating a model of an existing or proposed system to gain some understanding of how the corresponding system behaves.
5
What is Simulation?
System Experiment and real system Experiment with an “emulation” system (real traffic input/output) Experiment with simulations and models Test it in a testing environment (with generated traffic) Put the system in the real environment and use it (with real traffic) Physical models Mathematical models (execution in no real-time, non real traffic input/output) Analysis (Queueing Therory) Simulation 6
Why Simulate? (Example)
7
landing stack
8
Why Simulate? (Example Cont.)
An Example of Simulation in the Real World
landing way is busy, the airplane in the air must enter in a stack. However, when the stack is full, the takeoff way must become landing way.
this stack, airplanes fly a holding pattern on an assigned altitude.
9
Why Simulate? (Example Cont.)
Such measures of performance can get from historical data records. However, we are interested in the impact of certain proposed changes.
Why Simulate?
Save time Reduce cost Test design ideas (performance measurement)
Predict the future behavior of the system
10 10
Simulation
Static/Dynamic Simulation
Continuous/Discrete Simulation
time
11 11
Discrete-Event Simulation
Dynamic
proceeds
another
Discrete
time.
system
12 12
a
2a
1d
3a
2d Time e
1e
2e
3e
4e
5e A1 A2 A3 S1 S2
All state changes occur only at event times for a discrete-event simulation model
time to event time
Stochastic
13
Discrete-Event Simulation
14 14
The Phase of Simulation
Construction
rate, departure rate)
Running
system’s result.
Debugging
Simulation Implementation
Programming Language
16 16
Event
may change the state of the system
Attributes of an event
Event List
Efficiency
Priority Queue in C++ Standard Template Library
priority_queue<T, Sequence, Compare>
Random Number Generator
R.N.G.’s for various probability distributions
distribution
Implementation
17 17
Inverse Transform Method
18 18
F(x)
1 Probability
X F-1(yj)
xi yj yi xj Uniform(0,1)
Inverse Transform Method
19 19
Validity of this method:
F’(x) = Pr[F-1(U) ≤ x] = Pr[U ≤ F(x)] = FU( F(x) ) = F(x)
Inverse Transform Method
20 20
Example: exponential distribution with rate
=> 1 - e-λX = U => e-λX = 1-U => -λX = ln(1-U) => X = -ln(1-U)/ λ = -ln(U)/ λ Note: u!=0
Inverse Transform Method
21 21
Applicable when the inverse function of F(x), i.e., F-1(x), can be derived Preferably when F-1(x) has an east-to-use form Steps:
number
Generating Gamma-distributed
22 22
Generating Gamma-distributed
23 23
M/M/C/C
25 25
Queueing System
Key elements: customers and servers
Notation: A/B/c/N/K
First-In-First-Out)
26 26
Queueing System
M/M/c/c
Blocking
Analysis: M/M/c/c (Erlang B)
27 27
1 2 c-1 c
λ λ λ λ λ μ 2μ (c-1)μ cμ 3μ
Simulation Models: M/M/c/c
28 28
arrival1 arrival2 departure1
Simulation Models: M/M/c/c
29 29
arrival1 arrival2 departure1 arrival3 departure2
Simulation Models: M/M/c/c
30 30
arrival1 arrival2 departure1 arrival3 departure2
Simulation Models: M/M/c/c
31 31
arrival1 arrival2 departure1 arrival3 departure2
arrival4 arrival5 arrival6 departure4
Assume that c=2 Arrival5 is Blocking Pb = N_blocking / N_arrival
Simulation Models: Event Class
32 32
Simulation Models: Initialize
33 33
實驗次數100萬次
Simulation Models: Timing Routine
34 34
if channel > 0 then channel generate service time generate next call if channel = 0 then N_blocking++ channel++
Simulation Models: Report
35 35
M/M/c/c
http://www.erlang.com/calculator/erlb
Priority Queue
36 36
Priority Queue
37 37
HANDOFF MODEL
39
A Simulation Example Handoff Model
When the network attempts to deliver a call to a handset or the handset attempts to originate a call, the call is connected if a channel is available. Otherwise, the call is blocked (referred to as the new call blocking). When a handset moves from one cell to another during a call, in order to maintain call continuation the channel in the old cell is released, and a channel is required in the new cell. This process is called hand-off. If no channel is available in the new base station, then the hand-off call is force-terminated.
40
MSC Old BS New BS MSC Old BS New BS
(a) Step 1 (b) Step 2
MSC Old BS New BS MSC Old BS New BS
(c) Step 3 (d) Step 4
A Simulation Example Handoff Model
System Model – Assumptions (1/4)
Each cell consists of
A mobile user can carry only a call We do not consider batch arrivals of new and handoff calls
41 41
System Model – Assumptions (2/4)
42
System Model – Assumptions (3/4)
Each hard handoff call can only connect to one BS.
BS1 BS2 BS3 BS4 BS5
BS1 BS2 BS3 BS4 BS5
43
System Model – Assumptions (4/4)
Wrapped mesh cell: N*N => 8*8
45
A HANDOFF event An ARRIVAL event A RELEASE event
Simulation Models: Event Design
Simulation Models: Event Design
We define three types of events for traditional calls :
(Call_type = Traditional)
call (Call_type = Traditional)
the new cell.
Traditional)
46 46
Timing Diagram for one call
47 47
tc: the call holding time of a portable. tc,i: the period between the time the portable moves into coverage area i and the time when the call is complete. tm,i: the residence time of a portable at a coverage area i. τ0: the time between the arrival of the call and when the portable moves out of coverage area 0.
Residual-life τ0
48 48
Generation of an residual-life random number for gamma residence time with the parameters (k, θ) includes the following steps: We first generate a uniform random number μ in (0, 1). Second, we generate a random number t for the gamma random variable T with the parameters (k+1, θ). By multiplying u and t, we obtain a random number for the residual τ0. τ0=U*Gamma(k+1, θ)
Yi-Bing Lin, “Random Number Generation for Residual Life of Mobile Phone Movement”, IEEE International Conference
Timing Diagram for multiple call
49
Call 1 Arrival (t=0)
Event List
Call 2 Arrival (6)
insert ARRIVAL event if channel>0 { channel-- if (service time > residence time) insert HANDOFF event else insert RELEASE event }
first call
Call 1 Handoff (t=4) Call 2 Arrival (t=6)
Timing Diagram for multiple call
50
Call 1 Arrival (t=0)
Event List
Call 2 Arrival (6) Call 1 RELEASE (t=14)
compare the service time and the residence time if (service time > residence time) insert HANDOFF event else insert RELEASE event
Call 1 Handoff (t=4) Call 2 Arrival (t=6)
if channel==0 N_Blocking++ channel++
Call 3 Arrival (t=20)
Example: Event List and Event Struct
51 51
…
Event Struct Event List
Simulation Models: Timing Routine
/* initialization */ /* generate the first event and insert it into the event list */ While(Number_of_Case <= Bound){ /* retrieve the first event from event list */ /* adjust the system clock according to the timestamp of current event */ switch(event_type){ case ARRIVAL : /*Process flowchart for ARRIVAL event */ break; case HANDOFF: /*Process flowchart for HANDOFF event */ break; case RELEASE: /*Process flowchart for RELEASE event */ break; } } /*Calculate the desired performance measures and output the result */
52 52
53 53
Flow Chart
Start (1) Set initial values (2) Generate a traditional call ARRIVAL event for each cell (3) Delete next event e from the event list according the timestamp of the event (4) Check the type of event e (6) channel available? (5) Call_Type ? (10) Call_Type ? (8) one channel is allocated to the request (9) CRt = CRt + 1; (7) The request is blocked (11) Release one channel (12) CRt = CRt - 1; (13) Call_Type ? (14) channel available? (16) one channel is allocated to the request and release old channel (17) CRt = CRt + 1; (15) The handoff request is block. Traditional NO YES Traditional Traditional NO YES ARRIVAL RELEASE HANDOFF
54 54
The notations
The new traditional call arrival rate to a cell is exponentially distributed with the rate . The call holding time for a traditional call is exponentially distributed with the mean . The UE residence time in a cell has an exponential distribution with the mean . The total channels in a cell are C. The call incompletion probability for a traditional call is Pnc,t.
Analysis and Simulation Validation
55 55
The input parameters and are normalized by . We assume there are C=10 channels per cell.
Reference
Gamma distribution
Erlang B Calculator
Latex
GNUPlot
M/M/c/c Sample Source Code
56 56