Learn R Programming

simmer (version 4.2.2)

add_resource: Add a Resource

Description

Define a new resource in a simulation environment.

Usage

add_resource(.env, name, capacity = 1, queue_size = Inf, mon = TRUE,
  preemptive = FALSE, preempt_order = c("fifo", "lifo"),
  queue_size_strict = FALSE)

Arguments

.env

the simulation environment.

name

the name of the resource.

capacity

the capacity of the server, either a numeric or a schedule, so that the value may change during the simulation.

queue_size

the size of the queue, either a numeric or a schedule, so that the value may change during the simulation.

mon

whether the simulator must monitor this resource or not.

preemptive

whether arrivals in the server can be preempted or not based on seize priorities.

preempt_order

if the resource is preemptive and preemption occurs with more than one arrival in the server, this parameter defines which arrival should be preempted first. It must be fifo (First In First Out: older preemptible tasks are preempted first) or lifo (Last In First Out: newer preemptible tasks are preempted first).

queue_size_strict

if the resource is preemptive and preemption occurs, this parameter controls whether the queue_size is a hard limit. By default, preempted arrivals go to a dedicated queue, so that queue_size may be exceeded. If this option is TRUE, preempted arrivals go to the standard queue, and the maximum queue_size is guaranteed (rejection may occur). Whenever an arrival is rejected (due to a server drop or a queue drop), it will set the finished flag to FALSE in the output of get_mon_arrivals. Unfinished arrivals can be handled with a drop-out trajectory that can be set using the handle_unfinished activity.

Value

Returns the simulation environment.

See Also

Convenience functions: schedule.