Chapter 5 of Kelton

Problem # 1

What is the difference between an object property and an object state?

An object property is a characteristic of the object that can be predetermined and that dictates certain behaviors of the object. For example, we can specify the time a server takes to process an entity. An object state is a value that will change as the model executes at any given time. In this situation the object state could be whether the server object is currently processing an entity or not.

Problem # 2

Consider a process associated with a Server object. What is the difference between a token’s parent object and its associated object?

A token is a delegate of an object when a process is intitiated, so when an entity arrives at a server, for example, the parent object would be the server (because it creates the token at the beginning of the process) and the associated object would be the entity itself. This is because when the entity arrived at the server this prompted the parent object to “birth” the token.

Problem #3

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

#The first server recieves new entities at a rate of 10/hr and processed them at 15/hr.
ser1 <- mmc(10,15,1)

#The 2nd server will receive entities at a rate of 10/hr because the first server processed them at a rate faster than they came in.
ser2 <- mmc(10,20,1)

combined <- ser1[1:4] + ser2[1:4]
combined
##          p       Lq L   W
## 1 1.166667 1.833333 3 0.3
cbind(combined, ser1$p, ser2$p)
##          p       Lq L   W    ser1$p ser2$p
## 1 1.166667 1.833333 3 0.3 0.6666667    0.5