View source: R/simmer-methods.R
add_resource | R Documentation |
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 seize
);
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))
.env |
the simulation environment. |
name |
the name of the resource. If several names are provided, several resources will be defined with the same parameters. |
capacity |
the capacity of the server, either an integer or a
|
queue_size |
the size of the queue, either an integer or a
|
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 |
queue_size_strict |
whether the |
queue_priority |
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. |
An entity trying to seize a resource (see seize
) may
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.
However, with queue_size_strict=TRUE
, the maximum queue_size
is
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 handle_unfinished
activity.
Returns the simulation environment.
Convenience functions: schedule
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.