You are on page 1of 39

IE306

SYSTEMS SIMULATION

Ali Rıza Kaylan


kaylan@boun.edu.tr

1
LECTURE 1
OUTLINE

Systems, Models and Their Classification

Systems Simulation and Simulation Types

Discrete Event Systems (DES) Simulation

Simulation Methodology

What is Monte Carlo Simulation (MCS)


MCS Examples
2
SYSTEM
A set of interrelated entities which are
brought together to perform a function
or to accomplish an objective.

System state : Set of variables


necessary to describe a system at a
particular time.

3
OPEN OR CLOSED SYSTEM

Entity
Exterior
Entity Environment
Entity

Entity Entity
SYSTEM

Entity
Entity
BOUNDARY
Entity

Open System: Exchange of energy and resources with the environment


Closed System: Isolated system 4
OPEN OR CLOSED SYSTEM

5
SYSTEM COMPLEXITY
N = Number of elements
K = Number of links (Degree of Connectedness)
D = Degree of Diversity (How heterogeneus?)

Non-linearity of relationships

Adaptation: capability of adapting their behavior over


time, self-organization, emergence

6
NON-LINEARITY
Linear Relationships : Cause and Effect
Output proportional to input
Examples:
Fuel and Distance travelled
Two TV factories – Each producing n TV per year
Non-linear Relationship:
Synergistic: Output greater than the sum of its parts
Interference: Output less than the sum of its parts
Example : 4 textile workers producing t-shirts

7
ANALYTICAL vs. SYSTEMS THINKING

Analytical Thinking : Reductionist approach


Systems Thinking : Holistic View

Key Differences:
SETS (Objects) vs. SYSTEMS (Function)
COMPONENTS vs. RELATIONS
LINEAR (Causality) vs. NON-LINEAR (Feedback)
STATIC (Structure) vs. DYNAMIC (Process)

8
ANALYTICAL vs. SYSTEMS THINKING

Example: New Car Design


Analyzing the car and optimizing it
Minimizing the car’s drag by reducing the height
a few cm to increase its fuel efficiency

Systems Thinking :
Identify the car’s function: personal transportation

9
SYSTEM CLASSIFICATION

Prescriptive vs. Descriptive

Static vs. Dynamic

Deterministic vs. Stochastic

Discrete vs. Continuous


10
MODEL
Representation of a real-life system

Classification of models:
iconic (physical)
mathematical
analog

11
HOW TO STUDY A SYSTEM

Analytical solutions

Numerical solutions

Simulation

12
WHY SIMULATE?

•  Is Simulation a technique of last resort?

•  How common is simulation practiced as


a problem solving technique and
methodology?

•  What is SINSFIT?

13
WHY SIMULATE?

System Complexity – Analytical solutions not


available

Surveys of MS/OR practitioners: simulation and


statistics have the highest rate of application
over all other tools.

SINSFIT
14
WHY SIMULATE?

•  Generating values for uncontrollable


variables and computing the value of
the outcome variable
•  What if Analysis :
– Worst case Scenarios
– Base case Scenarios
– Best case Scenarios

15
SIMULATION

Experimentation using a model to study and


gain insight for the actual system.
Decision Variables

...
INPUT SIMULATION OUTPUT
MODEL
Performance
Measures

Uncontrollable Variables
16
MANUFACTURING SYSTEM
Major Questions:
What is the best design?
How to improve the current system?

Performance Measures:
Delay in order fulfillment
Throughput
Reliability

Further Questions:
Where are the bottlenecks?
How frequent are the machine breakdowns?

17
BENEFITS

•  Does not require simplifying assumptions


•  Can deal with problems not possible to solve
analytically
•  Provides an experimental laboratory: possible to
evaluate decisions/systems without
implementing them
•  Generally easier to understand than analytical
models

18
LIMITATIONS

•  Time-consuming for complex systems

•  Simulation results / simulated systems are


always approximations.

•  Does not guarantee an optimal solution.

19
TYPES OF SIMULATION
Discrete Event Simulation

Continuous Simulation

Monte Carlo Simulation

Distributed Simulation

20
DISCRETE EVENT SIMULATION

State variables change only at discrete points


in time.

Event : Instantaneous occurrence that may


change the state of the system

Time Advance Mechanisms:


Next-event time advance
Fixed-increment time advance
21
TYPES OF SIMULATION
Continuous Simulation:
State variables change continuously over
time
Monte Carlo Simulation:
Any technique of statistical sampling
employed to approximate solutions to
quantitative problems.
Distributed Simulation:
Distributing different parts of the
computing work load among different
processors operating in parallel. 22
DES METHODOLOGY
1. Problem definition
2. Data collection and model definition
3. Check validity of the model
4. Construct a computer program and Verify
5. Make pilot runs
6. Check validity of the model
7. Design experiments
8. Make production runs
9. Analyze output data
10. Implementation of results
23
COMPONENTS OF DES MODEL

Initialization routine
System state Timing routine
Simulation Clock
Event routine
Event list
Statistical counters Library routines
Report Generator

24
COMPONENTS OF DES MODEL

Initialization routine
1. Set simulation clock = 0
2. Initialize system state and statistical counters
3. Initialize event list
Timing routine
1. Determine the next event type
2. Advance the simulation clock
Event routine
1. Update system state
2. Update statistical counters
3. Generate future events and update event list 25
COMPONENTS OF DES MODEL

Library routines
Generate random variates
Report Generator
1. Compute estimates of interest
2. Write report
Main Program
0. Invoke the initialization routine
1. Invoke the timing routine
2. Invoke event routine i
26
MONTE CARLO SIMULATION

Any technique of statistical sampling


employed to approximate solutions to
quantitative problems.

Any method which solves a deterministic or a


stochastic problem using random numbers.

The method is useful for obtaining numerical


solutions to problems which are too
complicated to solve analytically.

27
MONTE CARLO SIMULATION
The term "Monte Carlo" comes from the name of a city in
Monaco. The city's main attractions are casinos, which run
games such as roulette wheels, dice and slot machines.
These games provide entertainment by exploiting the
random behaviour of each game.

It was Metropolis who named the new methodology after the


casinos of Monte Carlo.

The first paper on the Monte Carlo method :

Metropolis, Nicholas and Stanislaw Ulam (1949). The Monte


Carlo method, Journal of the American Statistical
Association, 44 (247), 335-341.

28
Stanislaw Marcin Ulam
•  Devised the 'Monte-Carlo method' widely
used in solving mathematical problems
using statistical sampling in 1946.

•  Worked for John von Neumann on the


United States’ Manhattan Project during
World War II. Ulam is primarily known for
designing the hydrogen bomb with Edward
Teller in 1951.

Born: 3 April 1909 in Lemberg, Poland,


Austrian Empire (now Lvov, Ukraine)
Died: 13 May 1984 in Santa Fe, New
Mexico, USA

http://www-history.mcs.st-andrews.ac.uk/history/Mathematicians/Ulam.html 29
Stanislaw Marcin Ulam
Invented the Monte Carlo method in 1946 while pondering the probabilities of
winning a card game of solitaire.
“The first thoughts and attempts I made to practice [the Monte Carlo Method] were
suggested by a question which occurred to me in 1946 as I was convalescing from an
illness and playing solitaires. The question was what are the chances that a Canfield
solitaire laid out with 52 cards will come out successfully? After spending a lot of
time trying to estimate them by pure combinatorial calculations, I wondered whether
a more practical method than “abstract thinking” might not be to lay it out say one
hundred times and simply observe and count the number of successful plays. This
was already possible to envisage with the beginning of the new era of fast computers,
and I immediately thought of problems of neutron diffusion and other questions of
mathematical physics, and more generally how to change processes described by
certain differential equations into an equivalent form interpretable as a succession of
random operations. Later … [in 1946, I] described the idea to John von Neumann,
and we began to plan actual calculations.”

Eckhardt, Roger (1987). Stan Ulam, John von Neumann, and the Monte Carlo 30
method, Los Alamos Science, Special Issue (15), 131-137.
Metropolis, Nicholas Constantine
(1915-1999)
Greek-American mathematician who
worked on Manhattan Project, and
collaborated with Enrico Fermi and Edward
Teller on the first nuclear reactors.

A team headed by Metropolis carried out


the first actual Monte Carlo calculations on
the ENIAC computer (the world's first
electronic digital computer, built at the
University of Pennsylvania) in 1948.

31
MONTE CARLO SIMULATION
Monte Carlo simulation randomly select values to create scenarios of a problem.
These values are generated randomly according to a probability distribution [e.g.
Uniform, exponential, normal, lognormal, etc.].

This is like rolling a die. If it is a fair die, the outcome is known to be one of the six
values {1,2,...,6} each with a chance of 1/6 . There is an equal opportunity for any
number to be the outcome.

Approximate answer to the problem

“Brute force" approach - computer intensive


(Avoid it if analytical solutions are possible.)

Able to solve problems for which no other solutions exist.

32
MONTE CARLO SIMULATION
EXAMPLES

Deterministic Problem - No Analytical Solution


Analytical Solution – Available But Not easy.
Demonstration of Probabilistic Laws
- Experiential Learning

33
Example 1 – Area Estimation

It is desired to obtain the shaded


area under the given function f(x).
The length of the rectangle is 10
units and the height is 5 units.

Due to the irregular shape of the rectangle, this problem is not


easily solved using analytical methods. One can resort to
numerical analysis to solve the problem. However, we can also
use Monte Carlo simulation to easily find an approximate
answer.

34
Example 1 – Area Estimation
Procedure :

1. Randomly select a location within the


rectangle
2. if it is within the shaded area, record this
instance as a success
3. generate a new location and repeat n times
(Say n = 1000 times)

Number of Successes
Area = x 50
n
Naturally, more accurate approximations for the shaded area can be obtained if more
trials are repeated.

35
Example 2 – Computation of Pi
Y
(1,1) Procedure :

1. Randomly select a location (X,Y) within the


square
X 2. if it falls within the circle, record this
instance as a success
3. generate a new location and repeat n times
(Say n = 1000 times)
(-1,-1)

Number of Successes
Area of Circle = x Area of Square
n
Number of Successes
π = x4
n
36
Example 2 – Computation of Pi
Procedure :
(1,1)
Randomly select a location (X,Y) within the
square.

If X 2 +Y 2 ≤ 1, then SUCCESS

Generate a new location and repeat n times


(Say n = 1000 times).

Estimate Pi as

Number of Successes
π= x4
n
37
EXAMPLE 3. DEMONSTRATION OF
CENTRAL LIMIT THEOREM
Experiment: cast a die n times

n=1
0.250

0.200

0.150

0.100

0.050

0.000

11

13

15

17
38
EXAMPLE 3. DEMONSTRATION OF
CENTRAL LIMIT THEOREM
Experiment: cast a die n times 0.250

0.200
n=2
0.150

0.100

0.050

0.000

11

13

15

17
n=3
0.250

0.200

0.150

0.100

0.050

0.000
39
1

11

13

15

17

You might also like