This method initialises a trajectory object, which comprises a chain of activities that can be attached to a generator.

trajectory(name = "anonymous", verbose = FALSE)

create_trajectory(name = "anonymous", verbose = FALSE)

Arguments

name

the name of the trajectory.

verbose

enable showing additional information.

Value

Returns an environment that represents the trajectory.

See also

Methods for dealing with trajectories: [.trajectory, [[.trajectory, length.trajectory, get_n_activities, join, seize, release, seize_selected, release_selected, select, set_capacity, set_queue_size, set_capacity_selected, set_queue_size_selected, set_prioritization, activate, deactivate, set_trajectory, set_distribution, set_attribute, timeout, branch, rollback, leave, renege_in, renege_if, renege_abort, clone, synchronize, batch, separate, send, trap, untrap, wait, log_.

Examples

t0 <- 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
#> trajectory: my trajectory, 9 activities #> { Activity: Seize | resource: nurse, amount: 1 } #> { Activity: Timeout | delay: 0x8977510 } #> { Activity: Release | resource: nurse, amount: 1 } #> { Activity: Seize | resource: doctor, amount: 1 } #> { Activity: Timeout | delay: 0x87d0a38 } #> { Activity: Release | resource: doctor, amount: 1 } #> { Activity: Seize | resource: administration, amount: 1 } #> { Activity: Timeout | delay: 0x65b6a70 } #> { Activity: Release | resource: administration, amount: 1 }
t1 <- trajectory("trajectory with a branch") %>% seize("server", 1) %>% # 50-50 chance for each branch branch(function() sample(1:2, 1), continue=c(TRUE, FALSE), trajectory("branch1") %>% timeout(function() 1), trajectory("branch2") %>% timeout(function() rexp(1, 3)) %>% release("server", 1) ) %>% # only the first branch continues here release("server", 1) %>% timeout(function() 2) t1
#> trajectory: trajectory with a branch, 7 activities #> { Activity: Seize | resource: server, amount: 1 } #> { Activity: Branch | option: 0x706d490 } #> Fork 1, continue, trajectory: branch1, 1 activities #> { Activity: Timeout | delay: 0x68e1a50 } #> Fork 2, stop, trajectory: branch2, 2 activities #> { Activity: Timeout | delay: 0x7472358 } #> { Activity: Release | resource: server, amount: 1 } #> { Activity: Release | resource: server, amount: 1 } #> { Activity: Timeout | delay: 0x705af60 }