Document 12927478

advertisement
Modeling & Simulation- Lecture -8-
12/2013
Hand simulation:
The machine interference problem let us consider a single server queue with a finite
population known as the machine interference problem. This problem arose originally
out of a need to model the behavior of machines. Later on, it was used extensively in
computer modeling. Let us consider M machines. Each machine is operational for a
period of time and then it breaks down. We assume that there is one repairman.
Figure 1: The machine interference problem.
For simplicity, we will assume that the operational time of each machine is equal to 10
units of time. Also, the repair time of each machine is equal to 5 units of time. In other
words, we assume that all the machines have identical constant operational times.
They also have identical and constant repair times. (This can be easily changed to
more complicated cases where each machine has its own random operational and
repair times.)
In this problem, the most important status variable is n, the number of broken down
machines, i.e., those waiting in the queue plus the one being repaired. If n=0, then we
know that the queue is empty and the repairman is idle. If n=1, then the queue is
empty and the repairman is busy. If n>1, then the repairman is busy and there are n-1
broken down machines in the queue. Now, there are two events whose occurrence will
cause n to change. These are:
1. A machine breaks down, i.e., an arrival occurs at the queue.
2. A machine is fixed, i.e., a departure occurs from the queue.
The flow-charts given in figures 2, show what happens when each these events occur.
1
Lecturer: Hawraa Sh.
Modeling & Simulation- Lecture -8-
Figure 2 An arrival event.
12/2013
Departure event
We are now ready to carry out the hand simulation shown below in table 1. Let us
assume that we have 3 machines. Let CL1, CL2, and CL3 be the clocks associated
with machine 1, 2, and 3 respectively (arrival event clocks). Let CL4 be the clock
associated with the departure event. Finally, let MC be the master clock and let R
indicate whether the repairman is busy or idle. We assume that at time zero all three
machines are operational and that CL1=1, CL2=4, CL3=9. (These are known as initial
conditions.)
2
Lecturer: Hawraa Sh.
Modeling & Simulation- Lecture -8-
12/2013
We note that in order to schedule a new arrival time we simply have to set the
associated clock to MC+10. Similarly, each time a new repair service begins we set
CL4=MC+5. A very important aspect of this simulation model is that we only check
the system at time instants at which an event takes place. We observe in the above
hand simulation that the master clock in the above example gives us the time instants
at which something happened (i.e., an event occurred). These times are: 0, 1, 4, 6, 9,
11, 16, ... We note that in-between these instants no event occurs and, therefore, the
system's status remains unchanged. In view of this, it suffices to check the system at
time instants at which an event occurs. Furthermore, having taken care of an event, we
simply advance the Master clock to the next event which has the smallest clock time.
For instance, in the above hand simulation, after we have taken care of a departure of
time 11, the simulation will advance to time 16. This is because following the time
instant 11, there are three events that are scheduled to take place in the future. These
are: a) arrival of machine 1 at time 16; b) arrival of machine 2 at time 21; and c) a
departure of machine 3 at time 16. Obviously, the next event to occur is the latter
event at time 16.
3
Lecturer: Hawraa Sh.
Modeling & Simulation- Lecture -8-
12/2013
Computer simulation example:
Single Server queuing model M / M / 1 queuing model.
Assumptions:
 One waiting queue and one server.
 We will assume that the arrival rate distributed as exponential distribution with rate
(no. of arrivals / unit time) represent by λ.
 The service rate was assumed to be distributed as exponential distribution with rate
(no. of served units / unit time) represent by µ.
 Entities come from infinite population.
 Queue discipline is First Come First Serve (FCFS).
 When the in service unit depart (complete service) the close one to the server (the
head of the queue) will enter first.
Building a Simulation Model
A new version of computer program was developed using visual basic
programming language to simulate this problem according to following steps:
1. Generate pseudo random number using function RND( ).
2. Transform this number to random variable exponentially distributed to represent
the enterarrival time as given by equation (4.3) :
3. Generate another pseudo random number .
4. Transform this numbers to random variable exponentially distributed to represent
the service time as given by equation (4.3):
5. Calculate arrival time (AT), waiting time in the queue(WTQ), idle time (IT),
entering time to server ( ETS ), departure time (DT) and waiting time in the system
(WTS) for each entity in the system. The developed computer simulation program
will perform the required calculation according to the following developed
relations:
4
Lecturer: Hawraa Sh.
Modeling & Simulation- Lecture -8-
12/2013
Table below explains simulation model with more clarity. Each field in the
table calculated by using the computations above.
Table1 The tabular result of simulation model of M / M / 1 queue
NO.
Enterarr
ival
1
2
3
4
5
6
7
8
0.4
0.7
0.6
1.4
1.3
0.3
4.7
0.3
Arrival Waiting
time
in
Queue
0.4
0
1.1
0
1.7
0
3.1
0
4.4
0
4.7
0.5
9.4
0
9.7
000001
Idle
time
Enterse
rvice
Service
time
Departure
time
0.4
0.6
0.4
0.3
1.2
0
4.1
0
0.4
1.1
1.7
3.1
4.4
5.2
9.4
10.3
0.1
0.2
1.1
0.1
0.8
0.1
0.9
0.3
0.5
1.3
2.8
3.2
5.2
5.3
10.3
10.6
Waiting in
whole system
0.1
0.2
1.1
0.1
0.8
0.6
0.9
000002
As an example we take the computations of thousand entity. Table (5.2) clarify
the calculations of two entities ( we take the second and the sixth entities as an
example). Enterarrival for first and second entity are random variables. Also service
times are random variables.
5
Lecturer: Hawraa Sh.
Modeling & Simulation- Lecture -8-
12/2013
Table 2 The calculations of two entities
Calculations for second entity
Arrival
Time(AT
)
Waiting
Time in
Queue
(WTQ)
0.4 + 0.7 =1.1
if current AT >= previous DT then
WTQ=0
1.1> 0.5 then
1.2> WTQ = 0
Idle Time if current AT >= previous DT then IT=
(IT)
current AT previous DT
Entering
Time to
Server
(ETS)
6
4.4+0.3=4.7
if current AT < previous DT then
WTQ= previous DT- current AT
4.7< 5.2 then
WTQ = 5.2-4.7=0.5
if current AT < previous DT then
IT= 0
1.1> 0.5 then
IT= 1.1 – 0.5 = 0.6
4.7< 5.2 then
IT= 0
if current AT >= previous DT then
ETS= current AT
if current AT < previous DT then ETS=
previous DT
1.1>0.5 then
ETS= 1.1
4.7< 5.2 then
ETS= 5.2
Departure
Time
(DT)
1.1+0.2= 1.3
Waiting
Time in
System
(WTQ)
Calculations for sixth entity
1.3 1.1=0.2
5.2+0.1= 5.3
5.3 4.7=0.6
Lecturer: Hawraa Sh.
Download