We provide you with two blocks for routing agents to different flowchart branches: SelectOutput and SelectOutput5.
- SelectOutput has two output ports and can split the agent flow to two branches.
- SelectOutput5 has five output ports and it may route agents to up to five exits.
Using SelectOutputIn and SelectOutputOut blocks, you can create a quasi-block SelectOutput with the required number of exits. You create it by adding a SelectOutputIn block and the required number of SelectOutputOut blocks. These blocks should not be connected together graphically.
The decision which output port of the SelectOutputOut block the agent will choose is made not when the agent enters the SelectOutputOut block, but earlier, when the agent completes its operation in the preceding flowchart block. It is implemented this way because agents do not spend any time in the SelectOutputOut block and are instantly forwarded to the next flowchart block, so we need to make sure first that this block is able to accept the agent (e.g. it can be a closed Hold block or full Queue). That is why the availability of the further route within the flowchart is calculated in advance, before letting the agent exit the current block and enter the SelectOutputOut block.
The routing condition of the SelectOutputOut block is calculated when the agent completes the operation defined by the preceding flowchart block and is ready to exit this block, but before the On exit action of that block is executed. So if you want to affect the agent routing logic in the On exit action of the flowchart block preceding the SelectOutputOut block, it will not happen. For example, if you assign a new value to a custom agent attribute in the On exit action, and then use this attribute as the routing condition in the following SelectOutputOut block, it will not work and agents may be routed to the wrong output port (the routing condition will actually be checked before your change in the On exit action will apply).
To obtain the correct behavior:
- If the preceding flowchart block has On at exit action, move your logic from its On exit action there. The On at exit action is executed after the block’s operation is finished, but before the further routing decision is made. If this block does not have the On exit action, use its other action, for instance, On enter.
- If the above option is not suitable, place the Delay block with zero Delay time before your SelectOutputOut block.
To implement a custom routing to N flowchart branches
- Add a SelectOutputIn block from the Auxiliary section located at the bottom of the Process Modeling Library palette.
- Add the desired number of SelectOutputOut blocks.
- In each SelectOutputOut block, specify the name of the SelectOutputIn block that serves as the input.
-
Define the routing principle. There are two options:
- In the SelectOutputIn properties, select Select output: By explicit choice and specify the expression that returns the SelectOutputOut block in the property below.
- In the SelectOutputIn properties, select Select output: With probabilities in SelectOutputOut blocks, and specify probabilities for each SelectOutputOut block.
The following simple model shows how to implement both cases.
Demo model: SelectOutputN Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files). Demo model: SelectOutputNOpen the model in your AnyLogic desktop installation.- The type of agents exiting this block. This agent type is referred to below as T.
Default value: Agent
- SelectOutputIn block
- The block SelectOutputIn that composes a quasi multi-exit SelectOutput together with this and other SelectOutputOut blocks.
Syntax: SelectOutputIn selectOutputIn
- Applies when in the referred SelectOutputIn block Select output: With probabilities in SelectOuputOut blocks. Expression used to evaluate the probability that the current agent will exit via this SelectOutputOut block. The probability value should be in the [0..1] range.
Value type: double
Local variable: agent — the agent
- On exit (true)
- Code executed when the agent exits the block.
Local variable: agent — the agent
- out
- The output port.
-
How can we improve this article?
-