Problem 14.b

In this problem we will build a simio model for M/M/4 queue with arrival rate \(\lambda\)=2.4 per minute and servervice rate \(\mu\)=0.7 per minute for each of the 4 individual server.

We will first determine the following steady-state theoritical results for \({ W }_{ q }\), W, \({ L }_{ q }\), L, and \(\rho\) and we will then compare these results to the results obtained by the simio simulation.

\({ W }_{ q }\) denotes the steady-state average time in the queue,
W denotes the steady-state average time in the system,
\({ L }_{ q }\) denotes the steady-state average number of entities in the queue,
L denotes the steady-state average number of entities in the system, and
\(\rho\) denotes the steady-state utilization of the server

\(\mu\) can be expressed as:
\(\mu=\frac { 1 }{ E(S) }\), where S is an RV representing an entity’s service time in a individual server.

For the subsequent calculations, we will make use of the little law and other relationships, mainly:

\(L=\lambda\cdot W\)
\({ L }_{ q }=\lambda\cdot { W }_{ q }\)
\(W={ W }_{ q }+E(S)\)

\(\rho =\frac { \lambda }{ c\cdot \mu }\) where c denotes the number of servers

The calculations will be done in R.

## Validation of inputs to any functions will not be done.  We expect input to be valide for calculations

#Function to calculate server utilization 
f_rho <- function(c, lambda, mu) {
  rho <- lambda/(c*mu)
  return(rho)
}

#Function to calculate P(0)
f_p_0 <- function(c, rho) {
  #We will calculate first term separately from sum
  p_0_1<- ((c*rho)^c)/(factorial(c)*(1-rho))
  
  # Calculate sum with for loop
  p_0_2 <- 0
  for (i in 1:c){
    p_0_i <- ((c*rho)^(i-1))/factorial(i-1)
    p_0_2 <- p_0_2 + p_0_i
  }
  
  # Calculate p_0 
  p_0 <- (p_0_1 + p_0_2)^(-1)
  
  return(p_0)
}

#Functions to Calculate Lq for M/M/c queue system
f_Lq_M <- function(c, rho, p_0){
  
  Lq <- ((rho*(c*rho)^c*p_0))/(factorial(c)*(1-rho)^2)
  
  return(Lq)
}

#Function to calculate other values; W, Wq, L from Lq and Lambda

f_little_law <- function (lambda, exp_v, lq){
  # Apply Little Law
  wq <- lq/lambda
  w <- wq+exp_v
  l <- w*lambda
  
  return(list("Wq"=wq, "W"=w, "L"=l))
}

f_mmc <- function(c, avg_arvl, avg_srv){
  
  #Function to determine Rho, Lq, Wq, L, W for MMC queue
  #Function will take as input parameters
  # c=number of server
  # avg_arvl = Average arrival time
  # avg_srv = Average service time at each server
  
  # This function will return Rho, Wq, W, Lq, L as 1 row data frame
  
  # Calculation lambda and mu
  r_lambda <- 1/avg_arvl
  r_mu <- 1/avg_srv
  
  # Using previously defined functions, calculating rho, p(0), and Lq
  r_rho <- f_rho(c,r_lambda, r_mu)
  r_p_0 <- f_p_0(c, r_rho)
  r_lq <- f_Lq_M(c, r_rho, r_p_0)
  
  # Using Little Law
  r_list <- f_little_law(r_lambda, avg_srv, r_lq)
  
  r_result <- data.frame(r_rho, r_list[[1]], r_list[[2]], r_lq, r_list[[3]])
  
  return(r_result)
}

#-----------------------------------------------#
# Building data frames will all results

# M/M/4 queue
# recasting given parameter to use pre-existing functions 
mm4_lambda <- 2.4
mm4_mu <- 0.7
mm4_c <- 4
mm4_avg_arvl <- 1/mm4_lambda
mm4_avg_srv <- 1/mm4_mu

d_mm4 <- f_mmc(mm4_c, mm4_avg_arvl, mm4_avg_srv)

colnames(d_mm4) <- c("rho", "Wq", "W", "Lq", "L")

knitr::kable(d_mm4)
rho Wq W Lq L
0.8571429 1.757616 3.186187 4.218278 7.646849

Simulation results

After building the model in simio and running 20 repetitions, we obtained the following results.

When specifying model in simio, we need to use average interarrival time given in this case by 0.4166667 and the average service time given by 1.4285714.

Running the model without setting up repetitions gives poor results. The utilization was around 67%. From the calculations, the average number in the queue should equal to 4.22. However, at the beginning of the run, the queue is empty and we are experiencing at start-up bias.

m/m/4 - Single Run

m/m/4 - Single Run

We will set-up a warm-up time of 2, 3, 5 minutes and run 10, 20, 30 repetitions.

m/m/4 - Repetition 2_10

m/m/4 - Repetition 2_10

m/m/4 - Repetition 3_20

m/m/4 - Repetition 3_20

m/m/4 - Repetition 5_30

m/m/4 - Repetition 5_30