-
Hi, Right now my code is like set.seed(100)
TRJ <- trajectory() %>%
seize("room", 1) %>%
seize("nurse", 1) %>%
timeout(function() rgamma(1, 4, 2)) %>%
release("nurse", 1) %>%
seize("doctor", 1) %>%
timeout(function() rgamma(1, 5, 3)) %>%
release("doctor", 1) %>%
release("room", 1) However, once I change the number of rooms from 3 to 4, the nurse visit durations (and doctor visit durations) don't remain the same, while I need them to remain the same. Thank you so much for your time and help in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
You can set a dataframe with predefined times, which are added as attributes, and then read them from there: library(simmer)
set.seed(100)
patient <- trajectory() %>%
seize("room", 1) %>%
seize("nurse", 1) %>%
timeout_from_attribute("nurse") %>%
release("nurse", 1) %>%
seize("doctor", 1) %>%
timeout_from_attribute("doctor") %>%
release("doctor", 1) %>%
release("room", 1)
n <- 5 # number of patients
df <- data.frame(
time = rexp(n, 1/10), # your interarrival times
nurse = rgamma(n, 2, 2),
doctor = rgamma(n, 5, 3)
)
simmer() %>%
add_resource("room", 10) %>%
add_resource("nurse", 2) %>%
add_resource("doctor", 2) %>%
add_dataframe("patient", patient, df) %>%
run() |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for your quick answer. That is a great help. Unfortunately, there is still an issue. In my simulation trajectory, there is also a branch. For example, assume that patients are required to visit the nurse by 40% probability. So it is like: I was wondering if you could also let me know how I can make the same patients visit the nurse in each scenario. For example if in the scenario with 2 rooms patients 1 and 4 visit the nurse how I can make only patients 1 and 4 visit the nurse in the scenario with 3 rooms? I followed an approach similar to yours as below: Position <- function(n){ library(simmer) env <- simmer() n <- 5 # number of patients env %>% However, it doesn't work. I would greatly appreciate your help on this in advance. |
Beta Was this translation helpful? Give feedback.
You can set a dataframe with predefined times, which are added as attributes, and then read them from there: