The SelectOutput5 block routes the incoming agents to one of the five output ports, depending on either probabilistic or deterministic conditions.
The block has three modes:
-
Conditions — Provide 4 conditions. When an agent arrives, the conditions are evaluated sequentially, one by one. If condition 1 is true, the agent exits through the exit 1, otherwise condition 2 is evaluated, and so on.
If all conditions are false, the agent exits through the last (default exit). The condition may depend on the agent as well as on any external factors. - Probabilities — Specify 5 probabilities for 5 exits. If their sum is not 1, they are normalized. The exit the agent takes is randomly defined according to the specified probabilities.
-
Exit number — Specify an expression that returns integer numbers in the range [1..5]. When the agent enters the block, the expression is evaluated. The resulting number is the number of the output port the agent should take to leave that block.
The expression may depend on the agent as well as on any external factors.
Agents spend zero time in SelectOutput5.
This block can be used to sort agents by some criteria, to randomly split the agent flow, and so on.
Sometimes it is necessary to have more than 5 outputs. Using SelectOutputIn and SelectOutputOut blocks, you can create a large quasi-block SelectOutput with the required number of exits.
The output port that the agent will take in the SelectOutput5 block is determined when the agent completes its operation in the preceding flowchart block, not when the agent enters the SelectOutput5 block. This is necessary because agents do not spend any time in SelectOutput5 and are immediately forwarded to the next one. Therefore, we need to determine in advance whether the next block can accept the agent.
For example, the next block could be a closed Hold block or a full Queue. The availability of the output route and the output selection are calculated before the agent exits the current block.
By default, the expression that defines the routing condition or an exit number of such a block is evaluated at this earlier point, before the On exit action of the preceding block is executed. As a result, any logic you place in that On exit action (such as changing a custom agent attribute used in the routing condition) will not affect the routing outcome.
To ensure your routing logic works correctly:
- Move any logic that affects routing from the On exit action to the On at exit action, if the block provides one. This action is executed after the block finishes its operation, but before the routing decision is made.
- If this is not possible, insert a Delay block with zero Delay time before the SelectOutput5 block to separate the change and the routing decision into two steps.
-
Alternatively, if your routing logic relies on stochastic or volatile expressions, such as calls of the randomTrue() function or expressions dependent on the current state of other blocks or changes in the agent properties, enable the Condition is stochastic or volatile option in the properties of SelectOutput5. By default, this option is disabled: the routing expressions can be evaluated twice, when the agent finishes the operation in the preceding block and when the agent actually leaves the preceding block. If the value of the expression changes between the two evaluations, AnyLogic raises an error, indicating that the agent can no longer follow the initially selected route.
Enabling the Condition is stochastic or volatile option disables this check, and the agent will follow the route selected during the first evaluation, even if the result of the expression has changed by the time the agent proceeds.
- Use
-
Specifies whether to route agents according to specified Conditions, randomly according to specified Probabilities, or to evaluate the specified expression to get the number of the exit port the agent should take to exit the block.
Get value: type
Valid values:
SelectOutput5.TYPE_PROBABILITIES
SelectOutput5.TYPE_CONDITIONS
SelectOutput5.TYPE_EXIT_NUMBERS - [Visible when Use: Probabilities]
The expression used to evaluate the probability that the current agent will exit via out1 .. out5 ports. The probability value should be in the [0..1] range.Value type: double
Local variable: agent — the agent.
Default value: 0.2 — does not depend on the agent and simply splits the agent flow into five equal parts - [Visible when Use: Conditions]
The condition evaluated for an incoming agent. If Condition N evaluates to true, the agent exits through the outN port, otherwise the next condition (Condition N+1) is checked. If all conditions are false, the agent exits through the last (default) exit. The condition may depend on the agent as well as on any external factors.Value type: boolean
Local variable: agent — the agent - [Visible when Use: Exit number]
The expression used to evaluate the index of the output port that the agent should take to leave this block. The expression may depend on the agent as well as on any external factors. The result should lie be in the [1..5] range.Value type: int
Local variable: agent — the agent.
Default value: uniform_discr( 1, 5 ) — does not depend on the agent and simply splits the agent flow into five equal parts - Condition is stochastic or volatile
-
[Visible when Use: Conditions or Exit number]
Specifies that the condition or exit number value may yield different results when evaluated at different times for the same agent. For example, this may occur if the condition uses random functions or depends on the state of other flowchart blocks.
The expression is checked twice by default: first, when the agent is ready to exit the preceding block and, if the next block was busy and could not accept the agent immediately, possibly again later. A built-in check compares the two evaluations and raises an error if the result has changed.
Enable this option to suppress the check and avoid errors in models where such variability is expected. The final routing decision will be based on the most recent evaluation when the agent leaves the block.Value type: boolean
Default value: false — the expression is assumed to be static between evaluations
- On enter
- Code executed when the agent enters the block.
Local variable: agent — the agent
- On exit 1, 2, .. , 5
- Code executed when the agent exits the block through the out1, out2, … port.
Local variable: agent — the agent
- in
- The input port.
- out1, out2, out3, out4, out5
- The output ports.
-
How can we improve this article?
-