8/6/2019 Or Simulation Lecture
1/48
Chapter-Ten
Simulation
8/6/2019 Or Simulation Lecture
2/48
8/6/2019 Or Simulation Lecture
3/48
Simulation Cont d
Simulation is an alternative form of analysisSimulation is an alternative form of analysis
when thewhen the problem situations are too complex to beproblem situations are too complex to be
represented by the concise mathematical techniques.represented by the concise mathematical techniques.
8/6/2019 Or Simulation Lecture
4/48
Simulation Cont d
Fig. 10.1 Model Types
8/6/2019 Or Simulation Lecture
5/48
Types of Simulation
Systems may have discrete or continuous state
Based on the use of either a continuous or discrete time
representation.
1.1. Continuous simulation: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 andout flow may change all the time.
8/6/2019 Or Simulation Lecture
6/48
8/6/2019 Or Simulation Lecture
7/48
Types of Simulation Cont dDiscrete event simulation has applications in a widerange of sectors including manufacturing and servicesectors.
automotiveautomotivehealthcarehealthcareelectronicselectronicspharmaceuticalspharmaceuticalsfood and beveragefood and beverage
packagingpackaginglogistics, etc.logistics, etc.
8/6/2019 Or Simulation Lecture
8/48
Types of Simulation Cont d
BasedBased onon thethe representationrepresentation of of thethe modelsmodels
1. Analogue simulation (AS):- In this type of simulation, anoriginal physical system is replaced by an analogous physicalmodels that is easier to manipulate.
Examples:M anned space flight
Treadmills that simulate automobile tire wear inlaboratory.
8/6/2019 Or Simulation Lecture
9/48
8/6/2019 Or Simulation Lecture
10/48
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 theperformance 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
8/6/2019 Or Simulation Lecture
11/48
Identify the problem
M odify the model by changingthe input data, i.e. values of
decision variables
Identify decision variables, performancecriterion and decision rules
Construct simulation model
Validate the model
Design experiments (specify values of decision variables to be tested )
Examine the results and selectthe best course of action
Run or conduct the simulation
Issimulationcompleted?
F ig.10. 2 Steps of the simulation process
No
Yes
8/6/2019 Or Simulation Lecture
12/48
M onte Carlo Simulation
One characteristic of some systems that makes them difficult tosolve 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 M onte Carlo has become synonymous with probabilistic
simulation in recent years.
M onte Carlo is a technique for selecting numbers randomly from
a probability distribution .
8/6/2019 Or Simulation Lecture
13/48
M onte Carlo Cont d
InIn casecase itit isis notnot possiblepossible toto describedescribe aa systemsystem inin termsterms of of standardstandard probabilityprobability distributiondistribution suchsuch asas normal,normal, Poisson,Poisson,
exponential,exponential, gamma,gamma, etcetc..,, anan empiricalempirical probabilityprobability distributiondistribution
cancan bebe constructedconstructed. .TheThe M onteM onte CarloCarlo processprocess isis analogousanalogous toto gamblinggambling devicesdevices.
ItIt maymay bebe usedused whenwhen thethe modelmodel containscontains elementselements thatthat exhibitexhibit
chancechance inin theirtheir behavior,behavior,
8/6/2019 Or Simulation Lecture
14/48
M onte Carlo Cont d
TheThe M onteM onte CarloCarlo techniquetechnique consistsconsists of of followingfollowingstepssteps::
1. Set up probability distributions for important variables
2. Build a cumulative probability distribution for each variable3. Establish an interval of random numbers for each variable
4.4. GenerateGenerate randomrandom numbersnumbers
5. Simulate a series of trials by means of random sampling
6. Repeat step 5until the required number of simulation runshas been generated.
7. Design and implement a courses of action and maintaincontrol
8/6/2019 Or Simulation Lecture
15/48
Random Number (RN) Generation
1. Arithmetic ComputationThe nth random number r n consisting of k-digitsgenerated by using multiplicative congruentialmethod given by
W here p and m are positive integers, P
8/6/2019 Or Simulation Lecture
16/48
RN Generation Cont dTo start the process of generating random numbers, the firstnumber r0 is specified by the user.For illustration, let p= 35, m= 100 and arbitrary start with r 0=57.Since m-1 = 99 is the 2=digit number, therefore, it will generate2-digit random numbers:
r1 = pr0 (modulo m)= 35 x 57 (modulo 100)
1,995/100 = 9 5, reminder
r2 = pr1 (modulo m)= 35 x 57 (modulo 100)3,325/100 = 2 5, reminderr3 = pr2 (modulo m)= 35 x 57 (modulo 100)
875/100 = 75, reminder
8/6/2019 Or Simulation Lecture
17/48
RN Generation Cont d2
. Computer GeneratorThe 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.
8/6/2019 Or Simulation Lecture
18/48
RN Generation Cont dFor example, for the negative exponential function with
density function,
The cumulative distribution function is given by,
Taking logarithm on both sides, we have
,0,)( g! xe x f xPP
)(1,
1)(0
x F eor
edxe x F
x
x x x
!
!!
)](1log[)/1(,
)](1log[
x F xor
x F x!!
8/6/2019 Or Simulation Lecture
19/48
RN Generation Cont d
If r = F (x) is a uniformly distributed randomdecimal fraction between 0 and 1, then theexponential variables associated with r is givenby
This is an exponential process generator since 1-ris a random number and can be replaced by r.
.log)/1()1log()/1( r r xn PP !!
8/6/2019 Or Simulation Lecture
20/48
RN Generation Cont d
RemarkI. W e can pick up random numbers from
random table, orII. Use built-in Excel formula to generate
random numbers
8/6/2019 Or Simulation Lecture
21/48
RN Generation Cont d
W hile 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 nextnumber, but a consistent, unvaried pattern should be
followed in drawing random numbers..
W e should not jump from one number to another
indiscriminately
8/6/2019 Or Simulation Lecture
22/48
8/6/2019 Or Simulation Lecture
23/48
8/6/2019 Or Simulation Lecture
24/48
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 .
8/6/2019 Or Simulation Lecture
25/48
Solution
D aily D emand for Tires Frequency
Probability of Occurrence
CumulativeProbability
0 10 10/ 200 = . 05 .051 2 0 20/ 200 = .1 0 .1 5
2 4 0 40/ 200 = .2 0 .35
3 60 60/ 200 = . 30 .65
4 4 0 40/ 200 = .2 0 .8 5
5 30 30/ 200 = .1 5 1. 00
200 days 2 00/ 200 = 1. 00
Table 10.3. Probability of D emand
8/6/2019 Or Simulation Lecture
26/48
Solution Cont d
D aily D emand Probability
CumulativeProbability
Interval of RandomNumbers
0 .05 .05 0 1 through 05
1 .1 0 .1 5 06 through 15
2 .2 0 .35 16 through 35
3 .30 .65 36 through 654 .2 0 .8 5 66 through 85
5 .1 5 1. 00 86 through 99, 00
Table 10.4 Assignment of Random Numbers Assignment of Random Numbers
8/6/2019 Or Simulation Lecture
27/48
Simulation Example 1Simulation Example 1D ay D ay
Number Number
RandomRandom
Number (r)Number (r)
Simulated Simulated D aily D emand D aily D emand
11 3 93 9 33
22 7373 4433 7272 44
44 7575 4455 3 73 7 3366 0 20 2 00
77 8787 55
88 9898 5599 1010 11
1010 4747 33Total= 3 2Total= 3 2
Average= 3 .2Average= 3 .2
8/6/2019 Or Simulation Lecture
28/48
8/6/2019 Or Simulation Lecture
29/48
Example 2 : Simulation of a Queuing System
ConsiderConsider thethe CaseCase of of drivedrive--inin marketmarket whichwhich consistsconsists of of oneonecashcash registrarregistrar (the(the serviceservice facility)facility) andand aa singlesingle queuequeue of of
customerscustomers. . TheThe interinter arrivalarrival timetime andand serviceservice timetime isis asas inin tabletable
aa andand bb..
AssumeAssume thatthat thethe timetime intervalsintervals betweenbetween customercustomer arrivalsarrivals areare
discretediscrete randomrandom variablesvariables. .
8/6/2019 Or Simulation Lecture
30/48
Queuing System Cont d
Arrival interval(min), x
ProbabilityP(x)
1.0 . 2 02 .0 .40
3.0 .30
4.0 .10
Service time(min), y
ProbabilityP(y)
0.5 . 2 0
1.0 .50
2 .0 .30
Table a. D istr ibut ion of arr ivalTable a. D istr ibut ion of arr ivalinter val t imeinter val t ime
Table b. D istr ibut ion of
Table b. D istr ibut ion of ser vice t imeser vice t ime
For 10 customers arr ivals to the cash reg istrar, Calculatea ) Average wa iting t imeb) Average queue l inec) Average t ime in the system
8/6/2019 Or Simulation Lecture
31/48
SolutionF irst we have to develop the cumulative probabilityF irst we have to develop the cumulative probabilitydistribution, to determine random number rangesdistribution, to determine random number ranges ..
Arrival
interval(min), x
Probability
P(x)
Cumulative
probability
Random number
range, r 1
1.0 . 2 0 .2 0 01- 2 02 .0 .40 .60 2 1 60
3.0 .30 . 9 0 61 9 04.0 .10 1.00 9 1- 99 , 00
Table a1. Range of random numbers for arrival interval timeTable a1. Range of random numbers for arrival interval time
8/6/2019 Or Simulation Lecture
32/48
8/6/2019 Or Simulation Lecture
33/48
Solution Cont dSolution Cont d
Custom-er
r1
Arrivalinterv-al
,x
Arrivalclock
Enterfacilityclock
Waiti-ng
T ime
Lengthof
QueueAfterEnter
r2 Servi-ce
T ime, y
Depar-ture
Clock
T ime insystem
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.08 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 .5TotalTotal 1 2 .512 .5 88 2 4.52 4.5
Table c. Simulation of the queuing system for 1 0 customersTable c. Simulation of the queuing system for 1 0 customers
8/6/2019 Or Simulation Lecture
34/48
Solution Cont dSolution Cont dOnce the simulation is complete, we can compute operatingOnce the simulation is complete, we can compute operatingcharacteristics from the simulation results as follows.characteristics from the simulation results as follows.
Average waiting time=Average waiting time=
Average queue length=Average queue length=
Average timeAverage timein the system=in the system=
r percustomecustomers
min25.110
min5.12 !
customer customers
customers80.
108 !
r percustomecustomers
min45.210
min5.24 !
8/6/2019 Or Simulation Lecture
35/48
Example 3: Simulation of a machine breakdown andExample 3: Simulation of a machine breakdown andMaintenance SystemMaintenance System
A continuous probability distribution of the time betweenmachine breakdowns is given by;
W hen 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 intable (I)
w eeks x x
x f 40,8
)( ee!
W here X = W eeks between mach ine breakdowns
8/6/2019 Or Simulation Lecture
36/48
8/6/2019 Or Simulation Lecture
37/48
Machine breakdown Cont dMachine 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
w eeks x x x f 60,18
)( ee!
W here x= W eeks between mach ine breakdowns
8/6/2019 Or Simulation Lecture
38/48
Machine breakdown Cont dMachine breakdown Cont d
The reduced repair time resulting from the maintenanceprogram is defined by the discrete probability distributionshown in table (II)
M achine repairtime, Y (days)
Probability of repairtime, p(y)
1 .402 .503 .10
Table II. Revised probability distribution of m/c repair timewith the maintenance program
8/6/2019 Or Simulation Lecture
39/48
SolutionSolution
r1 T ime betweenB/D, Xwks
r2 Repair time,ydys
Cost, $ 2 ,000y Cumulative time,xwks
.45.45 2.682.68 .19.19 22 4,0004,000 2.682.68
.90.90 3.803.80 .65.65 22 4,0004,000 6.486.48
.84.84 3.673.67 .51.51 22 4,0004,000 10.1510.15
.17.17 1.651.65 .17.17 22 4,0004,000 11.8011.80
.74.74 3.443.44 .63.63 22 4,0004,000 15.2415.24
.94.94 3.883.88 .85.85 33 6,0006,000 19.1219.12
.07.07 1.061.06 .37.37 22 4,0004,000 20.1820.18
.15.15 1.551.55 .89.89 33 6,0006,000 21.7321.73
.04.04 0.800.80 .76.76 33 6,0006,000 22.5322.53
.31.31 2.232.23 .71.71 33 6,0006,000 24.7624.76
.07.07 1.061.06 .34.34 22 4,0004,000 25.8225.82
.99.99 3.983.98 .11.11 11 2,0002,000 29.8029.80
.97.97 3.943.94 .27.27 22 4,0004,000 33.7433.74
.73.73 3.423.42 .10.10 11 2,0002,000 37.1637.16
.13.13 1.441.44 .59.59 22 4,0004,000 38.6038.60.03.03 0.700.70 .87.87 33 6,0006,000 39.3039.30
.62.62 3.153.15 .08.08 11 2,0002,000 42.4542.45
.47.47 2.742.74 .08.08 11 2,0002,000 45.1945.19
.99.99 3.983.98 .89.89 33 6,0006,000 49.1749.17
.75.75 3.463.46 .42.42 22 4,0004,000 52 .6352 .63$ 84,000
Table Simulation of the m/c breakdown and repair without the maint. Prog.
8/6/2019 Or Simulation Lecture
40/48
SolutionSolution
r1 T ime betweenB/D, Xwks r2 Repair time,ydys Cost,$2 ,000y Cumulative time,xwks
.45.45 4.034.03 .19.19 11 2,0002,000 4.034.03
.90.90 5.695.69 .65.65 22 4,0004,000 9.729.72
.84.84 5.505.50 .51.51 22 4,0004,000 15.2215.22
.17.17 2.472.47 .17.17 11 2,0002,000 17.6917.69
.74.74 5.165.16 .63.63 22 4,0004,000 22.8522.85
.94.94 5.825.82 .85.85 22 4,0004,000 28.6728.67
.07.07 1.591.59 .37.37 11 2,0002,000 30.2930.29
.15.15 2.322.32 .89.89 22 4,0004,000 32.5832.58
.04.04 1.201.20 .76.76 22 4,0004,000 33.7833.78
.31.31 3.343.34 .71.71 22 4,0004,000 37.1237.12
.07.07 1.591.59 .34.34 11 2,0002,000 38.7138.71
.99.99 5.975.97 .11.11 11 2,0002,000 44.6844.68
.97.97 5.915.91 .27.27 11 2,0002,000 50.5950.59
.73.73 5.125.12 .10.10 11 2,0002,000 55.7155.71$ 42 ,000
Table Simulation of the m/c breakdown and repair with the maint. Prog.
8/6/2019 Or Simulation Lecture
41/48
Summary of the resultSummary of the result
Option1:Option1:W
ith out the maintenance programCost = $84,000
Option 2Option 2 : W ith maintenance programCost = $20,000+ $42,000
= $62,000
Therefore Option 2 is better for the organization withProfit = $84,000 - $62,000
= $22 ,000= $22 ,000
8/6/2019 Or Simulation Lecture
42/48
Role of Computers in Simulation
Computers are critical in simulating complex tasksComputers are critical in simulating complex tasks
Computers are used to:Computers are used to:
Generate random numbers;Generate random numbers;
Simulate the given problem with varying values of variablesSimulate the given problem with varying values of variables
in few minutes; andin few minutes; and
help the decisionhelp the decision- -maker to prepare reports which enablemaker to prepare reports which enable
him to make decisions quickly as well as draw validhim to make decisions quickly as well as draw valid
conclusions.conclusions.
8/6/2019 Or Simulation Lecture
43/48
Computers in Simulation Cont d
Com puter languages a va ilableCom puter languages a va ilable1.1. GeneralGeneral- -pur pose languagespur pose languages FOR T R AN,FOR T R AN,
B ASIC, P AS C AL, COBO L, C++ etc.B ASIC, P AS C AL, COBO L, C++ etc.
2.2. Sp ec ialSp ec ial--pur pose s imulat ion languagespur pose s imulat ion languages -- GP SS ,GP SS ,SIMS CR IP T, DYN AMO, SIMULA , AREN A etc.SIMS CR IP T, DYN AMO, SIMULA , AREN A etc.1.1. Requ ire less programm ing t ime for large s imulat ionsRequ ire less programm ing t ime for large s imulat ions
2.2. Usually more eff icient and eas ier to check for errorsUsually more eff icient and eas ier to check for errors
3.3. RandomRandom- -number generators are bu ilt innumber generators are bu ilt in
Spreadsheets such as Excel can be used to developSpreadsheets such as Excel can be used to developsome simulationssome simulations
8/6/2019 Or Simulation Lecture
44/48
Using Software in SimulationUsing Software in Simulation
8/6/2019 Or Simulation Lecture
45/48
Simulation ApplicationsSurvey c onducte d dur ing the 1980s indi cate that a lar ge major ity of
major corporat ions use simulation in such f unctional area s as pr oduct ion, corporate p lannin g, engineer ing, f inancial analysis,
research a nd d eve lo pment, market ing, infor mation systems, and
per sonn el.
Follow ing are descr i ptions of so me of the more comm on
app licat ions of Simulation:
Queu ing
Inventory contr olPr oduct ion and manuf actur ing
Fin ance
Market ing
8/6/2019 Or Simulation Lecture
46/48
Applications Cont d Assembly-l ine balanc ing
Park ing lot and harbor des ign
Distr ibut ion system des ign
S chedul ing a ircraft
Labor-h ir ing dec is ions
Personnel schedul ingT raff ic-light t iming
Bus schedul ing
Ta xi, truck, and ra ilroaddis patch ing
Product ion fac ilityschedul ing
Plant layout
Product ion schedul ing
S ales forecast ing
Inventory plann ing andcontrol
8/6/2019 Or Simulation Lecture
47/48
Advantages of SimulationAdvantages of Simulation1.1. R elatively stra ightfor war d and flex ib leR elatively stra ightfor war d and flex ib le
2.2. Can be used to analyze lar ge and com plex rea lCan be used to analyze lar ge and com plex rea l--wo r ld situat ionswo r ld situat ions
that cann ot be solved by conventional modelsthat cann ot be solved by conventional models
3.3. R ealR eal--wo r ld com plicat ions can be included that most wo r ld com plicat ions can be included that most
mathe matical models cann ot per mi tmathe matical models cann ot per mi t
4.4. Tim e com pression is poss ib leTim e com pression is poss ib le
5.5. A llows whatA llows what --if type s of q uestionsif type s of q uestions
6.6. Does not in ter f ere with rea lDoes not in ter f ere with rea l--wo r ld systemswo r ld systems
7.7. Can study the in teract ive eff ect s of indi vidual com ponents or Can study the in teract ive eff ect s of indi vidual com ponents or
var ia bles in or der to deter min e which ones are im portantvar ia bles in or der to deter min e which ones are im portant
8/6/2019 Or Simulation Lecture
48/48
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