HW2 604:
2, 3, 5, and 12
2:
For an M/M/1 queue with mean inter-arrival time 1.25min and mean service time 1 minute, find:\(W_{q}\), \(W\), \(L_{q}\), \(L\), and \(\rho\) but this time assume that service times are uniformly distributed between \(a = 0.1\) and \(b = 1.9\) with expected value of service time \(E(S)=\frac{a+b}{2}=1\).
JB:
Given that that the model has exponential interarrival times but service times are not, we can use the model format \(M/G/1\) which can be used for situations when the service time distribution is “anything.” Further, we are given that the standard deviation of the continuous uniform distribution takes the form: \(\sigma = \sqrt{(b-a)^2/12}\) with mean \(svc_t=\frac{1}{2}(a+b)\)
\(W_{q}=\frac{\lambda(\sigma^2+1/\mu^2)}{2(1-\lambda/\mu)}\)
\(\rho=\frac{\lambda}{\mu}\)
\(W=W_{q}+E(S)\)
\(L=\frac{\rho}{(1-\rho)}\)
\(L_{q}=\lambda W_{q}\)
See the below function in R that shows how this calculation will be made:
# with mean interarrival time 1.25min and mean service time 1 minute, find:
my_MG1_func <- function(t_inter, t_svc, sd_t, nm){
lambda <- 1/t_inter # inter-arrival times
mu <- 1/t_svc # svc rate
Wq <- lambda*(sd_t^2+1/mu^2)/(2*(1-lambda/mu)) # avg time in queue
rho <- lambda/mu # utilization of enti
L <- rho/(1-rho) # steady-state avg of enti
W <- Wq + t_svc # steady-st avg time in sy
Lq <- lambda*Wq # steady-st avg enti in q
p0 <- 0
results <- t(c(nm, lambda, mu, Wq, W, Lq, L, rho, p0)) %>%
as.data.frame() %>%
rename(name = V1, lambda=V2, mu=V3, Wq = V4, W = V5, Lq = V6, L = V7, rho = V8, p0=V9)
return(results)
}
Using the given \(a=.1\) and \(b=1.9\), I can find the average time for service:
a <- .1
b <- 1.9
inter_arrival_t <- 1.25
svc_avg <- (a+b)/2 # aka E(S)
arrival_sd <- sqrt((b-a)^2/12)
svc_avg <- (a+b)/2 # aka E(S)
x<-my_MG1_func(inter_arrival_t, svc_avg, arrival_sd, "2:M/G/1")
name | lambda | mu | Wq | W | Lq | L | rho |
---|---|---|---|---|---|---|---|
2:M/G/1 | 0.8 | 1 | 2.54 | 3.54 | 2.032 | 4 | 0.8 |
Below, we’ll look at the compared (note that problem 1 results are shown on line 1) and see that changes have occurred where expected, namely the times in queue \(W_q\), time in system \(W\) and number of entities in queue \(L_q\) have decreased.
name | lambda | mu | Wq | W | Lq | L | rho |
---|---|---|---|---|---|---|---|
1:M/M/1 | 0.8 | 1 | 4 | 5 | 3.2 | 4 | 0.8 |
2:M/G/1 | 0.8 | 1 | 2.54 | 3.54 | 2.032 | 4 | 0.8 |
3:
For an M/M/1 queue with mean inter-arrival time 1.25min and service time triangularly distributed between \(a = 0.1\) and \(b = 1.9\), find:\(W_{q}\), \(W\), \(L_{q}\), \(L\), and \(\rho\).
JB:
As this is similar to problem 2, above, I’ll simply reuse the created function with these altered inputs as this is also a \(M/G/1\) system: \(SvcAvg = \frac{a+m+b}{3}\) and \(\sigma = \sqrt{(a^2 + m^2 + b^2-am-ab-bm)/18}\)
a <- .1
b <- 1.9
m <- 1.0
svc_avg <- (a+b+m)/3
arrival_sd <- sqrt(( a^2 + m^2 + b^2 - a*m - a*b - b*m)/18)
combo2<-rbind(combo, my_MG1_func(inter_arrival_t, svc_avg, arrival_sd, "3:M/G/1")[1:8])
Again, the times in queue \(W_q\), time in system \(W\) and number of entities in queue \(L_q\) have decreased.
name | lambda | mu | Wq | W | Lq | L | rho |
---|---|---|---|---|---|---|---|
1:M/M/1 | 0.8 | 1 | 4 | 5 | 3.2 | 4 | 0.8 |
2:M/G/1 | 0.8 | 1 | 2.54 | 3.54 | 2.032 | 4 | 0.8 |
3:M/G/1 | 0.8 | 1 | 2.27 | 3.27 | 1.816 | 4 | 0.8 |
3:
Repeat probem 1 as a \(M/M/3\) queue with mean interarrival time 1.25 minutes and mean service time 3 minutes at each of the 3 servers.
JB:
See the below function in R that shows how this calculation will be made:
# with mean interarrival time 1.25min and mean service time 3 minute, find:
my_MMC_func <- function(t_inter, t_svc, c, prob = 1, nm){
lambda <- (1/t_inter)*prob # inter-arrival times
mu <- 1/t_svc # svc rate
rho <- lambda/(c*mu) # utilization per enti
i <- (0:(c-1)) # the index to sum over
# prob system is empty i.e. p(0)
p_empty <- 1/(((c*rho)^c)/(factorial(c)*(1-rho)) + sum(((c*rho)^i)/factorial(i)))
Lq <- (rho*((c*rho)^c)*p_empty)/(factorial(c)*(1-rho)^2)#steady-st avg enti in q
Wq <- Lq/lambda # avg time in queue
L <- Lq + rho # steady-state avg of enti
W <- Wq + t_svc # steady-st avg time in sy
Lq <- lambda*Wq # steady-st avg enti in q
results <- t(c(nm, round(lambda,3), round(mu,3), round(Wq,3), round(W,3),
round(Lq,3), round(L,3), round(rho,3), round(p_empty,3))) %>%
as.data.frame(stringsAsFactors=FALSE) %>%
rename(name = V1, lambda=V2, mu=V3, Wq = V4,
W = V5, Lq = V6, L = V7, rho = V8, p0 = V9) %>%
mutate_each(funs(if(is.numeric(.)) as.numeric(.) else .))
return(results)
}
combo3<-rbind(combo2, my_MMC_func(1.25, 3, 3, 1, "5:M/M/3")[1:8])
name | lambda | mu | Wq | W | Lq | L | rho |
---|---|---|---|---|---|---|---|
1:M/M/1 | 0.8 | 1 | 4 | 5 | 3.2 | 4 | 0.8 |
2:M/G/1 | 0.8 | 1 | 2.54 | 3.54 | 2.032 | 4 | 0.8 |
3:M/G/1 | 0.8 | 1 | 2.27 | 3.27 | 1.816 | 4 | 0.8 |
5:M/M/3 | 0.8 | 0.333 | 3.236 | 6.236 | 2.589 | 3.389 | 0.8 |
12:
fig2.1
JB:
Calculate local traffic intensity at each station above: e.g. \(\rho_{exam}\)
Given:
sign_in is \(M/M/2\) with arrival rate \(\lambda_{signin}\).
registration is \(M/M/1\) with arrival rate \(0.9\lambda_{signin}\).
trauma is \(M/M/2\) with arrival rate \(0.1\lambda_{signin}\).
exam is \(M/M/3\) with arrival rate \(0.9\lambda_{signin}\).
treat is \(M/M/2\) with arrival rate \(0.9(0.6)\lambda_{signin}+0.1\lambda_{signin}\).
sign_in_t <- 6 #minutes, mean
signin_svc_t <- 3
reg_svc_t <- 5
trauma_svc_t <- 90
exam_svc_t <- 16
treat_svc_t <- 15
# function(t_inter, t_svc, c, prob = 1, nm)
sign_in <- my_MMC_func(sign_in_t, signin_svc_t, 2, 1, "Sign In:M/M/2")
register <- my_MMC_func(sign_in_t, reg_svc_t, 2, 0.9, "Register:M/M/1")
trauma <- my_MMC_func(sign_in_t, trauma_svc_t, 2, 0.1, "Trauma:M/M/2")
exam <- my_MMC_func(sign_in_t, exam_svc_t, 3, 0.9, "Exam:M/M/3")
treat <- my_MMC_func(sign_in_t, treat_svc_t, 2, (.9*.6+.1), "Treat:M/M/2")
all_stations<-rbind(sign_in, register, trauma, exam, treat)
Below, we review the combined results. First we note that the \(\rho_{name}\) for each station is below 1 - no single station appears to be overrun. Further: we see that the probability of no traffic at a given station \(p_0\) is not too close to zero indicating that there’s movement between the stations.
name | lambda | mu | Wq | W | Lq | L | rho | p0 |
---|---|---|---|---|---|---|---|---|
Sign In:M/M/2 | 0.167 | 0.333 | 0.2 | 3.2 | 0.033 | 0.283 | 0.25 | 0.6 |
Register:M/M/1 | 0.15 | 0.2 | 0.818 | 5.818 | 0.123 | 0.498 | 0.375 | 0.455 |
Trauma:M/M/2 | 0.017 | 0.011 | 115.714 | 205.714 | 1.929 | 2.679 | 0.75 | 0.143 |
Exam:M/M/3 | 0.15 | 0.062 | 17.258 | 33.258 | 2.589 | 3.389 | 0.8 | 0.056 |
Treat:M/M/2 | 0.107 | 0.067 | 26.667 | 41.667 | 2.844 | 3.644 | 0.8 | 0.111 |
Upon reviewing the table I believe that adding additional servers to the Trauma room would have the most impact. See the table below for the output of the same scenario with 1 additional “servers” in Trauma - this has reduced \(W_{q}\) and \(W\) quite significantly.
name | lambda | mu | Wq | W | Lq | L | rho | p0 |
---|---|---|---|---|---|---|---|---|
Sign In:M/M/2 | 0.167 | 0.333 | 0.2 | 3.2 | 0.033 | 0.283 | 0.25 | 0.6 |
Register:M/M/1 | 0.15 | 0.2 | 0.818 | 5.818 | 0.123 | 0.498 | 0.375 | 0.455 |
Trauma:M/M/2 | 0.017 | 0.011 | 14.211 | 104.211 | 0.237 | 0.737 | 0.5 | 0.211 |
Exam:M/M/3 | 0.15 | 0.062 | 17.258 | 33.258 | 2.589 | 3.389 | 0.8 | 0.056 |
Treat:M/M/2 | 0.107 | 0.067 | 26.667 | 41.667 | 2.844 | 3.644 | 0.8 | 0.111 |