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

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.

Value

Returns a generator function.

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.

See also

add_generator.

Examples

t0 <- trajectory() %>% timeout(0) simmer() %>% add_generator("dummy", t0, at(0, c(1,10,30), 40, 43)) %>% run(100) %>% get_mon_arrivals()
#> name start_time end_time activity_time finished replication #> 1 dummy0 0 0 0 TRUE 1 #> 2 dummy1 1 1 0 TRUE 1 #> 3 dummy2 10 10 0 TRUE 1 #> 4 dummy3 30 30 0 TRUE 1 #> 5 dummy4 40 40 0 TRUE 1 #> 6 dummy5 43 43 0 TRUE 1
t0 <- trajectory() %>% timeout(0) simmer() %>% add_generator("dummy", t0, from(5, function() runif(1, 1, 2))) %>% run(10) %>% get_mon_arrivals()
#> name start_time end_time activity_time finished replication #> 1 dummy0 5.000000 5.000000 0 TRUE 1 #> 2 dummy1 6.080750 6.080750 0 TRUE 1 #> 3 dummy2 7.915083 7.915083 0 TRUE 1 #> 4 dummy3 9.515844 9.515844 0 TRUE 1
t0 <- trajectory() %>% timeout(0) simmer() %>% add_generator("dummy", t0, to(5, function() runif(1, 1, 2))) %>% run(10) %>% get_mon_arrivals()
#> name start_time end_time activity_time finished replication #> 1 dummy0 1.007399 1.007399 0 TRUE 1 #> 2 dummy1 2.473793 2.473793 0 TRUE 1 #> 3 dummy2 3.971570 3.971570 0 TRUE 1
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()
#> name start_time end_time activity_time finished replication #> 1 dummy0 8.000000 8.000000 0 TRUE 1 #> 2 dummy1 9.732882 9.732882 0 TRUE 1 #> 3 dummy2 11.505403 11.505403 0 TRUE 1 #> 4 dummy3 13.380004 13.380004 0 TRUE 1 #> 5 dummy4 14.554945 14.554945 0 TRUE 1 #> 6 dummy5 15.589186 15.589186 0 TRUE 1 #> 7 dummy6 32.000000 32.000000 0 TRUE 1 #> 8 dummy7 33.402328 33.402328 0 TRUE 1 #> 9 dummy8 34.597998 34.597998 0 TRUE 1 #> 10 dummy9 36.001536 36.001536 0 TRUE 1 #> 11 dummy10 37.065198 37.065198 0 TRUE 1 #> 12 dummy11 38.453899 38.453899 0 TRUE 1