AnyLogic 9
Expand
Font size

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 blocks of Pedestrian Library.

Servicing groups of pedestrians

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

The behaviors are:

  • All group members are serviced individually — Each member of the group should be serviced individually. The example of such a service: turnstiles.
  • Only one group member is serviced, others wait in a queue — The example: a family buying cinema tickets at the counter. All the family members wait in a queue to choose the seats together, but only one of them — the head of the family pays and gets serviced.
  • Only one group member is serviced, others wait in a waiting area — The example: a tourist group buying museum tickets. The tourists do not wait in the queue, they just wait for their tour guide to buy the tickets for the whole group.
Note that these behavior modes are applied only when a group of pedestrians is serviced in a service with lines, not in a service with area.

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 services with lines (Grouping property section).

Demo model: Group Behavior in Services Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).

Assembling groups

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

  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 block) at input port and injects pedestrians into the simulated environment at specified location. This block 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 block is used to reassemble groups which have been split by blocks which don’t support groups: 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:

  • on size reached — When the specified group size is reached.
  • on timeout — When the specified timeout expires.
  • on time gap — When delay between pedestrian arrivals exceeds the specified gap value.

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 block. This block causes group to change its form to a specified one when group leader passes this block.

Disassembling groups

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

Demo model: Pedestrian Groups Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).

Social distancing

Pedestrians in the group do not observe social distance between each other while moving or waiting in queues or service areas.

Nodes with access restrictions

When a route is created for a pedestrian group, all members of the group receive the same general instructions on how to handle the nodes with access restrictions. If the access to the node is restricted by a condition, this condition is calculated once for the whole group at the start of the movement: either all members of the group will wait until the node opens or all of them will bypass the node. However, each member of the group would be handled individually when they reach the node's border and try to enter the node. So condition for entering will be checked for each member of the pedestrian group.

To avoid situations where agents may remain in the queue indefinitely, we recommend disassembling groups before they have to pass through such nodes, and reassembling them after.

PedGroup API

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

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

for (Agent ped : group) { }

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

Accessing group and its members
Function Description
List<Agent> getPeds() Returns the list of pedestrians - members of this group.
Agent get(int index) Returns a pedestrian with the given index in a group. Enumeration starts from zero, the leader of the group has index 0.
boolean contains(Agent ped) Returns true, if the group contains the specified pedestrian, otherwise returns false.
int size() Returns the number of pedestrians in this group.
Agent getLeader() Returns leader of this group.
Group leader is chosen internally and may be changed at any time of group movement, so you 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 pedestrian leaving PedGroupAssemble block is a group leader: ped.getGroup().getLeader() == ped
  • group selection by selection of its leader: pedConfiguration.select(group.getLeader()
int getId() Returns the unique identifier for the group.
Control
Function Description
void add(Agent ped) Adds the given pedestrian (ped) to this group.
void remove(Agent ped) Removes the given pedestrian (ped) from this group.
void disassemble() Disassembles this group, removes all the pedestrians from this group making them independent. Group is destroyed.
Group formation
Function Description
PedConstants.GroupFormation getFormation() Returns the current formation type of the group.

Possible values:
PedConstants.GroupFormation.SWARM — swarm
PedConstants.GroupFormation.CHAIN — chain
PedConstants.GroupFormation.FRONT — front
void setFormation(PedConstants.GroupFormation formation) Sets a new formation type for this group.

formation — the new group formation
Valid values:
PedConstants.GroupFormation.SWARM — swarm
PedConstants.GroupFormation.CHAIN — chain
PedConstants.GroupFormation.FRONT — front
Cancelling policy
Function Description
boolean isSolidCancelling() Returns the parameter that defines whether cancelling an operation of a pedestrian should also be applied to all other members of the same group of pedestrians. Returns true, if cancelling should be applied to all other pedestrians of the same group, otherwise returns false.
void setSolidCancelling(boolean solidCancelling) Sets the parameter that defines whether cancelling an operation of a pedestrian should also cancel operations of all other members of the same group of pedestrians.

solidCancelling — if true, cancelling an operation of a pedestrian should cancel current operations of all other pedestrians of the same group, if false - it does not affect other pedestrians
How can we improve this article?