Closed
Description
This might be a feature request rather than a bug. It would be handy to branch depending on attributes.
library(simmer)
t1 <- create_trajectory("trajectory with a branch") %>%
# Decide whether to branch or not, store in attribute
set_attribute("branch", function() sample(1:2, 1)) %>%
seize("server", 1) %>%
# Branch or not depending on the attribute
branch(function(attrs) attrs[["branch"]], merge=c(T, F),
create_trajectory("branch1") %>%
timeout(function() 1),
create_trajectory("branch2") %>%
timeout(function() rexp(1, 3)) %>%
release("server", 1)
) %>%
release("server", 1)
env<-
simmer() %>%
add_resource("server", 1) %>%
add_generator("patient", t1, at(0), mon = 2) %>%
run()
# Error in eval(expr, envir, enclos) :
# argument "attrs" is missing, with no default