0

在下面的 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)

也就是说,如果患者 01 看到医生 1,则将其记录在数据表中。

4

1 回答 1

2

默认情况下是这样。要获取此信息,只需get_mon_arrivals使用参数调用per_resource=TRUE。快速示例:

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
于 2018-02-15T09:39:52.497 回答