PedGroupAssemble


Organizes groups from sequence of pedestrians on input port. Allows defining multiple criteria for groups creation - group size, form, groups arrival rate and peds interarrival delay.

Reassembles 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. Groups are reassembled independently and simultaneously, and also at the same time new groups may be organized from single pedestrians.

Demonstration model: Pedestrian Groups

Parameters

Area [dynamic]
Area where pedestrians will wait for group assembly.
Value type:  AreaNode
Local variable: ped - the pedestrian
This block 
Choose here whether this block creates groups, or assembles them by matching pedestrians and groups.
Get value: assemblingMode
Change value dynamically: set_assemblingMode()
Valid values: PedGroupAssemble.ASSEMBLING_MODE_BY_CONDITIONS
           PedGroupAssemble.ASSEMBLING_MODE_BY_MATCHING
New group is created 
[Visible if This block creates groups] Defines how groups are created: whether a group is created when the specified group size is reached (on size reached), or when the specified timeout expires (on timeout), or when delay between pedestrian arrivals exceeds the specified gap value (on time gap), or the user specifies conditions and add pedestrian to some specific group e.g. when pedestrian and group IDs match (when condition is true).
Get value: groupingMode  Change value: set_groupingMode(new value)
Valid values: PedGroupAssemble.GROUPING_MODE_SIZE_REACHED
           PedGroupAssemble.GROUPING_MODE_TIMEOUT
           PedGroupAssemble.GROUPING_MODE_TIME_GAP
Group size [dynamic]
[Visible if New group is created on size reached] Size of newly created group (number of pedestrians making up one group).
If you leave the default value here, groups containing 2 and 3 pedestrians will be created with equal probabilities. 
Value type: int
Default value: uniform_discr( 2, 3 )
Local variable: T leader - the group leader
Timeout [dynamic]
[Visible if New group is created on timeout] Time given for group creation. When this timeout elapses, the group creation is finished and next group starts forming.
Value type: double
Default value: exponential(300 / hour())
Maximum gap between members [dynamic]
[Visible if New group is created on time gap] Maximum pedestrian interarrival time, for them to be collected in one group. In case pedestrian interarrival time exceeds this value, new group is created.
Value type: double
Default value: 2 * second()
Matching condition [dynamic]
[Visible if This block assembles groups by matching] The specified here condition will be evaluated for all groups being currently assembled by this block. If the condition returns true for some group, the pedestrian will join this particular group. The condition may e.g. analyze and match IDs of group and pedestrian. If the condition returns false for all groups being currently selected, new group starts assembling.
Value type: boolean
Local variables: ped - the pedestrian, 
             PedGroup group - the group being currently checked
             T leader - the leader of the group being currently checked
Is assembly finished [dynamic]
[Visible if This block assembles groups by matching] If the specified here condition returns true, the group assembly is finished (the current pedestrian will be the last member added to the group).  
Value type: boolean
Local variables: PedGroup group - the group of the current pedestrian
             leader - the leader of the current pedestrian's group
             int size - the size of the current pedestrian's group
Formation
Form of the group: swarm, front, or chain.
Get value: groupFormation  Change value: set_groupFormation(new value)
Valid values: 
   GROUP_FORMATION_SWARM 
swarm
   GROUP_FORMATION_CHAIN
chain  
   GROUP_FORMATION_FRONT
front 
Behavior in services
Here you can define how the groups of pedestrians created by this object behave while passing the services (if some other behavior is not defined by the service).
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. The service in this case should be Service with lines.
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. The service in this case should be Service with area.
Get value: serviceGroupBehavior  Change value: set_serviceGroupBehavior(new value)
Valid values: PedEnter.SGB_INDIVIDUAL_SERVING
           PedEnter.SGB_ONE_MEMBER_IS_SERVED_OTHERS_WAIT_IN_QUEUE
           PedEnter.SGB_ONE_MEMBER_IS_SERVED_OTHERS_WAIT_IN_AREA
Actions
On enter [code]
Code executed when a pedestrian enters the block.
Local variable: ped - the pedestrian
On begin grouping [code]
Code is called when the current pedestrian arrived into this block is the leader of the new group (his arrival starts the new group assembly).
Local variables: leader - the leader of the group
             PedGroup group - the group being currently created.
On end grouping [code]
Code is called when the current pedestrian arrived into this block is the last member of this group (the next pedestrian will start forming a new group).
Local variables: leader - the leader of the group
             PedGroup group - the just created group.
On exit [code]
Code executed when a pedestrian exits the object in a normal way, via out port.
Local variable: ped - the pedestrian
On cancel [code]
Code executed when a pedestrian exits the block via emergency ccl port.
Local variable: ped - the pedestrian
On remove [code]
Code executed when a pedestrian is intentionally removed from this block by calling the pedestrian's function remove(). This code is automatically executed after the remove() function call.
Local variable:
ped - the pedestrian

Functions

long countPeds() - Returns total number of pedestrians passed through this block.

long countGroups() - Returns number of created groups (including the group which is currently being created).

int size() - Returns number of pedestrians currently waiting for group assembly (including the pedestrians with disabled groups, if any, which wait for their groupmates).

void cancel(Agent ped)-  Interrupts command for the specified pedestrian and causes it to exit using ccl port. Setting parameter to null will cause all pedestrians to leave the block via ccl port. The cancelled pedestrian isn't added to the group. On cancel callback is called for each pedestrian leaving the block.

void cancelAll()
- Interrupts command for all the pedestrians in this block and causes them to exit using ccl port. On cancel callback is called for each pedestrian leaving the block.

Ports

in
The input port.
out
The output port.
ccl
The output port for pedestrians leaving the object because of "cancel" event (caused by a call of either cancel or cancelAll method).