You are on page 1of 48

Chapter-Ten

Simulation
What is Simulation?
 An attempt to duplicate the features,
appearance, and characteristics of a real
system, and its objectives are
1. To imitate a real-world situation mathematically
2. To study its properties and operating
characteristics
3. To draw conclusions and make action decisions
based on the results of the simulation
Simulation …Cont’d

 Simulation is an alternative form of analysis


when the problem situations are too complex to be
represented by the concise mathematical techniques.
Simulation …Cont’d

Fig. 10.1 Model Types


Types of Simulation
 Systems may have discrete or continuous state
 Based on the use of either a continuous or discrete time
representation.

1. Continuous simulation: The state changes all the time, not


just at the time of some discrete events.
 For example: the water level in a reservoir with given in and
out flow may change all the time.
Types of Simulation…Cont’d
2. Discrete event simulation: The system only change at
discrete points in time.
 Fore example: In an industrial plant, the system status
changes when a new part arrives at a machine or when a
machine breaks down.
down
 Between any two events, the status of the modeled system
remains constant.
 To represent the changes in the system, it is necessary to
describe the actions or events which causes the status of the
system to change.
Types of Simulation…Cont’d
• Discrete event simulation has applications in a wide
range of sectors including manufacturing and service
sectors.
 automotive
 healthcare
 electronics
 pharmaceuticals
 food and beverage
 packaging
 logistics, etc.
Types of Simulation…Cont’d
Based on the representation of the models

1. Analogue simulation (AS):- In this type of simulation, an


original physical system is replaced by an analogous physical
models that is easier to manipulate.

• Examples:
 Manned space flight
Treadmills that simulate automobile tire wear in
laboratory.
Types of Simulation…Cont’d
2. Computer Simulation:- In this form of simulation, systems
are replicated with mathematical models, which are
analyzed with computer.
 This form of simulation has become a very popular
technique that has been applied to a wide variety of
business problems.
 One reason of its popularity is that it offers a means of
analyzing very complex systems that cannot be analyzed
using the other techniques .
Steps of Simulation Process
• The process of simulating a system consists of
following steps:
1. Identify the problem
2. Identify the decision variables, and decide the
performance criterion (objective) and decision rules
3. Construct a numerical model
4. Validate the model
5. Design the experiments
6. Run the simulation model
7. Examine the results
Identify the problem

Identify decision variables, performance


criterion and decision rules
Modify the model by changing
the input data, i.e. values of
decision variables
Construct simulation model

No
Validate the model

Is
Design experiments (specify values of simulation
decision variables to be tested) completed?

Yes
Run or conduct the simulation
Examine the results and select
the best course of action
Fig.10.2 Steps of the simulation process
Monte Carlo Simulation
• One characteristic of some systems that makes them difficult to
solve analytically is that they consist of random variables
represented by probability distributions.
 Thus, a large proportion of the applications of simulations are
for probabilistic models.
• The term Monte Carlo has become synonymous with
probabilistic simulation in recent years.
• Monte Carlo is a technique for selecting numbers randomly from
a probability distribution.
Monte Carlo …Cont’d
• In case it is not possible to describe a system in terms of
standard probability distribution such as normal, Poisson,
exponential, gamma, etc., an empirical probability distribution
can be constructed.
• The Monte Carlo process is analogous to gambling devices.
devices
• It may be used when the model contains elements that exhibit
chance in their behavior,
Monte Carlo …Cont’d
The Monte Carlo technique consists of following
steps:

1. Set up probability distributions for important variables


2. Build a cumulative probability distribution for each
variable
3. Establish an interval of random numbers for each variable
4. Generate random numbers
5. Simulate a series of trials by means of random sampling
6. Repeat step 5until the required number of simulation runs
has been generated.
7. Design and implement a courses of action and maintain
control
Random Number (RN) Generation
1. Arithmetic Computation
 The nth random number rn consisting of k-digits
generated by using multiplicative congruential
method given by

rn = p.rn-1 (modulo m)
 Where p and m are positive integers, P<m, rn-1 is the
k-digit number and modulo m means that rn is the
reminder when p.rn-1 is devised by m. m this means, rn
and p.rn-1 differ by an integer multiple of m.
RN Generation…Cont’d
• To start the process of generating random numbers, the first
number r0 is specified by the user.
• For illustration, let p= 35, m= 100 and arbitrary start with r0=
57.
• Since m-1 = 99 is the 2=digit number, therefore, it will
generate 2-digit random numbers:
r1 = pr0 (modulo m)= 35 x 57 (modulo 100)
1,995/100 = 95, reminder
r2 = pr1 (modulo m)= 35 x 57 (modulo 100)
3,325/100 = 25, reminder
r3 = pr2 (modulo m)= 35 x 57 (modulo 100)
875/100 = 75, reminder
RN Generation…Cont’d
2. Computer Generator
 The random numbers that are generated by using computer
software are uniformly distributed decimal fractions
between 0 and 1.
 The software works on the concept of cumulative
distribution function for the random variables for which we
are seeking to generate random numbers.
RN Generation…Cont’d
• For example, for the negative exponential function with
 x
density function,
f ( x)  e ,0  x  ,
• The cumulative distribution function is given by,
x


 x  x
F ( x)   e dx  1  e
0

or , e  x  1  F ( x )
• Taking logarithm on both sides, we have

 x  log[1  F ( x)]
or , x  (1 /  ) log[1  F ( x)]
RN Generation…Cont’d
• If r = F(x) is a uniformly distributed random
decimal fraction between 0 and 1, then the
exponential variables associated with r is given
by
xn  (1 /  ) log(1  r )  (1 /  ) log r.

• This is an exponential process generator since 1-


r is a random number and can be replaced by r.
RN Generation…Cont’d

Remark
I. We can pick up random numbers from
random table, or
II.Use built-in Excel formula to generate random
numbers
RN Generation…Cont’d
While picking up random numbers from the random
number table
• The starting point could be randomly chosen
 Start with any number in any column or row, and
proceed in the same column or row to the next
number, but a consistent, unvaried pattern should be
followed in drawing random numbers..
 We should not jump from one number to another
indiscriminately
RN Generation…Cont’d
Table 10.1. Random number generation using
built-in excel formula
To Simulate Use built-in Excel
formula
(1) Random number, r (0≤ r≤ 1) =RAND()
(2) Random number, r =RAND()*100
(0 ≤ r ≤ 100)
(3) Continuous uniform =a+(b-a)*RAND()
distribution between a and b
(4) Discrete uniform distribution =INT(a+(b-a+1)*RAND())
between a and b
Example: Demand and supply
Table 10.2. Probability distribution of demand of Tires

Demand for Frequency of


Tires Demand
0 10
1 20
2 40
3 60
4 40
5 30
200 days
Example1: Demand and supply
• Using random numbers from the given table;

a) Simulate the demand for the next 10days

b) Also estimate the daily average demand for tires on


the bases of simulated data

c) Compare the results with the expected daily demand.


Solution
Table 10.3. Probability of Demand
Daily
Demand Probability of Cumulative
for Tires Frequency Occurrence Probability
0 10 10/200 = .05 .05
1 20 20/200 = .10 .15
2 40 40/200 = .20 .35
3 60 60/200 = .30 .65
4 40 40/200 = .20 .85
5 30 30/ 200 = .15 1.00
200 days 200/200 = 1.00
Solution…Cont’d
Table 10.4 Assignment of Random Numbers

Interval of
Daily Cumulative Random
Demand Probability Probability Numbers
0 .05 .05 01 through 05
1 .10 .15 06 through 15
2 .20 .35 16 through 35
3 .30 .65 36 through 65
4 .20 .85 66 through 85
5 .15 1.00 86 through 99,00
Simulation Example 1
Day Random Simulated
Number Number (r) Daily Demand
1 39 3
2 73 4
3 72 4
4 75 4
5 37 3
6 02 0
7 87 5
8 98 5
9 10 1
10 47 3
Total= 32
Average= 3.2
Solution…Cont’d
Expected Demand E(x) = Σpixi
5
Expected = ∑ (probability of i units) x (demand of i
demand units)
i =1

= (.05)(0) + (.10)(1) + (.20)(2) + (.30)(3) +


(.20)(4) + (.15)(5)
= 0 + .1 + .4 + .9 + .8 + .75
= 2.95 tires
Example2: Simulation of a Queuing System
 Consider the Case of drive-in market which consists of one

cash registrar (the service facility) and a single queue of


customers. The inter arrival time and service time is as in table
a and b.

 Assume that the time intervals between customer arrivals are

discrete random variables.


Queuing System…Cont’d
Table a. Distribution of arrival Table b. Distribution of
interval time service time
Arrival interval Probability Service time Probability
(min), x P(x) (min), y P(y)
1.0 .20 0.5 .20
2.0 .40 1.0 .50
3.0 .30
2.0 .30
4.0 .10

For 10 customers arrivals to the cash registrar, Calculate


a) Average waiting time
b) Average queue line
c) Average time in the system
Solution
• First we have to develop the cumulative probability
distribution, to determine random number ranges.

Table a1. Range of random numbers for arrival interval time


Arrival Probability Cumulative Random number
interval P(x) probability range, r1
(min), x
1.0 .20 .20 01- 20
2.0 .40 .60 21 – 60
3.0 .30 .90 61 – 90
4.0 .10 1.00 91- 99, 00
Solution …Cont’d
Table b1. Range of random numbers for service time

Service time Probability Cumulative Random number


(min), y P(y) probability range,
r2
0.5 .20 .20 01-20
1.0 .50 .70 21-70
2.0 .30 1.00 71-99,00
Solution …Cont’d
Table c. Simulation of the queuing system for 10 customers
Custom r1 Arrival Arrival Enter Waiti- Length r2 Servi- Depar- Time in
-er interv- clock facility ng of ce ture system
al ,x clock Time Queue Time, y Clock
After
Enter

1 - - 0.0 0.0 0.0 0.0 65 1.0 1.0 1.0


2 71 3.0 3.0 3.0 0.0 0.0 18 .5 3.5 .5
3 12 1.0 4.0 4.0 0.0 0.0 17 .5 4.5 .5
4 48 2.0 6.0 6.0 0.0 0.0 89 2.0 8.0 2.0
5 18 1.0 7.0 8.0 1.0 1 83 2.0 10.0 3.0
6 08 1.0 8.0 10.0 2.0 1 90 2.0 12.0 4.0
7 05 1.0 9.0 12.0 3.0 2 89 2.0 14.0 5.0
8 18 1.0 10.0 14.0 4.0 2 08 .5 14.5 4.5
9 26 2.0 12.0 14.5 2.5 2 47 1.0 15.5 3.5
10 94 4.0 16.0 16.0 0.0 0 06 .5 16.5 .5
Total 12.5 8 24.5
Solution …Cont’d
• Once the simulation is complete, we can compute operating
characteristics from the simulation results as follows.

12.5 min
 Average waiting time=  1.25 min percustomer
10customers
8customers
 Average queue length=  .80customer
10customers

 Average time
24.5 min
in the system=  2.45 min percustomer
10customers
Example 3: Simulation of a machine breakdown and
Maintenance System
• A continuous probability distribution of the time between
machine breakdowns is given by;
x
f ( x)  ,0  x  4weeks
8
Where X = Weeks between machine breakdowns

• When a machine breaks down, it must be repaired; and it


takes either one, two, or three days for the repair to be
completed, according to the discrete probability distribution
shown in table (I)
Machine breakdown…Cont’d

Table I. Probability distribution of machine repair time

Machine repair time, Y Probability of repair


(days) time , P(Y)
1 .15

2 .55
3 .30

•Every time a machine breaks down, the cost to the


company is estimated $2,000 per day in lost production
until the machine is repaired
Machine breakdown…Cont’d
 The company would like to know if it should implement a
machine maintenance program at a cost of $20,000 per year
that would reduce the frequency of breakdowns and thus the
time for repair.
 The maintenance program would result in the following
continuous probability function for time between breakdowns

x
f ( x)  ,0  x  6weeks
18
Where x= Weeks between machine breakdowns
Machine breakdown…Cont’d

• The reduced repair time resulting from the maintenance


program is defined by the discrete probability distribution
shown in table (II)
Table II. Revised probability distribution of m/c repair time
with the maintenance program

Machine repair Probability of repair


time, Y (days) time, p(y)
1 .40
2 .50
3 .10
Solution
Table Simulation of the m/c breakdown and repair without the maint. Prog.
r1 Time between r2 Repair time, Cost, $2,000y Cumulative time,
B/D, Xwks ydys Σxwks
.45 2.68 .19 2 4,000 2.68
.90 3.80 .65 2 4,000 6.48
.84 3.67 .51 2 4,000 10.15
.17 1.65 .17 2 4,000 11.80
.74 3.44 .63 2 4,000 15.24
.94 3.88 .85 3 6,000 19.12
.07 1.06 .37 2 4,000 20.18
.15 1.55 .89 3 6,000 21.73
.04 0.80 .76 3 6,000 22.53
.31 2.23 .71 3 6,000 24.76
.07 1.06 .34 2 4,000 25.82
.99 3.98 .11 1 2,000 29.80
.97 3.94 .27 2 4,000 33.74
.73 3.42 .10 1 2,000 37.16
.13 1.44 .59 2 4,000 38.60
.03 0.70 .87 3 6,000 39.30
.62 3.15 .08 1 2,000 42.45
.47 2.74 .08 1 2,000 45.19
.99 3.98 .89 3 6,000 49.17
.75 3.46 .42 2 4,000 52.63
$ 84,000
Solution
Table Simulation of the m/c breakdown and repair with the maint. Prog.

r1 Time between r2 Repair time, Cost, Cumulative time,


B/D, Xwks ydys $2,000y Σxwks
.45 4.03 .19 1 2,000 4.03
.90 5.69 .65 2 4,000 9.72
.84 5.50 .51 2 4,000 15.22
.17 2.47 .17 1 2,000 17.69
.74 5.16 .63 2 4,000 22.85
.94 5.82 .85 2 4,000 28.67
.07 1.59 .37 1 2,000 30.29
.15 2.32 .89 2 4,000 32.58
.04 1.20 .76 2 4,000 33.78
.31 3.34 .71 2 4,000 37.12
.07 1.59 .34 1 2,000 38.71
.99 5.97 .11 1 2,000 44.68
.97 5.91 .27 1 2,000 50.59
.73 5.12 .10 1 2,000 55.71
$ 42,000
Summary of the result
Option1: With out the maintenance program
Cost = $84,000

Option 2:
2 With maintenance program
Cost = $20,000+ $42,000
= $62,000

Therefore Option 2 is better for the organization with


Profit = $84,000 - $62,000
= $22,000
Role of Computers in Simulation

 Computers are critical in simulating complex tasks

 Computers are used to:

 Generate random numbers;

 Simulate the given problem with varying values of variables


in few minutes; and

 help the decision-maker to prepare reports which enable


him to make decisions quickly as well as draw valid
conclusions.
Computers in Simulation…Cont’d
Computer languages available
1. General-purpose languages – FORTRAN,
BASIC, PASCAL, COBOL, C++ etc.
2. Special-purpose simulation languages - GPSS,
SIMSCRIPT, DYNAMO, SIMULA, ARENA etc.
1. Require less programming time for large simulations
2. Usually more efficient and easier to check for errors
3. Random-number generators are built in

 Spreadsheets such as Excel can be used to develop


some simulations
Using Software in Simulation
Simulation Applications
 Survey conducted during the 1980s indicate that a large majority of
major corporations use simulation in such functional areas as
production, corporate planning, engineering, financial analysis,
research and development, marketing, information systems, and
personnel.
 Following are descriptions of some of the more common
applications of Simulation:
Queuing
Inventory control
Production and manufacturing
Finance
Marketing
Applications…Cont’d
 Assembly-line balancing  Bus scheduling
 Parking lot and harbor design  Taxi, truck, and railroad
 Distribution system design dispatching
 Production facility
 Scheduling aircraft
scheduling
 Labor-hiring decisions
 Plant layout
 Personnel scheduling
 Production scheduling
 Traffic-light timing
 Sales forecasting
 Inventory planning and
control
Advantages of Simulation
1. Relatively straightforward and flexible
2. Can be used to analyze large and complex real-world situations
that cannot be solved by conventional models

3. Real-world complications can be included that most


mathematical models cannot permit
4. “Time compression” is possible
5. Allows “what-if” types of questions

6. Does not interfere with real-world systems


7. Can study the interactive effects of individual components or
variables in order to determine which ones are important
Disadvantages of Simulation
1. Can be very expensive and may take months to develop

2. It is a trial-and-error approach that may produce different


solutions in repeated runs

3. Users must generate all of the conditions and constraints for


solutions they want to examine

4. Each simulation model is unique

You might also like