AnyLogic
Expand
Font size

SelectOutput

Routes the incoming agents to one of the two output ports depending on (probabilistic or deterministic) condition. The condition may depend on the agent as well as on any external factors. The agents spend zero time in SelectOutput.

May be used to sort agents according to a certain criteria, to randomly split the agent flow, etc. For example, suppose the agents are of type Customer that has a boolean field vip. Then if you wish VIP customers to exit via the upper (True) output and all others — via lower (False) port, you should specify the condition agent.vip and set Customer as a generic parameter of SelectOutput. A more sophisticated case: you wish only 80% of VIP customers to exit via upper port and 20% (and all others) — via lower port. Then the condition will look like agent.vip && randomTrue( 0.8 ).

Sometimes it is needed to have more than two outputs. We provide you with two blocks for routing agents to different flowchart branches: SelectOutput and SelectOutput5. SelectOutput5 has five output ports, so it may route agents to up to five exits. Using SelectOutputIn and SelectOutputOut blocks you can create one large quasi-block SelectOutput with the required number of exits.

Parameters

Select True output
Defines whether agents will be routed depending on the specified boolean condition (If condition is true) or randomly With specified probability [0..1].
Syntax: boolean conditionIsProbabilistic
Probability
[Visible when Select True output: With specified probability]
Expression used to evaluate the probability that the current agent will exit the upper port. The probability value should lie in the [0..1] range.
Value type: double
Local variable: agent — the agent
Default value: 0.5 — simply splits the agent flow into two equal parts
Condition
[Visible when Select True output: If condition is true]
Condition evaluated for an incoming agent. If it evaluates to true, the agent exits via the upper port, otherwise via the lower port.
Value type: boolean
Local variable: agent — the agent
Default value: randomTrue( 0.5 ) — does not depend on the agent and simply splits the agent flow into two equal parts

Actions

On enter
Code executed when the agent enters the block.
Local variable: agent — the agent
On exit (true)
Code executed when the agent exits the block via the upper outT port.
Local variable: agent — the agent
On exit (false)
Code executed when the agent exits the block via the lower outF port.
Local variable: agent — the agent

Functions

Function Description
int count() Returns the total number of agents passed through this block.
int countT() Returns the number of agents passed through the outT port of the block.
int countF() Returns the number of agents passed through the outF port of the block.

Ports

in
The input port.
outT
The upper output port (for the agents, for which the Select condition returned true).
outF
The lower output port (for the agents, for which the Select condition returned false).
How can we improve this article?