You are on page 1of 45

Chapter Five

Simulation
“Simulation is the process of designing a model of a
real system and conducting experiments with this
model for the purpose of either understanding the
behavior of the system and/or evaluating various
strategies for the operation of the system.”

Simulation is one of the most widely used techniques


in operations research and management science…
Allows us to:
• Model complex systems in a detailed way
• Describe the behavior of systems
• Use the model to predict future behavior, that is,
the effects that will be produced by changes in the
system
• Analyze proposed systems
Applications
MANUFACTURING:
 material handling systems,
 assembly lines,
 inventory control systems,
• System
A group of objects that are joined together in
some regular interaction or interdependence
toward the accomplishment of some purpose.

Inputs System Outputs


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

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. 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 95 (modulo 100)
3,325/100 = 25, reminder
r3 = pr2 (modulo m)= 35 x 25 (modulo 100)
875/100 = 75, reminder
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-
between a and b a+1)*RAND())
Example: Demand and supply
Probability distribution of demand of Products/day

Demand for Frequency of


Products/day 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 product
on the bases of simulated data

c) Compare the results with the expected daily demand.


Solution

Table Probability of Demand


Daily
Demand
for Probability of Cumulative
product 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 Assignment of Random Numbers

Daily Cumulative Interval of


Demand Probability Probability Random
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 1,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
 The analytical result of 2.95(=3) products is close to the
simulated result of 3.2 (=3) products.
 But there could certain differences between the analytical
results and simulated results.
 The difference between the simulated value and the
analytical value is a result of the number of periods over
which the simulation was conducted.
 The results of any simulation study are subject to the number
of times the simulation occurred (i.e., the number of trials).
 Thus, the more periods for which the simulation is conducted,
the more accurate the result.
 For example, if demand were simulated for 1,000 weeks, in all
likelihood an average value exactly equal to the analytical
value.
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
3.0 .30 1.0 .50
4.0 .10 2.0 .30

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- 1, 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 interval ,x clock facility ng of ce ture system
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 percustome r
10customers
8customers
 Average queue length=  .80customer
10customers

 Average time
in the system= 24.5 min
 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 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: 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
Quality Control
The output of a production line is checked by an inspector for one or
more of three different types of defects, called A, B and C. If defect A
occurs the item is scraped. If defect B or C occurs, the item must be
reworked. The time required to rework a B defect is 15 minutes and
the time required to rework a C defect is 30 minutes. The
probabilities of an A, B and C defects are 0.15, 0.20 and 0.10
respectively. For ten items coming off the production line, determine
the number of items without any defects, the number scrapped, and
the total minutes of the rework time .
Use the following random number:
RN for defect A: 48 55 91 40 93 01 83 63 47 52
RN for defect B: 47 36 57 04 79 55 10 13 57 09
RN for defect C: 82 95 18 96 20 84 56 11 52 03
Solution 1113
The Probabilities of occurrence of A, B, C defects are 0.15, 0.20, and 0.10
respectively.
The management of Hadassah Textile Factory is considering the
question of marketing a new product. The fixed cost required in the
project is Birr 4,000. Three factors are uncertain viz. the selling price,
variable cost and the annual sales volume. The product has a life of
only one year. The management has the data on these three factors
as follows:
Selling price probability Variable cost probability Sales Probability
(Br) (Br) volume
(units)

3 0.2 1 0.3 1000 0.3


4 0.5 2 0.6 3000 0.3
5 0.3 3 0.1 5000 0.4

Consider the ff sequence of thirty random numbers:


81 32 60 04 46 31 67 25 24 10 40 02 39 68 08
59 66 90 12 64 79 31 86 68 82 89 25 11 98 16

Using the sequence (first three random number for the first trial, etc) simulate the
average profit for the above project of the basis of ten trials.
Solution
Random numbers 0-99 are allocated in proportion to the probabilities associated with
each of the three variables as given under:
Selling price Probability Cum RN assigned
(Br) probability
3 0.2 0.2 00-19
4 0.5 0.7 20-69
5 0.3 1.0 70-99

Variable cost Probability Cum RN assigned


(Br) probability
1 0.3 0.3 00-29
2 0.6 0.9 30-89
3 0.1 1.0 90-99
Sales Volume Probability Cum RN assigned
(Units) probability
2000 0.3 0.3 00-29
3000 0.3 0.6 30-59
5000 0.4 1.0 60-99
S RN Selling price RN Variable RN Sales
N (Br) cost (Br) Volume
1 81 5 32 2 60 5000
2 04 3 46 2 31 3000
3 67 4 25 1 24 2000
4

10 3 40 2 02 2000
5 39 4 68 2 08 2000
6 59 4 66 2 90 5000
7 12 3 64 2 79 5000
8 31 4 86 2 68 5000
9 82 5 89 2 25 2000
10 11 3 98 3 16 2000
Profit = sales (Br) – total cost(Br)
= selling price * sales volume – (variable cost*sales volume + fixed cost)
SN Selling Variable Sales Profit
price (Br) cost (Br) Volume
1 5 2 5000 11000
2 3 2 3000 -1000
3 4 1 2000 2000
4 3 2 2000 -2000
5 4 2 2000 0
6 4 2 5000 6000
7 3 2 5000 1000
8 4 2 5000 6000
9 5 2 2000 2000
10 3 3 2000 -4000
Total profit = 21,000 Birr
Thus, Average profit per trial = 21000/10 = 2100 Br
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
 Scheduling aircraft  Production facility
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


Thank You

You might also like