branch {simmer} | R Documentation |
Activity for defining a fork with N
alternative sub-trajectories.
branch(.trj, option, continue, ...)
.trj |
the trajectory object. |
option |
a callable object (a function) which must return an integer between
|
continue |
a vector of |
... |
|
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