【问题标题】:Error: in [Seize]->Timeout->[Release]: Expecting a single value: [extent=11]错误:在 [Seize]->Timeout->[Release] 中:期望单个值:[extent=11]
【发布时间】:2020-06-17 07:41:30
【问题描述】:

我正在使用 R simmer 进行模拟。但是,每次运行时都会收到此错误消息:

错误:在 [Seize]->Timeout->[Release] 中 48.73 处的“truck0”:期待一个 单个值:[extent=11]。

这有什么问题?

这是我的 R 脚本:

rm(list=ls())
#load packages
library(simmer)
library(simmer.plot)

#create an simulation environment
env <- simmer("Terminal")
env

#create a truck trajectory
truck <- trajectory("Truck path", verbose = TRUE) 
truck  

#draw model
truck %>%

  seize("frontdesk",1) %>% 
  timeout(function() rnorm(11.27671,3.233562)) %>% 
  release("frontdesk",1) %>%

  seize("gate-in",1) %>% 
  timeout(function() rnorm(17.54509,9.915719)) %>% 
  release("gate-in",1) %>%

  seize("station",1) %>% 
  timeout(function() rnorm(12.68418,12.55247)) %>% 
  release("station",1) %>%

  seize("lashing",1) %>% 
  timeout(function() rnorm(28.87726,21.0809)) %>% 
  release("lashing",1) %>%

  seize("control",1) %>% 
  timeout(function() rnorm(12.70417,3.711475)) %>% 
  release("control",1) %>%

  seize("frontdesk end",1) %>%
  timeout(function()rnorm(11.27671,3.233562)) %>%
  release("frontdesk end",1)

env <- lapply(1:100, function(i) {
  simmer("Terminal") %>%
    add_resource("frontdesk", 2) %>%
    add_resource("gate-in", 2) %>%
    add_resource("station", 1) %>%
    add_resource("lashing", 15) %>%
    add_resource("control", 1) %>%
    add_resource("frontdesk end", 2) %>%
    add_generator(name = "truck" , 
                  trajectory = truck,
                  distribution = function() rnorm(1,24.992,36.015)) %>%
    run(660) %>%
    wrap()
})

【问题讨论】:

    标签: r simulation


    【解决方案1】:

    如错误所示,超时活动需要一个值,在这种情况下您提供的是 11。正因为如此:

    timeout(function() rnorm(11.27671,3.233562))
    

    rnorm 的第一个参数是样本数(在本例中四舍五入为 11)。你想在这里做什么?如果应该是mean=11.27sd=3.23,那么你需要添加

    timeout(function() rnorm(1, 11.27671,3.233562))
    

    这样您就可以根据需要在每次调用时获得一个样本。这同样适用于所有其他超时。

    编辑:另外,我不建议对服务时间使用正态分布,因为正态分布可能会返回负值(默认情况下强制为正),因此您可能会得到意想不到的结果。

    【讨论】:

      猜你喜欢
      • 2020-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-03
      • 2021-11-21
      • 1970-01-01
      • 2022-01-24
      • 1970-01-01
      相关资源
      最近更新 更多