Simulation
Nature of simulation –
• Numerical approach for investigating models
of systems.
• Data are gathered to estimate the true
characteristics of the model.
• Garbage in – garbage out!
• One of the techniques of operations research
– possibly the most widely used.
Nature of simulation -2/2
• Typical applications:
– Designing and analyzing manufacturing systems.
– Evaluating military weapons systems.
– Evaluating logistics of weapons supply systems.
– Determining hardware and software requirements for a computer system.
– Designing and operating transportation systems.
– Evaluating designs for service organizations.
– Re-engineering business processes.
– Analyzing financial systems (?)
Designing and analyzing manufacturing systems.
Systems, Models and Simulation
• System: collection of entities, acting and interacting towards some logical end.
• The definition of a system depends on the goal of the analysis.
• The state of the system is the collection of
variables necessary to describe the system at a particular time.
• The definitional of the state of a system is conditional on the goals of the study.
Systems, Models and Simulation
• Types of systems:
– Discrete: state variables change instantaneously
at discrete points in time.
• Number of cars in a parking lot.
– Continuous: State variables change continuously
in time.
• Speed of a car.
• Ways to study a system:
Systems, Models and Simulation
System
Experiment with the system
Experiment with a model of the system
Physical Model
Mathematical Model
Analytical Solution
Simulation
• Experiment with the system:
• Physical Model
• Analytical solutions vs. Simulation
Systems, Models and Simulation
• Types of simulations:
– Static vs. Dynamic simulations
• Monte Carlo
– Deterministic vs. Stochastic
• Output is determined given the inputs.
• Output changes given the same inputs.
– Continuous time vs. Discrete Simulation
• Similar to continuous and discrete models.
Systems, Models and Simulation
Discrete event simulation
• The system can change at only a countable
number of points in time.
• Events: cause changes to the simulation.
• Types of events:
– To change the state of the system.
– To change the simulation itself.
• Usually done using computers.
Time advance Mechanism
• All dynamic simulations need a system clock –
a counter to mimic real world time advances.
This is known as the simulation clock.
• Fixed increment time advance:
– Computer Games
• Next event time advance:
– Most commonly used system.
Next event time advance
• Single server queuing system:
Components and organization of
simulations• System state: collection of state variables necessary to describe the
system at a particular time.
• Simulation clock: a variable giving the current value of simulated time.
• Event list: A list containing the next time when each type of event will occur.
• Statistical counters: performance measuring variables.
• Initialization routine: Used at start of simulation.
• Timing routine: Next event selection routine.
• Event routine: Next event handling routine.
• Library routines: used to generate random variables.
• Report Generators: Performance reporting routines.
• Main program:
• Visual interface control routines:
Fowchart for next-event time-advance
Main program:
Invoke initialization routine
Invoke timing routine
invoke event routine
Event routine:
Update system state
Update statistical counters
Generate future events.
Initialization routine:
Set clock = 0
Initialize state variables and
statistical counters
Initialize event list.
Library routines:
Generate random variables
Timing routines:
Determine next event type.
Advance simulation clock.
Report generator:
Compute estimates of interest.
Write report
Start
Stop
Simulation over ?
Simulation approaches
• Event scheduling approach.
• Process approach.
Simulation of single server queuing
system
• Inter-arrival times are independent and identically distributed random variables.
• A customer who arrives and finds the server idle starts service immediately. Service times of successive customers are IID random variables.
• If server is busy, customer joins the waiting queue.
• Server selects customers from queue in a FIFO manner.
• Other issues ?
Simulation of single server queuing
system
• What do we want to study ?
– Customer delays ?
– Average number of customers in the queue:
Single server system
• Where, pi is the fraction of time there are i
customers in the queue.
• This can also be written as:
Single server queuing model
• Fraction of time the server is idle ?
Initialization Routine
Simulation
Homework I
• How would you simulate a 4 way traffic
crossing ?
• Use excel to simulate the single server
queuing system for 100 arrivals.
• What is the mean server utilization ?
• Identify a data structure you would use for
handling the event list.