Define a new resource in a simulation environment. Resources are conceived
with queuing systems in mind, and therefore they comprise two internal
self-managed parts: a server, which is the active part, with a
specified capacity that can be seized and released (see
and a priority queue of a certain size, in which arrivals may wait for
the server to be available.
add_resource(.env, name, capacity = 1, queue_size = Inf, mon = TRUE, preemptive = FALSE, preempt_order = c("fifo", "lifo"), queue_size_strict = FALSE, queue_priority = c(0, Inf))
the simulation environment.
the name of the resource. If several names are provided, several resources will be defined with the same parameters.
the capacity of the server, either an integer or a
the size of the queue, either an integer or a
whether the simulator must monitor this resource or not.
whether arrivals in the server can be preempted or not based on seize priorities.
the priority range required to be able to access the queue if there is no room in the server (if a single value is provided, it is treated as the minimum priority). By default, all arrivals can be enqueued.
Returns the simulation environment.
An entity trying to seize a resource (see
1) access the server straightaway if there is enough capacity, 2) wait in the
queue if there is no room in the server but there is room in the queue, or 3)
rejected if there is no room in the queue either.
There are two special situations regarding queue management: 1) the
queue_size is shrinked below the actual number of items waiting, and
2) preemption occurs, and an item previously in the server goes to the queue.
By default in both cases, the excess of items in the queue is allowed.
queue_size_strict=TRUE, the maximum
guaranteed, and thus some entities will be rejected (dropped) by the resource.
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