Week 4-Introduction To Simulations
Week 4-Introduction To Simulations
Simulations
Overview
• Simulation: Key Questions
• Common Mistakes in Simulation
• Other Causes of Simulation Analysis Failure
• Checklist for Simulations
• Terminology
• Types of Models
2
Simulation: Key Questions
• What are the common mistakes in simulation and why most simulations
fail?
• What language should be used for developing a simulation model?
• What are different types of simulations?
• How to schedule events in a simulation?
• How to verify and validate a model?
• How to determine that the simulation
has reached a steady state?
• How long to run a simulation?
3
Common Mistakes in Simulation
1. Inappropriate Level of Detail:
More detail Þ More time Þ More Bugs Þ More CPU
Þ More parameters ¹ More accurate
2. Improper Language
General purpose Þ More portable, More efficient, More time
3. Unverified Models: Bugs
4. Invalid Models: Model vs. reality
5. Improperly Handled Initial Conditions
6. Too Short Simulations: Need confidence intervals
7. Poor Random Number Generators: Safer to use a well-known generator
8. Improper Selection of Seeds: Zero seeds, Same seeds for all streams
4
Other Causes of Simulation Analysis Failure
1. Inadequate Time Estimate
2. No Achievable Goal
3. Incomplete Mix of Essential Skills
(a) Project Leadership
(b) Modeling and
(c) Programming
(d) Knowledge of the Modeled System
4. Inadequate Level of User Participation
5. Obsolete or Nonexistent Documentation
6. Inability to Manage the Development of a Large Complex Computer Program
Need software engineering tools
7. Mysterious Results
5
Checklist for Simulations
1. Checks before developing a simulation:
(a) Is the goal of the simulation properly specified?
(b) Is the level of detail in the model appropriate for the goal?
(c) Does the simulation team include personnel with project
leadership, modeling, programming, and computer systems
backgrounds?
(d) Has sufficient time been planned for the project?
2. Checks during development:
(a) Has the random number generator used in the simulation
been tested for uniformity and independence?
(b) Is the model reviewed regularly with the end user?
(c) Is the model documented?
6
Terminology
• Introduce terms using an example
of simulating CPU scheduling
• Study various scheduling techniques given job characteristics, ignoring disks,
display…
• State Variables: Define the state of the system
• Can restart simulation from state variables
• E.g., length of the job queue.
• Event: Change in the system state
• E.g., arrival, beginning of a new execution, departure
7
Terminology: Types of Models
• Continuous Time Model
• State is defined at all times
• Discrete Time Models
• State is defined only at some instants
8
Terminology: Types of Models (cont’d)
• Continuous State Model
• State variables are continuous
• Discrete State Models
• State variables are discrete
9
Terminology: Types of Models (cont’d)
• Discrete state = Discrete event model
• Continuous state = Continuous event model
• Continuity of time ¹ Continuity of state
10
Terminology: Types of Models (cont’d)
• Deterministic and Probabilistic Models
• Deterministic - If output predicted with certainty
• Probabilistic - If output different for different repetitions
11
Terminology: Types of Models (cont’d)
• Static and Dynamic Models
• Static - Time is not a variable
• Dynamic - If changes with time
• Linear and nonlinear models
• Linear - Output is linear combination of input
• Nonlinear - Otherwise
Output
Output
Input Input
(Linear) (Non-Linear)
12
Terminology: Types of Models (cont’d)
• Open and closed models
• Open - Input is external and independent
• Closed - Model has no external inputs
• Ex: if same jobs leave and re-enter queue then closed, while if new jobs enter
system then open
cpu cpu
open
closed
13
Terminology: Types of Models (cont’d)
• Stable and unstable
• Stable - Model output settles down
• Unstable - Model output always changes
14
Computer System Models
• Continuous time
• Discrete state
• Probabilistic
• Dynamic
• Nonlinear
• Open or closed
• Stable or unstable
15
Next….
• Analysis of simulation results
Markov Chain
A Markov chain is a discrete-time process that
possesses a Markov property. Originally, this expression
denoted discrete-time and discrete-state Markovian
process.
However, the state space of a process may be
continuous.
• By extension, a continuous-time Markov chain will be called
a discrete-state (and continuous time) Markovian stochastic
process.
Note: For study purposes, we shall consider a discrete-
time Markov chain
Markov Property
• A stochastic process
• Having a random variable X at a particular time t
• A stochastic process possesses a Markov property if the conditional
probability distribution of the future states of the process, depends
only upon the present state, AND NOT on the sequence of events
that preceded it (Came before it)
• Future values are conditionally dependent in the present state of the system
• A process with this property is called a Markov process.
Transition matrix
Transition Matrix (1)
2-state Markov chain
Example
Question:
(a)Find the transition matrix P
(b)Find P(X2=3|X0=1)
Solution
Solution
Matrices (Matrix)
T-step transition
3- step transitions
N-step transition
N-step transition matrix
Toothpaste brands
2-step transition
Steady state