renege | R Documentation |
Activities for leaving with some probability, or for setting or unsetting a timer or a signal after which the arrival will abandon.
leave(.trj, prob, out = NULL, keep_seized = TRUE, ..., tag)
renege_in(.trj, t, out = NULL, keep_seized = FALSE, ..., tag)
renege_if(.trj, signal, out = NULL, keep_seized = FALSE, ..., tag)
renege_abort(.trj, ..., tag)
.trj |
the trajectory object. |
prob |
a probability or a function returning a probability. |
out |
optional sub-trajectory in case of reneging. |
keep_seized |
whether to keep already seized resources. By default, all resources are released. |
... |
unused. |
tag |
activity tag name to perform named rollbacks (see
|
t |
timeout to trigger reneging, accepts either a numeric or a callable object (a function) which must return a numeric. |
signal |
signal to trigger reneging, accepts either a string or a callable object (a function) which must return a string. |
Arrivals that leave the trajectory will set the finished
flag
to FALSE
in the output of get_mon_arrivals
. Unfinished
arrivals can be handled with a drop-out trajectory that can be set using the
optional argument out
or the handle_unfinished
activity.
Note that, for historical reasons, leave
has keep_seized=TRUE
by default, while renege_*
does not.
Note that renege_if
works similarly to trap
,
but in contrast to that, reneging is triggered even if the arrival is waiting
in a queue or is part of a non-permanent batch
.
Returns the trajectory object.
handle_unfinished
send
## leave with some probability
set.seed(1234)
traj <- trajectory() %>%
log_("leave with some probability") %>%
leave(function() runif(1) < 0.5) %>%
log_("didn't leave")
simmer() %>%
add_generator("dummy", traj, at(0, 1)) %>%
run() %>% invisible
## reneging after some time
bank <- trajectory() %>%
log_("here I am") %>%
# renege in 5 minutes
renege_in(
5,
out = trajectory() %>%
log_("lost my patience. Reneging...")) %>%
seize("clerk") %>%
# stay if I'm being attended within 5 minutes
renege_abort() %>%
log_("I'm being attended") %>%
timeout(10) %>%
release("clerk") %>%
log_("finished")
simmer() %>%
add_resource("clerk", 1) %>%
add_generator("customer", bank, at(0, 1)) %>%
run() %>% invisible
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.