I am trying to learn DES with R for solving maintenance optimization problem. However, I am getting very confused if it is actually a good tool for this.
As an initial trial, I have posted here a very simple problem where a component is functioning at state 0 and failed at state 1 as in image. Both failure and repair times are exponentially distributed with associated rates $\lambda$ and $\mu$ respectively.
My objective is to find the unavailability of the system which is the amount of time system spends on failure state (1) as in image.
I set up the model with simmer as follows (Reproducible):
library(simmer)
library(simmer.plot)
library(magrittr)
set.seed(1234)
env.fr <- simmer("FailureRepair")
lambda <- 1/1000
mu <- 1/10
traj <- trajectory() %>%
seize("Repairman") %>%
timeout(function() rexp(1, mu)) %>%
release("Repairman")
env.fr %>%
add_resource("Repairman", queue_size = Inf) %>%
add_generator("failure", traj, function() rexp(1, lambda)) %>%
run(until = 10000000)
Can anyone help to verify if this representation is correct and how can I calculate the time spent in any of these states?