Pedestrian Groups

AnyLogic supports modeling groups of pedestrians. You can assemble pedestrian into groups, adjust the formation of the group and disassemble the group using the specific objects of Pedestrian Library.

Servicing groups of pedestrians

When passing through services with lines, a group of pedestrians may behave differently. 

The behaviors are:

You can choose one of three alternative behavior modes in the flowchart block that creates pedestrian groups (it can be PedSource, PedEnter, or PedGroupAssemble), and even change the group servicing settings in the properties of some specific service with lines (Grouping property section).

Demo model: Group Behavior in Services

Assembling groups

Groups can be assembled by  PedSource PedEnter and  PedGroupAssemble flowchart objects. 

PedSource generates pedestrians and also can be used to generate groups of pedestrians.

PedEnter accepts pedestrians generated somewhere (e.g. using Process Modeling Library Source object) at input port and injects pedestrians into the simulated environment at specified location. This object also can be used to organize groups from sequence of pedestrians on input port.

PedGroupAssemble organizes groups from sequence of pedestrians on input port. Also this object is used to reassemble groups which have been split by blocks which don't support groups (like PedService): pedestrians wait in the given area and leave it in their original group when the whole group arrives.

You can choose how you want groups to be created: 

Changing forms of groups

Groups may have one of predefined forms (swarm, front, chain) or a custom form. Custom form of the group can be defined with a polyline. Points of such a polyline mean desired locations of pedestrians in the group.

The form of the group is defined on group formation and can be changed later using the PedGroupChangeFormation object. This object causes group to change its form to a specified one when group leader passes this object.

Disassembling groups

Groups are disassembled by  PedGroupDisassemble flowchart object. When group leader enters this object, group dissolves, so pedestrians become independent from each other and follow their personal paths.

Demo model: Pedestrian Groups

Working with groups programmatically

Groups of pedestrians are instances of class Group. You can work with groups programmatically using the API of this class.

Pedestrians in the group can be iterated using loop like this one: 

for (Agent ped : group) { }

There is also a set of functions for working with group contents:

int size() - Returns number of pedestrians in this group.

disassemble() - Disassembles this group, removes all the pedestrians from this group making them independent. Group is destroyed.

add( Agent ped ) - Adds the given pedestrian (ped) to this group.

remove( Agent ped ) - Removes the given pedestrian (ped) from this group.

Agent get( int index ) - Returns a pedestrian with the given index in a group. Index is 0-based, leader has index 0.

Agent getLeader() - Returns leader of this group. Note that group leader is chosen internally and may be changed at any time of group movement, so user shouldn't completely rely on the value returned by this function. Sample use cases of this function:
      - the designation of an event occurring once per group, e.g. when a ped leaving PedGroupAssemble block is a group leader: ped.getGroup().getLeader() == ped  
      - group selection by selection of its leader:   pedConfiguration.select(group.getLeader()

setFormation( GroupFormation formation ) - Sets a new formation type for this group.

int getId() - Returns unique identifier for the group.