branch {simmer} | R Documentation |
Fork the Trajectory Path
Description
Activity for defining a fork with N
alternative sub-trajectories.
Usage
branch(.trj, option, continue, ..., tag)
Arguments
.trj |
the trajectory object. |
option |
a callable object (a function) which must return an integer between
|
continue |
a vector of |
... |
|
tag |
activity tag name to perform named rollbacks (see
|
Value
Returns the trajectory object.
Examples
env <- simmer()
traj <- trajectory() %>%
set_global("path", 1, mod="+", init=-1) %>%
log_(function() paste("Path", get_global(env, "path"), "selected")) %>%
branch(
function() get_global(env, "path"), continue=c(TRUE, FALSE),
trajectory() %>%
log_("following path 1"),
trajectory() %>%
log_("following path 2")) %>%
log_("continuing after the branch (path 0)")
env %>%
add_generator("dummy", traj, at(0:2)) %>%
run() %>% invisible