Aremu Assignment On Simulation
Aremu Assignment On Simulation
Simulation Methods
By
AREMU, A.O. (04/30GB024)
Department of Civil Engineering
University of Ilorin, Nigeria
May, 2013
1a. What is simulation and under what circumstances can it be used?
Simulation is an imitation of reality. Simulation is a representation of reality through the use of a model or other device
which will react in the same manner as reality under a given set of conditions. Simulation has also been defined as the
2013
Simulation methods by AREMU A.O (04/30GB024)
use of a system model that has the designed characteristics of reality in order to produce the essence of actual
operation. According to Donald G. Malcolm, a simulated model may be defined as one which depicts the working of a
large scale system of men, machines, materials and information operating over a period of time in a simulated
environment of the actual real world conditions. According to Shannon simulation is the process of designing a model of
the real system by conducting experiments with this model for the purpose of understanding the behavior of the
operation of the system.
It is used when the characteristics such as uncertainty, complexity, dynamic interaction between the decision and
subsequent event, and the need to develop detailed procedures and finely divided time intervals combine together in
one situation, it becomes too complex to be solved by any of the techniques of mathematical programming and
probabilistic models.
Quantification of the variables is another difficulty. In a number of situations it is not possible to quantify all the
variables that affect the behavior of the system.
In very large and complex problems, the large number of variables and the inter-relationships between them
make the problem very unwieldy and hard to program. The number of variables may be too large and may
exceed the capacity of the AVAILABLE COMPUTER.
Simulation is, b no means, a cheap method of analysis. In a number of situations, such as corporate planning,
simulation is comparatively costlier and time consuming.
Other important limitations stem from too much tendency to rely on the simulation models. This results in
application of the technique to some simple problems which can more approximately be handled by other
techniques of mathematical programming.
c. Describe a method for generation of random numbers. Generate 10 random numbers by using the method
suggested.
Congruence Method or Residue Method: is one of the most commonly used recursive procedures which are used to
generate pseudo-random numbers by some arithmetic operations. It is describe by this expression
r i +1=( a r i +b ) ( modulo m ) ,
Where a, b, and m are constants and r i , r i +1, are the i th and (i+1)th random numbers. The expression implies
multiplying of a by r i , addition of b and then dividing by m . Then r i +1 is the remainder or residue. To begin the process
of random number generation, in addition to a , b , and m , the value of r 0 is also required. It may be any random number
and is called seed.
The congruence random number generator may be of the addictive, multiplicative or mixed type. This expression;
r i +1=( a r i +b ) ( modulo m ) , give the mixed type.
The selection of the values for the constant a , b , and m is very important, because on them depends the length of the
sequence of random numbers, after which the sequence repeats.
For example the procedure of random number generation can be illustrated by taking some values for the constants a ,
b , and m . Leta=16 , b=18∧m=23, using the Mixed Congruence Method to generate ten (10) random number.
Mixed Congruence Method
r i +1=( a r i +b ) ( modulo m ) ,
Taking r o =1 ,
16 ×1+18 34
r 1= = =1+ remainder 11,
23 23
16 ×11+18 194
r 2= = =8+remainder 10 ,
23 23
16 ×10+ 18 178
r 3= = =7 +remainder 17 ,
23 23
16 ×17+18 290
r 4= = =12+remainder 14 ,
23 23
16 × 12+18 210
r6 = = =9+remainder 3 ,
23 23
16 × 3+18 66
r7 = = =2+remainder 20 ,
23 23
16 × 20+18 338
r8 = = =14+r emainder 16 ,
23 23
16 × 16+18 274
r9 = = =11+ remainder 21 ,
23 23
16 ×21+18 354
r 10= = =15+remainder 9
23 23
CVE 657 Assignment No 7
2013
Simulation methods by AREMU A.O (04/30GB024)
The string of random numbers obtained is 1, 11, 10, 17, 14, 12,3, 20, 16 and 21.
4 Study examples 13.7-1 to 13.7-8 (Solve them and show all the steps taken).
Examples 13.7-1
Customers arrive at a service facility to get the required service. The interarrival and service times are constant and are
1.8 minutes and 4 minutes respectively. Simulate the system for 14 minutes. Determine the average waiting time of a
customer and idle time of the service facility.
Solution
The arrival times of customers within 14 minutes period will be:
Customer 1 2 3 4 5 6 7 8
Arrival time 0 1.8 3.6 5.4 7.2 9.0 10.8 12.6
(Minutes)
The time at which the service begins and ends within time period of 14 minutes is shown below. Waiting time of
customers and idle time of service facility are also calculated.
Customer service waiting time idle time of
Begins ends of customers service facility
1 0 4 0 0
2 4 8 4-1.8=2.2 0
3 8 12 8-3.6=4.4 0
4 12 16 12-5.4=6.6 0
The waiting time of the first four customers is calculated above. For the remaining, it is calculated below:
Customer : 5 6 7 8
Waiting time (minutes) : 14-7.2=6.8 5.0 3.2 1.4
Example 13.7-2
Find the value of π experimentally by simulation.
Solution
Draw the coordinate axes OX and OY. With centre O draw an arc PR of unit radius as shown below and complete the
square OPQR. Equation of the circle is x 2+ y 2=1. From random number table below, select any two random numbers,
say 0.2068 and 0.7295 (first two four-digit numbers from the second column) and let x = 0.2068 and y = 0.7295. plot the
point P1 (0.2068, 0.7295). obviously, if x 2+ y 2 ≤ 1, P1 will lie inside or on arc of the circle but if x 2+ y 2> 1, the point P1
will lie outside the arc but within the square.
P Q
y P1 Fig 1
O x R X
2013
Simulation methods by AREMU A.O (04/30GB024)
In this manner, hundreds or thousands of pairs of random numbers are selected and it is ascertained whether the points
representing them lie in/on the arc or beyond the arc but inside the square. Suppose N is the total number of points
considered, out of which n lie in/on the arc. Then
Example 13.7-3
Three points are chosen at random on the circumference of a circle. Find by Monte Carlo methods the probability that
they lie on the same semi-circle.
Solution
1
Draw a circle of circumference unity i.e., of radius as shown in figure below.consider a triplet of three random
2π
numbers (first three two-digit numbers with decimal from the last column) 0.48,, 0.51and 0.06 from the random number
table C.1. these are plotted as points A, B and C in the figure, the distance of a point from O along the circumference
anticlockwise being the value of a random number. Since for this triplet, the difference between the maxima (0.51) and
minima (0.06) is less than 0.50, the triplet lies obviously on a semicircle.
0.25
C= 0.06
A= 0.48
B= 0.51
Distance ≤ 0.5 O
0.75
The general rule for ascertaining whether a triplet of random numbers lies on a semicircle or not is as follows:
CVE 657 Assignment No 7
2013
Simulation methods by AREMU A.O (04/30GB024)
i. Find the difference between the maxima and minima. If this difference is ≤ 0.50, the triplet lies on a semicircle.
ii. If this difference is > 0.50, add unity to those random number(s) in the triplet which is (are) less than 0.50. now
find the difference between the new maxima and the minima. If this new difference is ≤ 0.50, the triplet lies on a
semicircle, otherwise not.
Following the above rule it is ascertained whether each of the following 15 triplets lies ( )or does not lie ( ) on a
semicircle.
S. No Triplet Difference between Difference between new
Maxima and minima maxima and minima
1 0.79 0.56 0.06 0.79-0.06=0.73 1.06-0.56=0.50
2 0.91 0.51 0.13 0.91-0.13=0.78 1.13-0.51=0.62
3 0.65 0.59 0.51 0.65-0.51=0.14
4 0.50 0.13 0.94 0.94-0.13=0.81 1.13-0.50=0.63
5 0.57 0.26 0.78 0.78-0.26=0.52 1.26-0.57=0.69
6 0.33 0.60 0.31 0.60-0.31=0.29
7 0.15 0.64 0.89 0.89-0.15=0.74 1.15-0.64=0.51
8 0.74 0.99 0.63 0.99-0.63=0.36
9 0.58 0.83 0.44 0.83-0.44=0.39
10 0.64 0.59 0.03 0.64-0.03=0.61 1.03-0.59=0.44
11 0.59 0.30 0.16 0.59-0.16=0.43
12 0.57 0.87 0.21 0.87-0.21=0.66 1.21-0.57=0.64
13 0.36 0.60 0.82 0.82-0.36=0.46
14 0.37 0.72 0.33 0.72-0.33=0.39
15 0.90 0.76 0.29 0.90-0.29=0.61 1.29-0.76=0.53
9
Thus out of 15 triplets 9 lie on a semicircle, yielding the required probability ¿ =0.6. However, if a large
15
number of triplets are considered, the probability obtained will be very close to the theoretical value of 0.75.
Example 13.7-4
A town has six wards and they contain 170, 510, 640, 75, 250 and 960 houses respectively. Make a random selection of 8
houses using the table of random numbers. Explain the procedure adopted by you.
Solution
Since the total number of houses is 2,605, first of all random numbers 0-2, 604 are allocated in proportion to the
number of houses in each of the six wards as shown in the table below:
The first random number picked up from the random number table is 2181 (first 4 digits of the first random
number in table C.1). Since it lies within the interval 1,645-2,604, it is fitted against ward number 6 in column 5. The next
random number is 1128, which lies in the interval 680-1, 319 and is, therefore, fitted against ward number 3 in column
5. The next random number 7112 is > 2,604 in column 4 and is, therefore, dropped from consideration. In this manner
the following random numbers are either fitted in column 5 or dropped; 6557 (D or dropped), 4199 (D), 3545 (D), 1749
(F5), 9103 (D), 0764 (F2), 3493 (D), 1292 (F5), 4397 (D), 3807 (D), 4984 (D), 1340 (F5), 0590 (F5), 9566 (D), 7615 (D), 8508
(D), 6970 (D), 5799 (D), 6343 (D), 4165 (D), 0354 (F5). We stop because 8 houses have been selected. The eight houses
selected belong to ward number 6, 3, 6, 3, 3, 4, 2, and 2 respectively.
ii. The stock situation for various days if the decision is made to make 35 cakes everyday is given in the table
below.
Day Demand No of cakes made Stock
1 35 35 -
2 35 35 -
3 15 35 20
CVE 657 Assignment No 7
2013
Simulation methods by AREMU A.O (04/30GB024)
4 35 35 20
5 35 35 20
6 35 35 20
7 15 35 40
8 15 35 60
9 35 35 60
10 15 35 80
1
∴ Average daily demand ¿ ¿
10
270
¿ =27 cakes
10
Example 13. 7-6
A company manufactures around 200 mopeds. Depending upon the availability of raw materials and other conditions,
the daily production has been varying from 196 mopeds to 204 mopeds, whose probability distribution is as given
below:
Production/day : 196 197 198 199 200 201 202 203 204
Probability : 0.05 0.09 0.12 0.14 0.20 0.15 0.11 0.08 0.06
The finished mopeds are transported in a specially designed three-storeyed lorry that can accommodate only 200
mopeds. Using the following 15 random numbers 82, 89, 78, 24, 53, 61, 18, 45, 04, 23, 50, 77, 27, 54 and 10, simulate
the process to find out.
i. What will be the average number of mopeds waiting in the factory?
ii. What will be the number of empty spaces in the lorry?
Solution
The random numbers are established as in the table below:
Production/day Probability Cumulative probability Random number interval
196 0.05 0.05 00 - 04
197 0.09 0.14 05 - 13
198 0.12 0.26 14 - 25
199 0.14 0.40 26 - 39
200 0.20 0.60 40 - 59
201 0.15 0.75 60 - 74
202 0.11 0.86 75 - 85
203 0.08 0.94 86 - 93
204 0.06 1.00 94 - 99
Based on the 15 random numbers given, we simulate the production per day in the table below.
Day no. Random Number Production per day No of mopeds Empty spaces in
waiting the lorry
1 82 202 2 -
2 89 203 5 -
3 78 202 7 -
4 24 198 5 -
5 53 200 5 -
6 61 201 6 -
CVE 657 Assignment No 7
2013
Simulation methods by AREMU A.O (04/30GB024)
7 18 198 4 -
8 45 200 4 -
9 04 196 - -
10 23 198 - 2
11 50 200 - -
12 77 202 2 -
13 27 199 1 -
14 54 200 1 -
15 10 197 - 2
Solution
a. Table below shows the cumulative frequency distribution for X. eight random numbers given for person X are
also fitted. The serial numbers of random numbers are shown in the parentheses.
Thus the eight times for X are 60, 50, 10, 30, 50, 50, 50, and 10 seconds respectively. likewise, the eigth times for Y are
derived from his cumulative distribution below.
b. The above times for persons X and Y are used to calculate the waiting time, if any.
Item no Person X Person Y Waiting time Waiting time
Time in Time out Time in Time Out on the part of Y on the part of item
1 0 60 60 110 60 -
2 60 110 110 190 - -
3 110 120 190 260 - 70
4 120 150 260 330 - 110
5 150 200 330 360 - 130
6 200 250 360 400 - 110
7 250 300 400 430 - 100
8 300 310 430 480 - 120
Thus person X will not have to wait for the remaining seven items.
0+0+70+110 +130+110 +100+120 640
Average waiting time of items ¿ = =80 secs.
8 8
c. In all there are 6 items waiting between the two stations.
d. Total time taken to process 8 items = 480 secs = 8 minutes.
8 item
∴ Average production rate = =1 .
8 minute
CVE 657 Assignment No 7
2013
Simulation methods by AREMU A.O (04/30GB024)
Simulate the dentist’s clinic for four hours and determine the average waiting time for the patients as well as the
idleness of the doctor. Assume that all the patients show up at the clinic at exactly their scheduled arrival times, starting
at 8.A.M. use the following random numbers for handling the above problem: 40, 82, 11, 34, 25, 66, 17 and 79.
Solution
The time taken by the dentist to treat the eight patients arriving in four hours at the clinic is calculated in the table
below.
Thus the times taken by the dentist to treat the eight patients are 60, 15, 45, 45, 45, 15, 45 and 45 minutes respectively.
Let us simulate the dentist’s clinic (for eight patients) starting at 8 A.M.
Patient no Arrival time Dentist’s treatment Waiting time on the idle time for
Starts Ends part of the patient the dentist.
1 8.00 8.00 9.00 - -
2 8.30 9.00 9.15 30 -
3 9.00 9.15 10.00 15 -
4 9.30 10.00 10.45 30 -
5 10.00 10.45 11.30 45 -
6 10.30 11.30 11.45 60 -
7 11.00 11.45 12.30 45 -
8 11.30 12.30 13.15 60 -
1
∴ Average waiting time for the patients = [ 30+15+30+ 45+60+ 45+60 ]
8
CVE 657 Assignment No 7
2013
Simulation methods by AREMU A.O (04/30GB024)
285
¿ =35.625 minutes
8
Average idleness of the dentist = Nil