simmer (version 3.6.3)

trajectory: Create a Trajectory

Description

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

Usage

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

Run this code
# NOT RUN {
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

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
# }

Run the code above in your browser using DataCamp Workspace