Problem # 13
mmc <- function (mean_inter, mean_service, c) {
lam <- mean_inter
mu <- mean_service
# If p is less than 1, we have a stable queue
p <- lam/(mu*c)
#empty vector to stre values
summ <- 0
for (i in 1:c) {
summ <- summ + (c*p)^(i-1)/(factorial(i-1))
}
p0 <- (((c*p)^c)/(factorial(c)*(1-p)) + summ)^-1
#Wq is the steady state average time in the queue
Wq <- ((c*p)^c*p0) / (factorial(c)*c*mu*(1-p)^2)
#W is the steady state average time in the system
W <- Wq + 1/mu
# Lq is the steady state average number of entities in the queue
Lq <- (p * ((c*p)^c) * p0)/ (factorial(c)*((1-p)^2))
#L is the steady state average number of entities in the system (rather than the number in queue)
L <- Lq + (lam/mu)
df <- data.frame(p=p, Lq=Lq, L=L, W=W, Wq=Wq)
return(df)
}
# In Minutes
mmc((120/60), (50/60), 3)
## p Lq L W Wq
## 1 0.8 2.588764 4.988764 2.494382 1.294382