View source: R/trajectory-activities.R
branch | R Documentation |
Activity for defining a fork with N
alternative sub-trajectories.
branch(.trj, option, continue, ..., tag)
.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
|
Returns the trajectory object.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.