如何在 r simmer 中定义排队模型的起始状态?
How to define starting state of queueing model in r simmer?
下面是标准银行柜台问题来说明我的问题:
Consider a simple bank with customers arriving at random. Customers
are to be served at one of two counters, taking a random time for
service at each. Also, assume that waiting customers form a single
FIFO queue.
这是并发症:
Suppose we are interested in modeling this system starting noon of a
particular day instead of at the start of the day. At noon, both
counters are occupied and there is already a queue of 4 customers.
有没有办法在 R simmer 中构建这种起始状态?
这是我已有的代码:
library(simmer)
set.seed(1234)
customer <-
trajectory("Customer's path") %>%
log_("Here I am") %>%
set_attribute("start_time", function() {now(bank)}) %>%
seize("counter") %>%
log_(function() {paste("Waited: ", now(bank) - get_attribute(bank, "start_time"))}) %>%
timeout(function() {rexp(1, 1/12)}) %>%
release("counter") %>%
log_(function() {paste("Finished: ", now(bank))})
bank <-
simmer("bank") %>%
add_resource("counter", 2) %>%
add_generator("Customer", customer, function() sample(1:15,1))
bank %>% run(until = 300)
您可以很容易地设置初始条件:只需添加另一个生成器以在 t=0 时放置 6 个到达。如果您需要进一步自定义他们的服务时间,请为此目的设置另一个轨迹。
下面是标准银行柜台问题来说明我的问题:
Consider a simple bank with customers arriving at random. Customers are to be served at one of two counters, taking a random time for service at each. Also, assume that waiting customers form a single FIFO queue.
这是并发症:
Suppose we are interested in modeling this system starting noon of a particular day instead of at the start of the day. At noon, both counters are occupied and there is already a queue of 4 customers.
有没有办法在 R simmer 中构建这种起始状态?
这是我已有的代码:
library(simmer)
set.seed(1234)
customer <-
trajectory("Customer's path") %>%
log_("Here I am") %>%
set_attribute("start_time", function() {now(bank)}) %>%
seize("counter") %>%
log_(function() {paste("Waited: ", now(bank) - get_attribute(bank, "start_time"))}) %>%
timeout(function() {rexp(1, 1/12)}) %>%
release("counter") %>%
log_(function() {paste("Finished: ", now(bank))})
bank <-
simmer("bank") %>%
add_resource("counter", 2) %>%
add_generator("Customer", customer, function() sample(1:15,1))
bank %>% run(until = 300)
您可以很容易地设置初始条件:只需添加另一个生成器以在 t=0 时放置 6 个到达。如果您需要进一步自定义他们的服务时间,请为此目的设置另一个轨迹。