at: Convenience Functions for Generators

Description Usage Arguments Details Value See Also Examples

View source: R/generators.R

Description

These convenience functions facilitate the definition of generators of arrivals for some common cases.

Usage

1
2
3
4
5
6
7
at(...)

from(start_time, dist, arrive = TRUE)

to(stop_time, dist)

from_to(start_time, stop_time, dist, arrive = TRUE, every = NULL)

Arguments

...

a vector or multiple parameters of times at which to initiate an arrival.

start_time

the time at which to launch the initial arrival.

dist

a function modelling the interarrival times.

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).

stop_time

the time at which to stop the generator.

every

repeat with this time cycle.

Details

at generates arrivals at specific absolute times. from generates inter-arrivals following a given distribution with a specified start time. to generates inter-arrivals following a given distribution with a specified stop time. from_to is the union of the last two.

Value

Returns a generator function.

See Also

add_generator.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
t0 <- trajectory() %>%
  timeout(0)

simmer() %>%
  add_generator("dummy", t0, at(0, c(1,10,30), 40, 43)) %>%
  run(100) %>%
  get_mon_arrivals()
t0 <- trajectory() %>%
  timeout(0)

simmer() %>%
  add_generator("dummy", t0, from(5, function() runif(1, 1, 2))) %>%
  run(10) %>%
  get_mon_arrivals()
t0 <- trajectory() %>%
  timeout(0)

simmer() %>%
  add_generator("dummy", t0, to(5, function() runif(1, 1, 2))) %>%
  run(10) %>%
  get_mon_arrivals()
t0 <- trajectory() %>%
  timeout(0)

# from 8 to 16 h every 24 h:
simmer() %>%
  add_generator("dummy", t0, from_to(8, 16, function() runif(1, 1, 2), every=24)) %>%
  run(48) %>%
  get_mon_arrivals()

simmer documentation built on Nov. 17, 2017, 5:37 a.m.