AnyLogic 9
Expand
Font size

Wait

AnyLogic: The Wait block

The Wait block can store agents inside and supports their manual release (you need to call free() or freeAll()). It has no order (except in the case of preemption, if the latter is enabled).

Parameters

Capacity
[Visible if Maximum capacity is not chosen]
The capacity of the queue.
Syntax: int capacity
Set new value dynamically: set_capacity(new value)
Default value: 100
Maximum capacity
If the option is selected (true), the capacity of the queue is maximum possible (limited by Integer.MAX_VALUE).
Syntax: boolean maximumCapacity
Set new value dynamically: set_maximumCapacity(new value)
Default value: false
Agent location
Space markup shape (node or path) where the agents are located while being in this block.
Syntax: AnimationStaticLocationProvider entityLocation

Advanced

Enable exit on timeout
If the option is selected (true), the timeout option for the queue is on. After spending the specified time in the queue, the agent will leave the block through the outTimeout port.
Syntax: boolean enableTimeout
Default value: false
Timeout
[Visible if Enable exit on timeout option is enabled]
Expression evaluated to obtain the timeout time for the agent.
Value type: double
Local variable: agent — the agent
Default value: 100 seconds
Enable preemption
If the option is selected (true), the agents are placed in the queue according to their priorities and may be preempted by higher priority ones.
Syntax: boolean enablePreemption
Default value: false
Preempt
[Visible if Enable preemption is selected]
Defines how the incoming agents preempt the agents that are already in the queue. The choice defines the agent to be preempted:
The most recent agent — The default policy. The last stored agent will be preempted.
Agent with the least priority value — The agents will be preempted according to their priorities (defined in the Agent priority field below).
By comparison — In this mode, the Boolean expression, defined in the "agent1 may preempt agent2" field, is evaluated for every incoming agent. It compares this agent with the agents that are already stored in the block and determines the agent that will be preempted.
The oldest agent — The first stored agent will be preempted.
Syntax: Queue.QueuingMode queuing
Valid values:
Queue.QUEUING_FIFO — The most recent agent
Queue.QUEUING_PRIORITY — Agent with the least priority value
Queue.QUEUING_COMPARISON — By comparison
Queue.QUEUING_LIFO — The oldest agent
Agent priority
[Visible if Preempt: Agent with the least priority value]
The priority of the incoming agent (the larger the higher).
Value type: double
Default value: 0
Local variable: agent — the agent
"agent1 may preempt agent2"
[Visible if Preempt: By comparison]
The comparison callback which should return true if 'agent1' has higher priority than 'agent2' (and false otherwise, including the case of equal priorities).
Value type: boolean
Default value: false
Local variables: agent1, agent2 — the agents
Forced pushing
If the option is selected (true), when agents finish processing at the block, they are instantly pushed further regardless the state of the succeeding block. If the option is not selected, agents are not pushed, but pulled: only when the succeeding block is ready to accept one more agent, it requests the agent from this block, and only then this agent passes further.
Syntax: boolean pushProtocol
Default value: false
Restore agent location on exit
If the option is selected, after being animated in the Agent location shape, the agents will return to their original location (node or path) where they were before entering this block.
Syntax: boolean restoreEntityLocationOnExit
Default value: true
Force statistics collection
This block collects the statistics on the queue size. If the statistics collection is turned off for all Process Modeling Library blocks in the model by the PMLSettings block, this option enables you to override this setting and collect the statistics for this specific block. Otherwise, the statistics will be collected regardless this setting.
Syntax: boolean forceStatisticsCollection
Default value: false

Actions

On enter
Code executed when the agent enters the block (and has been placed in the queue).
Local variable: agent — the agent
On exit
Code executed when the agent exits the block via out port (in the normal way).
Local variable: agent — the agent
On exit (preempted)
[Visible if Enable preemption option is enabled] Code executed when the agent exits via outPreempted port as a result of preemption.
Local variable: agent — the agent
On exit (timeout)
[Visible if Enable exit on timeout option is enabled] Code executed when the agent exits via outTimeout port as a result of waiting too long.
Local variable: agent — the agent
On remove
Code executed when the agent is intentionally removed from this block by calling the agent’s function remove(). This code is automatically executed after the remove() function call.
Local variable: agent — the agent

Statistics

StatisticsContinuous statsSize
Continuous statistics on the queue size. Is collected if the statistics collection is not turned off by PML Settings block.

Functions

Agents
Function Description
int size() Returns the number of agents in the queue.
Agent get(int index) Returns the agent at position index (0 is at the exit).
Agent remove(Agent agent) Removes the given agent from the queue and returns it. If the agent is not contained in the queue, returns null.
boolean free(Agent agent) Tells the queue to release the given agent and forward it to the out port.
boolean freeAll() Tells the queue to release all the agents and forward it to the out port.
Iterator<Agent> iterator() Returns the agent at position index (0 is at the exit).
Statistics
Function Description
boolean isStatisticsCollected() Returns true if the block collects statistics.
resetStats() Resets the statistics collected for this block.

Ports

in
The input port.
out
The output port.
outTimeout
The output port for agents leaving the block because of timeout.
outPreempted
The output port for agents leaving the block because of preemption.
How can we improve this article?