AnyLogic
Expand
Font size

PedSelectOutput

Routes the incoming pedestrians to one of several (up to five) processes depending on specified ratios or conditions. Each process has to be defined with a flowchart connected to one of the block’s output ports.

The block works in three modes: Probabilities, Conditions, or Exit number.

  • In the Probabilities mode, you provide 5 probabilities for five exits (if their sum does not equal 1, they are normalized). The exit the pedestrian takes is defined randomly according to the specified probabilities. For example, if, Probability 1 is 5, Probability 2 is 1, and Probability 3 is 4, pedestrians will use the out1, out2, and out3 ports with average probabilities of 0.5, 0.1, and 0.4.
  • In the Conditions mode, you provide 4 conditions. When a pedestrian arrives, the conditions are evaluated sequentially one by one. If condition 1 is true, the pedestrian leaves the block through the out1 port, otherwise, condition 2 is evaluated, and so on. If all conditions are false, the pedestrian exits via the out5 port — the default exit. The result of the condition’s evaluation may depend on the properties and attributes of the pedestrian — as well as on other external factors.
  • In the Exit number mode, you provide an expression that returns integer numbers in the [1..5] range. When the pedestrian enters the block, the expression is evaluated, and the resulting number determines the number of the output port the pedestrian should use to leave this block. The result of the condition’s evaluation may depend on the properties and attributes of the pedestrian — as well as on other external factors.
In the Probabilities and Conditions modes, it is not necessary to define all five chance ratios or all four conditions. If you want to route pedestrians to only one of two ports, you will only need to define two corresponding parameters.

Use this block to sort pedestrians according to certain criteria, randomly split the pedestrian flow, and so on.

Pedestrians spend zero time in the PedSelectOutput block.

The decision which output port of the PedSelectOutput block the pedestrian will choose is made not when the pedestrian enters the PedSelectOutput block, but earlier, when the pedestrian completes its operation in the preceding flowchart block. It is implemented this way because pedestrians do not spend any time in the PedSelectOutput 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 pedestrian (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 pedestrian exit the current block and enter the PedSelectOutput block.

The routing condition of the PedSelectOutput block is calculated when the pedestrian 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 pedestrian routing logic in the On exit action of the flowchart block preceding the PedSelectOutput block, it will not happen. For example, if you assign a new value to a custom pedestrian attribute in the On exit action, and then use this attribute as the routing condition in the following PedSelectOutput block, it will not work and pedestrians 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 PedSelectOutput block.

Parameters

Use
Defines whether pedestrians will be routed randomly according to specified Probabilities, depending on the specified Conditions, or the specified expression will be evaluated to get the number of the output port the pedestrian will use to leave the block.
Syntax: PedSelectOutput.Type useConditions
Get value: type
Set new value dynamically:set_type(new value)
Valid values:
PedSelectOutput.TYPE_PROBABILITIES — for the Probabilities mode
PedSelectOutput.TYPE_CONDITIONS — for the Conditions mode
PedSelectOutput.TYPE_EXIT_NUMBERS — for the Exit number mode
Probability 1, 2, … 5
[Visible if Use: Probabilities]
Ratio of pedestrian flow that exits the block via the port out1, out2, ….
Value type: double
Local variable: ped — the pedestrian
Condition 1, 2, … 5
[Visible if Use: Conditions]
Condition that checks whether the pedestrian should leave this block via the out1, out2, ... port. If Condition 1 is true, the pedestrian leaves the block via out1, if not, Condition 2 is checked. If Condition 2 is true, the pedestrian leaves the block via out2, if not, the next condition is checked, and so on. If no conditions are met, the pedestrian leaves the block via the last out5 port.
Value type: boolean
Local variable: ped — the pedestrian
Exit number [1 .. 5]
[Visible if Use: Exit number]
Expression evaluating 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 in the [1..5] range.
Value type: int
Local variable: ped — the pedestrian
Default value: uniform_discr( 1, 5 ) — does not depend on the pedestrian; simply splits the pedestrian flow into five equal parts.

Actions

On enter
Code executed when the pedestrian enters the block.
Local variable: ped — the pedestrian
On exit 1, 2, …
Code executed when the pedestrian exits the block via port out1, out2, ….
Local variable: ped — the pedestrian

Ports

in

The input port.

out1, out2, out3, out4, out5

Output ports.

How can we improve this article?