AnyLogic
Expand
Font size

Hold

Can block the agent flow along a particular connection. Is used, for example, when the succeeding flowchart block can accept agents, but you (temporarily) do not want the agents to proceed there, or when you wish to block an output of a particular flowchart block that merges with outputs of other blocks.

The state of the block is controlled programmatically by calling setBlocked() function.

Hold does not hold agents inside (even for zero time), and can be treated as an extension to an input or an output port (or ports).

Parameters

Mode
Here you can choose the block/unblock mode for this Hold block. There are three modes supported:
Manual (use block(), unblock() methods) — the block will be blocked upon calling its block() function, and unblocked on unblock() call.
Block automatically after N agents (use unblock() method) — the block will be blocked automatically right after the specified number of agents arrives at its input port. The block will be unblocked by the call of the block’s function unblock().
Conditional (custom decision for each agent) — the block will make the decision whether to block the input, or not, depending on the result of the Blocking condition being evaluated for each incoming agent.
Get value: mode
Valid values:
Hold.MANUAL
Hold.BLOCK_AFTER_N_ENTITIES
Hold.CONDITIONAL
N agents for self-block
[Visible if Mode: Block automatically after N agents]
The number of agents that should arrive in the block’s input port to block the Hold.
Syntax: int nEntitiesForSelfBlock
Blocking condition
[Visible if Mode: Conditional (custom decision for each agent)]
Here you can specify the condition that will be re-evaluated for each agent. If the condition evaluates to true, this Hold block is blocked. You can change the condition dynamically, in this case you have to call the block’s function recalculateConditions() that tells the Hold block to recalculate blocking conditions for all agents which are currently held by this block.
Type: dynamic
Value type: boolean
Local variable: agent — the agent
Initially blocked
If the option is selected (true), the block is initially put into blocked state.
Syntax: boolean initiallyBlocked
Default value: false

Actions

On enter
Code executed when the agent enters the block.
Type: code
Local variable: agent — the agent

Functions

Function Description
void setBlocked(boolean blocked) Blocks the input port if true is passed as the argument, and unblocks it otherwise.
boolean isBlocked() Returns true if the input is blocked, otherwise false.
void block() Blocks the input port. Does nothing if port is already blocked.
void unblock() Unblocks the input port. Does nothing if port isn’t blocked.
boolean toggleBlock() Changes “blocked” state and returns the new state (blocked = true).
void recalculateConditions() Use this function to tell the Hold block to recalculate blocking conditions for all agents which are currently held by this block.

Ports

in
The input port.
out
The output port.
How can we improve this article?