R中的离散事件模拟

时间:2016-08-01 04:54:15

标签: r

从谷歌我试图理解"煨"用于离散事件模拟的R包。

根据link中给出的示例,我尝试使用create_simulator函数创建模拟器。但我得到以下错误

使用的代码:

      trajectory <- read.table(header=T, text=                           "event_id  description   resource        amount  duration          successor                         1         registration  administration  1       runif(1,3,10)     2                         2         intake        nurse           1       runif(1,10,20)    3                         3         consultation  doctor          1       runif(1,5,15)     NA"  )


    sim <-  create_simulator(name = "SuperDuperSim") %>%  add_trajectory(name = "simple_trajectory", trajectory_df = trajectory) %>%  add_resource(name = "administration", capacity = 1) %>%  add_resource(name = "nurse", capacity = 1) %>%  add_resource(name = "doctor", capacity = 2) %>%  add_entities_with_interval(n = 10, name_prefix = "patient", trajectory_name = "simple_trajectory", interval = "rnorm(1,10)") %>%  replicator(15)

错误:

   Error in eval(expr, envir, enclos) : 
     could not find function "create_simulator"

1 个答案:

答案 0 :(得分:1)

之前我从未使用过此软件包,但在我看来,create_simulator函数在当前版本的软件包中不存在(add_trajectory函数似乎也不存在)。有关simmer包的信息,请访问https://github.com/r-simmer/simmer。更具体地说,介绍如下:https://cran.r-project.org/web/packages/simmer/vignettes/A-introduction.html。从我的网站看来,现在通过键入simmer(nameOfMySimulator)来完成模拟器的创建。