Skip to contents

Activities for dynamically modifying a resource's server capacity or queue size, by name or a previously selected one. Resources must be defined in the simulation environment (see add_resource).

Usage

set_capacity(.trj, resource, value, mod = c(NA, "+", "*"), ..., tag)

set_capacity_selected(.trj, value, id = 0, mod = c(NA, "+", "*"), ..., tag)

set_queue_size(.trj, resource, value, mod = c(NA, "+", "*"), ..., tag)

set_queue_size_selected(.trj, value, id = 0, mod = c(NA, "+", "*"), ...,
  tag)

Arguments

.trj

the trajectory object.

resource

the name of the resource.

value

numeric value to set, or a callable object (a function) which must return a numeric value.

mod

if set, values modify the attributes rather than substituting them.

...

unused.

tag

activity tag name to perform named rollbacks (see rollback) or just to better identify your activities.

id

selection identifier for nested usage.

Value

Returns the trajectory object.

Examples

## a resource with a queue size equal to the number of arrivals waiting
traj <- trajectory() %>%
  set_queue_size("res", 1, mod="+") %>%
  seize("res") %>%
  set_queue_size("res", -1, mod="+") %>%
  timeout(10) %>%
  release("res")

simmer() %>%
  add_resource("res", 1, 0) %>%
  add_generator("dummy", traj, at(0:2)) %>%
  run() %>%
  get_mon_resources()
#>    resource time server queue capacity queue_size system limit replication
#> 1       res    0      0     0        1          1      0     2           1
#> 2       res    0      1     0        1          1      1     2           1
#> 3       res    0      1     0        1          0      1     1           1
#> 4       res    1      1     0        1          1      1     2           1
#> 5       res    1      1     1        1          1      2     2           1
#> 6       res    2      1     1        1          2      2     3           1
#> 7       res    2      1     2        1          2      3     3           1
#> 8       res   10      1     1        1          2      2     3           1
#> 9       res   10      1     1        1          1      2     2           1
#> 10      res   20      1     0        1          1      1     2           1
#> 11      res   20      1     0        1          0      1     1           1
#> 12      res   30      0     0        1          0      0     1           1