
This function initialises a trajectory, which is a chain of activities followed by arrivals of the same type.
create_trajectory(name = "anonymous", verbose = FALSE)
the name of the trajectory.
enable showing additional information.
Returns an environment that represents the trajectory.
Other methods for dealing with trajectories: get_head, get_tail, get_n_activities, join, seize, release, set_attribute, timeout, branch, rollback, leave, seize_selected, release_selected, select.
# NOT RUN {
t0 <- create_trajectory("my trajectory") %>%
## add an intake activity
seize("nurse", 1) %>%
timeout(function() rnorm(1, 15)) %>%
release("nurse", 1) %>%
## add a consultation activity
seize("doctor", 1) %>%
timeout(function() rnorm(1, 20)) %>%
release("doctor", 1) %>%
## add a planning activity
seize("administration", 1) %>%
timeout(function() rnorm(1, 5)) %>%
release("administration", 1)
t0
t1 <- create_trajectory("trajectory with a branch") %>%
seize("server", 1) %>%
## 50-50 chance for each branch
branch(function() sample(1:2, 1), continue=c(TRUE, FALSE),
create_trajectory("branch1") %>%
timeout(function() 1),
create_trajectory("branch2") %>%
timeout(function() rexp(1, 3)) %>%
release("server", 1)
) %>%
## only the first branch continues here
release("server", 1) %>%
timeout(function() 2)
t1
# }
Run the code above in your browser using DataLab