issues in simulation

26
Issues in Simulation 2110636 Performance Evaluation and Analysis Asst. Prof. Natawut Nupairoj, Ph.D. Department of Computer Engineering Chulalongkorn University

Upload: others

Post on 14-Jan-2022

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Issues in Simulation

Issues in Simulation

2110636 Performance Evaluation and AnalysisAsst. Prof. Natawut Nupairoj, Ph.D.Department of Computer EngineeringChulalongkorn University

Page 2: Issues in Simulation

Outline

• States of Simulation• Removing Initial Bias• Simulation Termination

2110636 Performance Evaluation and Analysis

Page 3: Issues in Simulation

Common Mistakes in Simulation

• Improperly handled initial conditions– Often, initial trajectory not representative of steady state• Including can lead to inaccurate results

– Typically want to discard, but need method to do so effectively

• Too short simulation runs– Makes even more dependent upon initial conditions– Correct length depends upon the accuracy desired

(confidence intervals)– Variance estimates

2110636 Performance Evaluation and Analysis

Page 4: Issues in Simulation

Simulation States: Single Server(3-process.py)

2110636 Performance Evaluation and Analysis

Page 5: Issues in Simulation

Simulation States: Single ServerLonger Run

2110636 Performance Evaluation and Analysis

Page 6: Issues in Simulation

Simulation States: Single Server2 Runs

2110636 Performance Evaluation and Analysis

Page 7: Issues in Simulation

Simulation States: Single ServerMultiple Runs

2110636 Performance Evaluation and Analysis

Page 8: Issues in Simulation

Simulation States: Single ServerMultiple Runs

2110636 Performance Evaluation and Analysis

Page 9: Issues in Simulation

States of Simulation

2110636 Performance Evaluation and Analysis

Transient-StateInterval

Steady-StateInterval

Page 10: Issues in Simulation

Transient Removal

• Most simulations only want steady state– Remove initial transient state

• Trouble is, not possible to define exactly what constitutes end of transient state

• Use heuristics:– Long runs– Proper initialization– Truncation– Initial data deletion– Moving average of replications– Batch means

2110636 Performance Evaluation and Analysis

Page 11: Issues in Simulation

Long Runs

• Use very long runs• Effects of transient state will be amortized• But … wastes resources• And tough to choose how long is “enough”• Recommendation … don’t use long runs alone

2110636 Performance Evaluation and Analysis

Page 12: Issues in Simulation

Proper Initialization

• Start simulation in state close to expected state

• Ex: CPU scheduler may start with some jobs in the queue

• Determine starting conditions by previous simulations or simple analysis

• May result in decreased run length, but still may not provide confidence that are in stable condition

2110636 Performance Evaluation and Analysis

Page 13: Issues in Simulation

2110636 Performance Evaluation and Analysis

Truncation

• Assume variability during steady state is less than during transient state

• Variability measured in terms of range – (min, max)

• If a trajectory of range stabilizes, then assume that in stable state

• Method:– Given n observations

{x1, x2, …, xn} – ignore first k

observations– Calculate (min,max) of

remaining n-k– Repeat for k = 1…n– Stop when (k+1)th

observation is neither min nor max

Page 14: Issues in Simulation

2110636 Performance Evaluation and Analysis

Truncation Example• Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9,

10, 11, 10, 9, 10, 11, 10, 9…• k=1, ignore observation #0, range

is (2, 11) and observation #1 (value=2) is the min

• k=2, ignore observation# 0 and #1, range is (3,11) and observation #2 (value=3) is min

• Finally, k=9 and range is (9, 11) and observation #9 (value=10) is neither min nor max

• So, discard first 9 observations

TransientInterval

Page 15: Issues in Simulation

2110636 Performance Evaluation and Analysis

Truncation Example 2 (1 of 2)

• Find duration of transient interval for:– 11, 4, 2, 6, 5, 7, 10, 9, 10,

9, 10, 9, 10

Page 16: Issues in Simulation

2110636 Performance Evaluation and Analysis

Truncation Example 2

• Find duration of transient interval for:– 11, 4, 2, 6, 5, 7, 10, 9, 10,

9, 10, 9, 10

• When k=1, range is (2,10) and observation #1 (value=4) is not min or max

• So, discard only 1 observation instead of 6

“Real” transient

Assumed transient

Page 17: Issues in Simulation

Our Single Server Example 𝜆 = !!"

𝜇 = !#

2110636 Performance Evaluation and Analysis

Page 18: Issues in Simulation

2110636 Performance Evaluation and Analysis

Moving Average of Independent Replications• Compute mean over moving time window• Given m replications size n each, let xij be the

j-th observation of i-th replication• Get mean trajectory

!𝑥! =1𝑚&"#$

%

𝑥"! 𝑗 = 1,2, …𝑛

• Set k=1. Plot moving average of 2k+1 values:

𝑀𝑉𝐴& !𝑥! =1

2𝑘 + 1&'#(&

&

𝑥!)'

With j=k+1, k+2,…,n-k

• Repeat for k=2,3… and plot until smooth• Find knee. Value at j is length of transient

phase.

$𝑥1

j

𝑀𝑉𝐴

2$𝑥 1

j

transientinterval

knee

Page 19: Issues in Simulation

2110636 Performance Evaluation and Analysis

Get Mean Trajectory

Page 20: Issues in Simulation

Calculate 𝑀𝑉𝐴! $𝑥"

2110636 Performance Evaluation and Analysis

Page 21: Issues in Simulation

Terminating Simulation

• Important to run long enough– Stopping too short may give variable results– Stopping too long may waste resources

• There are several techniques– Confidence intervals– Variance of sample mean of independent observations– independent replications– batch means

2110636 Performance Evaluation and Analysis

Page 22: Issues in Simulation

Simulation States: Single ServerMultiple Runs

2110636 Performance Evaluation and Analysis

When should we stop?

Page 23: Issues in Simulation

Stopping Criteria: Confidence Interval

• Stop when width of confidence interval of a specified metric is within a given percentage of the mean

𝐶𝐼 = �̅� ± 𝑧!)*/,𝑠𝑛

• Variance of sample mean of independent observations• But only if observations independent! Most

simulations not• Ex: if queuing delay for packet i is large then will likely be

large for packet i+1• So, use: independent replications

2110636 Performance Evaluation and Analysis

Page 24: Issues in Simulation

Independent Replications• Assume replications are independent

– Different random seed values

• Collect m replications of size n+n0 each– n0 is length of transient phase

• Mean for each replication

$𝑥3 =1𝑛

0145!67

5!65

𝑥31 𝑖 = 1,2, …𝑚

• Overall mean for all replications

�̿� =1𝑚0347

8

$𝑥3

2110636 Performance Evaluation and Analysis

Page 25: Issues in Simulation

Stopping Criteria: Confidence Interval

• Calculate variance of replicate means

𝑉𝑎𝑟 �̅� =1

𝑚 − 10347

8

(𝑥3 − �̅� )9

• Confidence interval is

�̿� ± 𝑧7:;/9𝑉𝑎𝑟[�̅�]𝑚

• We will stop when

2 𝑧7:;/9𝑉𝑎𝑟[�̅�]𝑚

�̿�< 𝑟%

Note: if m < 30, we will use 𝑡!"#/% (with degree of freedom = m-1) instead of 𝑧!"#/%

2110636 Performance Evaluation and Analysis

Page 26: Issues in Simulation

2110636 Performance Evaluation and Analysis

Confidence Interval of Response Time of Single Server (95% confidence level)