Thanks for the help on this.
By predefining the model up front like this I'm having difficulty getting replications to run properly (I end up with identical results across all runs).
#### Pull Model Format Together ####
ISM <- simmer("ISM") %>%
add_resource(paste0("emergency_bed_", c(1:52)), Inf) %>%
add_resource(paste0("elective_bed_", c(1:52))) %>%
add_resource(paste0("elective_emerg_bed_", c(1:52))) %>%
add_resource("home", home) %>%
add_dataframe("ED_Patient_", ED_Patient,
data = arrivals,
mon = 0,
col_time = "Day",
time = "absolute",
col_priority = "Priority") %>%
add_dataframe("Elec_Patient_", Elective_Patient,
data = elec_arrivals,
mon = 0,
col_time = "Day",
time = "absolute") %>%
add_dataframe("Elec_Emerg_Patient_", Elective_Emerg_Patient,
data = elec__emerg_arrivals,
mon = 0,
col_time = "Day",
time = "absolute",
col_priority = "Priority") %>%
add_dataframe("Surge_Emerge_Patient", Surge_Patient,
data = surge_arrivals,
mon = 0,
col_time = "Day",
time = "absolute",
col_priority = "Priority") %>%
add_generator(name_prefix = "Capacity_Monitor_", trajectory = daily_capacity_monitor,
distribution = function() c(rep(1, DES_Length)), mon = 1)
for (i in seq_along(sort(unique(RAW_00_Data_dictionary$`Model ID`)))) {
ISM <- ISM %>%
add_global(key = paste0("days_over_cap_bed_", i), 0) %>%
add_global(key = paste0("days_under_cap_bed_", i), 0)
}
for (i in seq_along(sort(unique(RAW_00_Data_dictionary$`Model ID`)))) {
ISM <- ISM %>%
add_resource(paste0("bed_",i), INPUT_inpatient_capacity_Schedules[[i]])
}
for (i in seq_along(sort(unique(RAW_00_Data_dictionary$`Region ID`)))) {
ISM <- ISM %>%
add_resource(paste0("ss_bed_",i), INPUT_BEDS_Short_Stay_capacity_Schedules[[i]])
}
#### Run the Simulation ####
envs <- lapply(1:5, function(x) {
ISM %>%
run(DES_Length, progress = progress::progress_bar$new()$update)
})
If I have this like above I get it run once and then copied.
If I reset(ISM) before running I get it to run 5 times but with identical results.
I'm guessing there's some way of setting the seed for the environment???