Suppose that you would like to develop a discreteevent simul
Suppose that you would like to develop a discrete-event simulation model for an 24/7 emergency clinic with a single physician working at any given time. Assume the interarrival times of patients have the disribution Unif[0.5, 2.5], and the service times of the physician is distributed Unif[1,3] (in hours).
(a) Using a spreadsheet, simulate the system for 20 and 200 patients. For each simulation length make 10 replications.
(b) Compute the average waiting time, percentage of the patients that have to wait and average number of patients in the system. For each of the replications in part (a), and then for the whole simulation. How did increasing the length of the simulation affect the results?
(c) Repeat the 10 replications for 200 patients using Unif[0,4] distribution for service times. How did this change the percentage of the patients that have to wait? Why?
Solution
(a) R-coding
I=c();S=c()
for (i in 1:10){
I[i]=runif(20, 0.5,2.5)
S[i]=runif(20,1,3)
}
I
S
I
[1] 1.2379348 1.7384620 0.5346536 1.6678115 1.1779533 1.1322499 2.3827507
[8] 1.6296191 2.2924993 2.3458833
> S
[1] 1.889899 1.100617 1.036146 2.181505 2.842996 2.550687 2.759606 2.981469
[9] 2.413749 2.799490
For 200 patients is
I=c();S=c()
for (i in 1:10){
I[i]=runif(200, 0.5,2.5)
S[i]=runif(200,1,3)
}
I
S
I
[1] 1.9424041 1.7888142 1.5528759 2.0196499 1.2539421 1.1168511 1.3108667
[8] 0.5128681 0.6059576 1.4046244
> S
[1] 1.530632 2.826028 1.935088 2.515085 1.213858 2.999623 1.420717 1.516060
[9] 1.276642 2.055438
(b)
average number of patients in the system is 1.824
and 20% of the patients have to waited
The increasing the length of the simulation the average waiting time is less.
(c)
S
[1] 1.789561 2.420145 1.543183 1.801045 1.678206 2.154236 1.880624 1.350325
[9] 1.363797 2.259221
This not change the percentage of the patients that have to wait.

