The SelectOutput block routes the incoming agents to one of the two output ports depending on a condition — probabilistic or deterministic. The condition may depend on the agent as well as on any external factors. Agents spend zero time in SelectOutput.
The block can be used to sort agents according to some criteria, to split the agent flow randomly, and so on.
For example, consider agents of type Customer, which has a Boolean field vip. If you want VIP customers to exit the block through the top port (true) and all others through the bottom port (false), specify the condition agent.vip and set Customer as a generic parameter of SelectOutput.
In a more sophisticated case, you might want that only 80% of VIP customers to exit through the top port, and the remaining 20% of VIPs and all other customers to exit through the bottom port. To reflect this, the condition will look like this: agent.vip && randomTrue( 0.8 ).
Sometimes it is necessary to have more than two outputs. AnyLogic provides two blocks for routing agents to different flowchart branches: SelectOutput and SelectOutput5. SelectOutput5 has five output ports, so it can route agents to up to five exits. Using SelectOutputIn and SelectOutputOut blocks you can create a large SelectOutput quasi-block with the required number of exits.
- Select True output
-
Specifies whether agents are routed according to the specified boolean condition (If condition is true) or randomly (With specified probability [0..1]).
Syntax: boolean conditionIsProbabilistic
-
[Visible when Select True output: With specified probability]
The expression used to evaluate the probability that the current agent will leave the top port. The probability value should be 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 -
[Visible when Select True output: If condition is true]
The condition evaluated for an incoming agent. If it evaluates to true, the agent through the top port, otherwise — through the bottom 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
- 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 through the upper outT port.
Local variable: agent — the agent
- On exit (false)
- Code executed when the agent exits the block through the lower outF port.
Local variable: agent — the agent
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. |
- in
- The input port.
- outT
- The top output port (for the agents, for which the Select condition returned true).
- outF
- The bottom output port (for the agents, for which the Select condition returned false).
-
How can we improve this article?
-