简体   繁体   中英

How to set conditional service rates in simmer package in R for discrete event simulation?

I am trying to model failure and repair of 2 machines with 1 resource (repairman) available which I can do as follows:

reset(env.ex3)
env.ex3 <- simmer("FailureRepair ex3")

lambda1 <- 0.01 # Failure rate
lambda2 <- 0.02
mu1 <- 0.2 # Repair rate
mu2 <- 0.4

traj <- trajectory() %>%
  seize("Repairman") %>%
  timeout(function() rexp(1, mu1)) %>%
  release("Repairman")

env.ex3 %>%
  add_resource("Repairman", queue_size = Inf) %>%
  add_generator("failureOne", traj, function() rexp(1, lambda1)) %>%
  add_generator("failureTwo", traj, function() rexp(1, lambda2)) %>%
  run(until = 1000000)

env.ex3 %>% get_mon_arrivals(per_resource = T) 

Notice that I used only one trajectory for resource with mu1 . I would like to extend this model so that "failureOne" and "failureTwo" have different service rates ( mu1 and mu2 , respectively) from the same resource. So the underlying assumption is, if a resource is occupied in servicing a failure, other failure has to wait until the resource becomes available.

If I use two separate trajectory, as per my understanding, it would mean there are two separate resources for repairing and if the failure times of two machines overlap then they will be repaired simultaneously, which I do not want to model.

Can anyone please help?

You defined one unit of "repairman", and you can use that resource from as many trajectories as you like: if one gets the resource, the others wait. Use two trajectories:

traj1 <- trajectory() %>%
  seize("Repairman") %>%
  timeout(function() rexp(1, mu1)) %>%
  release("Repairman")

traj2 <- trajectory() %>%
  seize("Repairman") %>%
  timeout(function() rexp(1, mu2)) %>%
  release("Repairman")

env.fr2 %>%
  add_resource("Repairman", queue_size = Inf) %>%
  add_generator("M1.failure", traj1, M1.running) %>%
  add_generator("M2.failure", traj2, M2.running) %>%
  run(100000)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM