Bryan Adams
Bryan Adams

Reputation: 174

Simmer to Record What Resources are Used

In the following Simmer code, is there a way to record which doctor the patient sees:

  patient_traj <- trajectory(name = "patient_trajectory") %>%
  select(resources = c("doctor1", "doctor2", "doctor3"), policy = "round-robin") %>%
  set_capacity_selected(1) %>%
  seize_selected(amount = 1) %>%
  timeout(5) %>%
  release_selected(amount = 1)

That is if patient01 sees doctor 1 it is recorded in a data table.

Upvotes: 0

Views: 170

Answers (1)

I&#241;aki &#218;car
I&#241;aki &#218;car

Reputation: 975

It is, by default. To get this info, just call get_mon_arrivals with argument per_resource=TRUE. Quick example:

library(simmer)

patient_traj <- trajectory(name = "patient_trajectory") %>%
  select(resources = c("doctor1", "doctor2", "doctor3"), policy = "round-robin") %>%
  set_capacity_selected(1) %>%
  seize_selected(amount = 1) %>%
  timeout(5) %>%
  release_selected(amount = 1)

simmer() %>%
  add_resource("doctor1") %>%
  add_resource("doctor2") %>%
  add_resource("doctor3") %>%
  add_generator("patient", patient_traj, at(0, 1, 2, 3)) %>%
  run() %>%
  get_mon_arrivals(per_resource = TRUE)
#>       name start_time end_time activity_time resource replication
#> 1 patient0          0        5             5  doctor1           1
#> 2 patient1          1        6             5  doctor2           1
#> 3 patient2          2        7             5  doctor3           1
#> 4 patient3          3       10             5  doctor1           1

Upvotes: 2

Related Questions