Complete problems 2, 3, 5, and 12 from Section 2.6 in Kelton.
For an M/M/1 queqe with mean interarriaval time 1.25 minutes and mean service time 1 minute, find all five of \(W_{q}\), W, \(L_{q}\), L, and \(\rho\). For each, interprete in words. Be sure to state all of your units (always!), and the relevant time frame of operation.
This system is an expontital interval time, exponential service time, and single server system.
\(L = \lambda * W\) \(L_{q} = \lambda * W_{q}\) \(W = W_{q} + E(S)\)
In this case, we have \(\lambda = 1/1.25 = 0.8\) min and \(E(S) = 1\) min. Expressing the formula in a different way, we can get L, and use that to calculate W, \(W_{q}\), \(L_{q}\), and \(\rho\).
\(L = \frac{\lambda}{1/E(S) - \lambda} = \frac{0.8}{1/1 - 0.8} = 4\) \(W_{q} = \frac{L}{\lambda} - E(S) = 4/0.8 = 5 - 1 = 4\) \(W = W_{q} + E(S) = 4 + 1 = 5\) \(L_{q} = \lambda W_{q} = 0.8 * 4 = 3.2\)
\(\rho = \lambda / (c * \mu) = 0.8/(1*1) = 0.8\)
For this problem, we have an average total number of 4 people in the system, with a 5 minute average time in the system. The average time in queue is 4 minutes, and average people in queue is 3.2. Utilization is 80%.
Repete except assume that the service times are not exponentially distributed, but rather (continuously) uniformally distributted between a=0.1 and b=1.9. Note that the expected value of the uniform distribution is (a+b)/2 = 1, the same as the expected service time as before. Compare all five of your numerical results to the previous and explain intuitively with respect to this change in the service-time distribution (but with its expected value remaining at 1). Hint: In case you’ve forgotten, or your calculus has rusted completely shut, or you haven’t already found it with a web search, the standard deviation of the continuous uniform between a and b is sqrt((b-a)^2 / 12) (that’s right, you always divide by 12 regardless of what a and b are… the calculus just works out that way).
This is an M/G(?)/1 model where:
\(W_{q} = \frac{\lambda( \sigma^2 + 1/\mu^2)}{2(1-\lambda/\mu)}\) \(\lambda = 1 / arrivaltime = 1/1.25 = 0.8\) \(\sigma^2=\sqrt{(b-a)^/12}^2 = 0.9/12 = 0.075\) \(\mu = 1/E(S) = \frac{1}{0.5*0.1+0.5*1.9} = 1\) \(W_{q} = \frac{0.8(0.075 + 1/1^2)}{2(1-0.8/1)} = 1.34375/0.5 = 2.15\)
With service times being \(E(S)=0.5*0.1+0.5*1.9 = 1\), same as Problem 1, some customers will likely face a wait due to uncertainty as to which service time they will incur. By adding the \(\sigma^2\) into the formula for \(W_{q}\), the expected time in queue is 2.15 mintues.
\(L_{q} = \lambda * W_{q} = 0.8 * 2.15 = 1.72\) \(W = W_{q} + E(S) = 2.15 + 1 = 3.15\) \(L = \lambda * W = 0.8 * 3.15 = 2.52\)
The average number in the system (L) is 2.52 persons, compared to the previous 4 persons This is due to the decreased service times for some customers, creating a queue wait time of (\(W_{q}\)) of 2.15 mintues vs 4 mintues in queue. \(L_{q}\) (average number in queue) of 1.72 persons, vs 3.2 persons, is a major difference. Average service time (W) is 3.15 minutes vs 5 minutes.
Repeate the first problem, execept assume that the service times are triangularly distributed between a=0.1 and b=1.9, and with the mode at m=1.0. Compare all five of your results to those from the first two parts. Hint: the expected value of a triangular distribution between a and b, and with mode m (a < m < b), is (a + m + b)/3, and the stardard deviation is sqrt((a^2 + m^2 + b^2 - am - ab - bm)/18) … do you think maybe it’s time to dust off that calculus book (or at least hone your web-search skills)?
This is an M/G(?)/1 model. While I’m not familiar with a triangular distribution terminology, I assume that means the probability is evenly distributed between a, b, and m. With these inputs, expected service time is unchanged, as is \(\mu\), though \(\sigma^2\) is different.
\(E(S) = \frac{0.1 + 1.0 + 1.9}{3} = 1\) \(\mu = \frac{1}{E(S)} = \frac{1}{1} = 1\) \(\sigma^2 = \sqrt{(a^2 + m^2 + b^2 - am - ab - bm)/18}^2 = \frac{0.1^2+1.0^2+1.9^2 - 0.1(1) - 0.1(1.9) - 1(1.9)}{18} = 0.135\) \(W_{q} = \frac{0.8(0.135 + 1/1^2)}{2(1-0.8/1)} = 1.40625/0.5 = 2.27\)
A slight increase in wait times (\(W_{q}\)) = 2.27 from the previous 2.15 mintues is likely due to the weighting of longer service times, where there is less of a chance of a short service time.
\(L_{q} = 0.8 * 2.27 = 1.816\) \(W = 2.27 + 1 = 3.27\) \(L = 0.8 * 3.27 = 2.616\) \(\rho = 0.8\)
The longer service times have an increase in other metrics as well with an average persons in queue (\(L_{q}\)) of 1.816 vs 1.72 and 3.2 persons in the second and first problems, respectively. Average time in the system (W) is also higher at 3.27 mintues, vs 3.15 minutes and 5 minutes of the previous two systems. Average time in queue (\(W_{q}\)) is also higher at 2.27 minutes for this system and 2.15 and 4 minutes of the previous two systems. Number of people in the system (L) of 2.616 is higher than heprevious systems as well (2.52 and 4).
Repete the first part, except for M/M/4 queue with mean interarrival time 1.25 minutes and mean service time 3 minutes at each of the three servers. Hint: You might want to consider creating a computer program or spreadsheet, or use mmc.exe.
With 4 servers
\(p(0) = \frac{1}{\frac{(cp)^c}{c!(1-p)} + \sum_{\substack{c-1 \\ n=0}}\frac{(cp)^n}{n!}}\)
MM3 <- function(arrivetime, servtime, c=3){
#calculate required inputs
lambda <- 1/arrivetime
mu <- 1/servtime
rho <- lambda / (c*mu)
#calculate P(0) for 3 servers
p_0 <- (((1*rho)^0/factorial(0)) + ((2*rho)^1/factorial(1)) + ((3*rho)^2/factorial(2)) + ((3*rho)^3*(1/factorial(3))*(1/(1-rho))))^(-1)
#calculate required outputs
p_inf <- ((c*rho)^c * p_0) / (factorial(c) * (1-rho))
L <- c*rho + ((rho * p_inf)/1-rho)
W <- L/lambda
W_q <- W - 1/mu
L_q <- W_q * lambda
df <- data.frame('lambda'=lambda, 'mu'=mu, 'c'=c, 'rho'=rho, 'L'=L, 'L(q)'=L_q, 'W'=W, 'W(q)'=W_q, 'P(0)'=p_0, 'P(L(inf) >= c)'=p_inf)
df
}
MM3(1.25, 3)
## lambda mu c rho L L.q. W W.q.
## 1 0.8 0.3333333 3 0.8 2.142118 -0.2578824 2.677647 -0.3223529
## P.0. P.L.inf.....c.
## 1 0.05882353 0.6776471
Using this method as described in the book ‘Discrete-Event System Simulation’ by Jerry Banks et all, there is a major difference in the result between this result and the one from the ‘QueueingTools.xls’ file the book refers to. There is likely to be an issue in my calculations of P(0). The result using the worksheet is shown below:
df2 <- data.frame('lambda'=c(0.8), 'mu'=c(0.333), 'c'=c(3), 'rho'=c(0.8), 'L'=c(4.989), 'L(q)'=c(2.589), 'W'=c(6.236), 'W(q)'=c(3.236), 'P(0)'=c(0.056), 'P(L(inf) >= c)'=c('N/A'))
df2
## lambda mu c rho L L.q. W W.q. P.0. P.L.inf.....c.
## 1 0.8 0.333 3 0.8 4.989 2.589 6.236 3.236 0.056 N/A
In the urgent-care clinic of Figure 2.1, suppose that the patients arrive from outside into the clinic (coming from the upper right corner of the figure and always into the Sign In station) with interarrival times that are exponentially distributed with mean 6 minutes. The number of individual servers at each station and the branching probabilities are all as shown in Figure 2.1. The service times at each node are exponentially distributed with means (all in minutes) of 3 for Sign In, 5 for Registration, 90 for Trauma Rooms, 16 for Exam Rooms, and 15 for Treatment Rooms. For each of the five stations, compute the “local” traffic intensity p(Station) there. Will this clinic “work,” i.e., be able to handle the external patient load? Why or why not? If you could add a single server to the system, and add it to any of the five stations, where would you add it? Why? Hint: Unless you like using your calculator, a spreadsheet or computer program might be good, or perhaps use mmc.exe.
SignIn: M/M/2
90% go to Registration: M/M/1 > Exam Rooms: M/M/3 > 60% to Treatment Rooms: M/M/2 > 40% Exit
10% go to Trauma Rooms: M/M/2 > Treatment Rooms: M/M/2
Sign In: M/M/2, arrival rate \(\lambda_{SignIn}\), service time 3 min. Registration: M/M/1, arrival rate \(0.9\lambda_{SignIn}\), service time 5 min. Trauma Rooms: M/M/2, arrival rate \(0.1\lambda_{SignIn}\), service time 90 min. Exam Rooms: M/M/3, arrival rate \(0.9\lambda_{SignIn}\), service time 16 min. Treatment Rooms: M/M/2, arrival rate \((0.9)(0.6)\lambda_{SignIn} + 0.1\lambda_{SignIn} = 0.64\lambda_{SignIn}\), service time 15 min.
SignIn_MM2 <- function(arrivetime, servtime, c=2){
#calculate required inputs
lambda <- 1/arrivetime
mu <- 1/servtime
rho <- lambda / (c*mu)
#calculate P(0) for 2 servers
p_0 <- (((1*rho)^0/factorial(0)) + ((2*rho)^1/factorial(1)) + ((2*rho)^2*(1/factorial(2))*(1/(1-rho))))^(-1)
#calculate required outputs
p_inf <- ((c*rho)^c * p_0) / (factorial(c) * (1-rho))
L <- c*rho + ((rho * p_inf)/1-rho)
W <- L/lambda
W_q <- W - 1/mu
L_q <- W_q * lambda
df <- data.frame('lambda'=lambda, 'mu'=mu, 'c'=c, 'rho'=rho, 'L'=L, 'L(q)'=L_q, 'W'=W, 'W(q)'=W_q, 'P(0)'=p_0, 'P(L(inf) >= c)'=p_inf)
df
}
SignIn_MM2(6, 3)
## lambda mu c rho L L.q. W W.q. P.0. P.L.inf.....c.
## 1 0.1666667 0.3333333 2 0.25 0.275 -0.225 1.65 -1.35 0.6 0.1
Registration_MM1 <- function(servtime){
#calculate required inputs
lambda <- 0.9 * 1/6
mu <- 1/servtime
c<-1
rho <- lambda / (c*mu)
#calculate required outputs
L_q <- rho^2 / (1-rho)
L <- rho / (1-rho)
W <- 1 / (mu * (1-rho))
W_q <- rho/(mu * (1-rho))
df <- data.frame('lambda'=lambda, 'mu'=mu, 'c'=c, 'rho'=rho, 'L'=L, 'L(q)'=L_q, 'W'=W, 'W(q)'=W_q)
df
}
Registration_MM1(5)
## lambda mu c rho L L.q. W W.q.
## 1 0.15 0.2 1 0.75 3 2.25 20 15
Trauma_MM2 <- function(servtime, c=2){
#calculate required inputs
lambda <- 0.1 * 1/6
mu <- 1/servtime
rho <- lambda / (c*mu)
#calculate P(0) for 2 servers
p_0 <- (((1*rho)^0/factorial(0)) + ((2*rho)^1/factorial(1)) + ((2*rho)^2*(1/factorial(2))*(1/(1-rho))))^(-1)
#calculate required outputs
p_inf <- ((c*rho)^c * p_0) / (factorial(c) * (1-rho))
L <- c*rho + ((rho * p_inf)/1-rho)
W <- L/lambda
W_q <- W - 1/mu
L_q <- W_q * lambda
df <- data.frame('lambda'=lambda, 'mu'=mu, 'c'=c, 'rho'=rho, 'L'=L, 'L(q)'=L_q, 'W'=W, 'W(q)'=W_q, 'P(0)'=p_0, 'P(L(inf) >= c)'=p_inf)
df
}
Trauma_MM2(90)
## lambda mu c rho L L.q. W W.q.
## 1 0.01666667 0.01111111 2 0.75 1.232143 -0.2678571 73.92857 -16.07143
## P.0. P.L.inf.....c.
## 1 0.1428571 0.6428571
Exam_MM3 <- function(servtime, c=3){
#calculate required inputs
lambda <- 0.9 * 1/6
mu <- 1/servtime
rho <- lambda / (c*mu)
#calculate P(0) for 3 servers
p_0 <- (((1*rho)^0/factorial(0)) + ((2*rho)^1/factorial(1)) + ((3*rho)^2/factorial(2)) + ((3*rho)^3*(1/factorial(3))*(1/(1-rho))))^(-1)
#calculate required outputs
p_inf <- ((c*rho)^c * p_0) / (factorial(c) * (1-rho))
L <- c*rho + ((rho * p_inf)/1-rho)
W <- L/lambda
W_q <- W - 1/mu
L_q <- W_q * lambda
df <- data.frame('lambda'=lambda, 'mu'=mu, 'c'=c, 'rho'=rho, 'L'=L, 'L(q)'=L_q, 'W'=W, 'W(q)'=W_q, 'P(0)'=p_0, 'P(L(inf) >= c)'=p_inf)
df
}
Exam_MM3(16)
## lambda mu c rho L L.q. W W.q. P.0.
## 1 0.15 0.0625 3 0.8 2.142118 -0.2578824 14.28078 -1.719216 0.05882353
## P.L.inf.....c.
## 1 0.6776471
Treatment_MM2 <- function(servtime, c=2){
#calculate required inputs
lambda <- 0.64 * 1/6
mu <- 1/servtime
rho <- lambda / (c*mu)
#calculate P(0) for 2 servers
p_0 <- (((1*rho)^0/factorial(0)) + ((2*rho)^1/factorial(1)) + ((2*rho)^2*(1/factorial(2))*(1/(1-rho))))^(-1)
#calculate required outputs
p_inf <- ((c*rho)^c * p_0) / (factorial(c) * (1-rho))
L <- c*rho + ((rho * p_inf)/1-rho)
W <- L/lambda
W_q <- W - 1/mu
L_q <- W_q * lambda
df <- data.frame('lambda'=lambda, 'mu'=mu, 'c'=c, 'rho'=rho, 'L'=L, 'L(q)'=L_q, 'W'=W, 'W(q)'=W_q, 'P(0)'=p_0, 'P(L(inf) >= c)'=p_inf)
df
}
Treatment_MM2(15)
## lambda mu c rho L L.q. W W.q.
## 1 0.1066667 0.06666667 2 0.8 1.368889 -0.2311111 12.83333 -2.166667
## P.0. P.L.inf.....c.
## 1 0.1111111 0.7111111
TotalRho <- data.frame(
'SignIn'=SignIn_MM2(6, 3)[['rho']],
'Registration'=Registration_MM1(5)[['rho']],
'Trauma'=Trauma_MM2(90)[['rho']],
'Exam Room'=Exam_MM3(16)[['rho']],
'Treatment'=Treatment_MM2(15)[['rho']])
TotalRho
## SignIn Registration Trauma Exam.Room Treatment
## 1 0.25 0.75 0.75 0.8 0.8
Will the system work? The system should be able to handle the load as no station has higher than 1 utilization. Looking at the details of each station (i.e. L, L_q, etc.) would uncover other details that may be important for the hospital.
If I could add a single server to any room, which would I add it? I would add it to the treatment room, since it not only has the highest utilization rate (along with Exam Room) but it also has a higher probability of a patient than the Exam Room