I'm new to R and very new to discrete event simulation. r.simmer seems to be a very good package for doing this, so trying to model strategies for hospital bed admissions using it, it seems natural to me that the trajectory branch option be able to examine both resource state and arbitratry attributes of the arrival e.g.
library(simmer)
daypatient<-trajectory() %>%
log_("sent home") %>%
timeout(300) %>%
seize("admin",1) %>%
release("admin",1) %>%
seize("bed",1)
patient <-trajectory() %>%
log_("start pat") %>%
branch(
function() rnorm(1)>0.5 ,
# actually want to inspect arrival priority and queues to decide which trajectory path to follow
continue= TRUE,
daypatient
) %>%
seize("bed",1) %>%
seize("theatre",1) %>%
timeout(rnorm(1,5)) %>%
release("theatre",1) %>%
timeout(50) %>%
release("bed",1)
# some patients need treatment pdq...
serious<-data.frame(time=rexp(10,1),priority=2)
# ... other less so
wounded<-data.frame(time=rexp(10,1),priority=1)
hos <- simmer() %>%
add_resource("bed",2) %>%
add_resource("admin",3) %>%
add_resource("theatre",1) %>%
add_dataframe("serious",
patient,
serious) %>%
add_dataframe("wounded",
patient,
wounded)
hos %>% run(until = 500)
is there any way to do this, or am I fundamentally misunderstanding the r.simmer/DES framework?