Learn R Programming

simmer (version 3.1.1)

from: Generate arrivals starting at a specified time

Description

Generator convenience function to generate inter arrivals with a specified initial start time.

Usage

from(start_time, dist, arrive = TRUE)

Arguments

start_time

the time at which to launch the initial arrival

dist

a function modelling the interarrival times (returning a negative value stops the generator).

arrive

if set to TRUE (default) the first arrival will be generated at start_time and will follow dist from then on. If set to FALSE, will initiate dist at start_time (and the first arrival will most likely start at a time later than start_time).

Value

Returns a generator function.

See Also

add_generator

Examples

Run this code
# NOT RUN {
t0 <- create_trajectory("my trajectory") %>%
  ## add an intake activity
  seize("nurse", 1) %>%
  timeout(function() rnorm(1, 15)) %>%
  release("nurse", 1) %>%
  ## add a consultation activity
  seize("doctor", 1) %>%
  timeout(function() rnorm(1, 20)) %>%
  release("doctor", 1) %>%
  ## add a planning activity
  seize("administration", 1) %>%
  timeout(function() rnorm(1, 5)) %>%
  release("administration", 1)
  
env <- simmer("SuperDuperSim") %>%
  add_resource("nurse", 1) %>%
  add_resource("doctor", 2) %>%
  add_resource("administration", 1) %>%
  add_generator("patient", t0, from(5, function() rnorm(1, 10)))
# }

Run the code above in your browser using DataLab