A Modelling and Scheduling Tool for Crowd Movement in Complex Network

Managing events pose a unique challenge to the stakeholders and authorities to control the crowd in all three phases of the event (pre, during and post), ensuring crowd safety. One of the fundamental keys to provide crowd safety is to consider the mobility infrastructure hosting the crowd, i.e., routes, areas, entrances and exits. During Hajj, where millions of pilgrims worldwide fulfil the annual event’s rites, mina encampment incorporates pilgrims performing recurring stoning ritual conducted over multi-level Jamarat bridge. Pilgrims mobility through the available complex road network, to and back from the Jamarat bridge, forces upon authorities in charge to set out mobility plans which may require off and on modification as per attendees’ preferences and organizational needs. This paper presents a basis for mathematical modelling of pilgrims’ mobility pattern in Mina by considering available corridors’ capacity, limited times, group size restrictions, and road segment connectivity. The developed mathematical model can generate an efficient schedule to control the flow through these corridors, assess crowd management risks when corridors’ capacity is affected by any emergency, and scientifically estimate each corridor’s maximum allowable occupants


Introduction
Increasingly affordable travelling facilities have mobilized a significant percentage of the world population for sports events, leisure trips, education, adventure, medical treatments and pilgrimage [1]. Mostly in sports or religion-related activities, people count reaches millions or even more. A few of the large gatherings 1 are Kumbh Mela (2013), gathering at the shrine of Husayn Ibn Ali (2013), the funeral of C. N. Annadurai (1969), the concert was given by Rod Stewart (1994), Hajj 2 the annual pilgrimage to Makkah, Dubai Exposition, protest in Circus Maximus, Rome against the government of Silvio The temporal implication is one of the solemn challenges for organizing authorities to make necessary arrangement to mobilize a massive Hajj crowd till the pilgrims safely reach back to their places after they had performed the rituals. It requires hosting authorities to integrate pedestrian movement and crowd safety with available resources and thoroughly analyze crowd's behaviour and utilize their mobility parameters like average speed/crowd density at the different hours of the day to set out efficient mobility plans, which can be deployed and be modified on demand to avoid any possible crowd shockwaves [5], disasters [6] and massive causalities such as Mina stampede in 2015 [7]. Pilgrims' sacerdotal interest keeps them cooperative with other pilgrims, which provides sustained parameters like their speed and crowd density when they pass through different transfer corridors and adapt precautionary behaviour during their mobility. This helps us consider speed and crowd density as starting parameters along with road capacity, temporal restrictions, groups size and threshold safety measures to model crowds' mobility across multiple transfer corridors in order to generate an efficient schedule to control and any possibility of stampedes due to possible crossflows at junctions.
In this paper, we detail the development of our mathematical model, which considers crowds safety parameters (road capacity and density, average walking speed etc.) set by the hosting authorities, the number of pilgrims in different tents which were allotted certain roads to go and come back to their place, after performing rituals, and possibly crossflows across the junctions. The model generates an efficient time schedule to control crowd flow, helping to manage risks in emergencies when there is the possibility of crossing the road capacity and density limits. We used this model for multiple scenarios, including understanding the corridor connectivity, generate mobility time schedules according to numerous criteria, find the maximum number of pilgrims that can occupy a particular area, find the minimum time to schedule all occupants, and test the impact on crowd mobility with dynamic changing of the corridors capacity, the number of pilgrims, group sizes and forbidden times.
To validate the model, we added a sample scenario by considering a small mina area with ten tents and seven connecting road segments and the Jamarat bridge as the pilgrims' final destination during the stoning ritual. The simulation was carried out, and the model was tested with two features, the impact of changing road capacity and forbidden time slots set by the organizing authorities and or pilgrims' preferences. Implementation details and related statistics are presented in the paper.
The rest of the paper is organized as: After the introduction section, we have added state-of-the-art by the past researchers, followed by modelling in Section 3. Next, we presented a use case describing pilgrims' movement within the Mina area under spatio-temporal and safety constraints in Section 4. Later in Section 5, we show the implementation details and finally added Section 6 for more information on the results and discussion.

Literature Review
Mina is most important for its role during the entire Hajj event, where the complex nature of pedestrian walkways and possible crossflows of pilgrims need continued efforts to integrate crowd behaviour in terms of speed/density with analysis of interconnectivity of the Mina roads. This section includes past researchers' contribution in this area and different models to analyze pedestrian movement and proposed mobility plans for large gatherings. Templeton et al. [8] presented pedestrian behaviour while they were walking through the crossflow. By comparing the individuals and the groups based on pedestrians' speed and the distance travelled towards the junctions, the study showed that the crowd self organizes to reduce the impact of possible stampede over the junctions.
Li et al. [9] conducted a qualitative study to understand both unidirectional and bidirectional pedestrian movement on a zigzag corridor located in a business district in Yiyuan, China. To study the movement patterns, videos were captured by the surveillance cameras installed in the study area of the corridor that was divided into three right-angled corners and two straight corridors. Image processing techniques were used to manually extract each pedestrian's spatial coordinate during both Uni and bidirectional flow. Thus, their trajectories were obtained to analyze the crowd density, velocity, and other related movement characteristics. Their findings supported the unidirectional movement and emphasized focusing more on straight corridor boundaries to avoid clustering.
Dridi [10] developed a microscopic model that uses PedFlow simulation [2] to discuss the high-density crowd behaviour in autonomous and controlled scenarios. To validate the model, the simulation was carried out to study the high-density pilgrims crowd cramming the Jamarat bridge during the Hajj event. Analyzing mobility patterns at different speeds and under different circumstances provided different evacuation control strategies to ensure pedestrian safety. The centrifugal force model describes the pedestrian movement in terms of their acceleration towards their desired velocities, the attraction or repulsion between them. At the same time, they are in motion and their interaction with walls and other rigid objects in their way [11]. Charaibi et al. [12,13] presented a modified spatially continuous forced-based model that described the pedestrian movement quantitative in one and two dimensions (on several geometrical paths). The oscillations and overlapping of an elliptical volume exclusion were introduced compared to the standard circular one for narrow and wide corridors. Simulating the model with experimental data deduced that the model could be improved by considering a density-dependent repulsive force.
Wang et al. [5], Helbing et al. [14] presented the social force model, explained crowd shockwave (Fig. 2.) as one of the causes of crowd destabilization and stampede accidents. They utilized social force theory and presented a crowd shockwave simulation model to understand the crowd shockwave transmission mechanism. Its amplitude was defined in terms of crowd density, propagation speed, and duration.
They carried out an experiment where pedestrians were asked to move through a high fences flank channel along with a waiting area on its right side in a college building in Nanjing Technology University. Two cameras and a UAV (unnamed aerial vehicle (drone)) were used to capture mobility videos of volunteers wearing white shirts and red hats and were asked to move under multiple constraints. The resulting crowd shockwaves were analyzed, and control strategies helped reduce the crowd shockwaves and prevent stampedes were proposed in similar scenarios. Chen et al. [15] presented extended LGM (Lattice Gas Model) for simulating pedestrian movements using statistical methods. They introduced the concept of local density in their two-dimensional pedestrian movement study, which described the spatial occupancy of a small area around a pedestrian, leading them to derive the relationship between the local density and the pedestrian movement. The proposed model successfully demonstrated fair numerical results when applied to an open dataset comprising a series of unidirectional pedestrian flow experiments and clarified pedestrian movements' statistical characteristics.
Helbing et al. [14] presented the social force model, and later Helbing explained the Fluid Dynamic Model [16] to describe pedestrian motion. The forces are considered as the internal motivations of the individuals during their activity. Considering the pedestrians' behaviour in terms of pedestrians' acceleration towards their desired velocities, distances between themselves and from the borders, and modelling attractive effects, the modelled resulted in nonlinearly coupled Langevin equations. The model was validated by simulating with pedestrians' crowd and successfully described the self-organizing pedestrian behavior.
Still et al. [17] presented an implementation report of a crowd safety management tool for the places where there is public assembly and a significant event. This tool provides insight into strategic planning to reduce the potential threats to crowd safety. Continuing their research in the same area, later Still [18] presented their article addressing the importance of crowd counting that is the core objective before planning for the safety crowd plans.
Dietrich et al. [19] set of Force Based Model, Georgoudas et al. [20] used a simulation tool for modelling pedestrian dynamics during large areas' evacuation. Kang et al. [21] showcased a realistic and straightforward Pedestrian Model for Crowd Simulation and Application, and Blue and Adler used "Cellular automata microsimulation for modelling bi-directional pedestrian walkways [22].
Hajj crowd is different in terms of participants' ethnic and cultural background, various age groups and language diversity, which in addition to available multi-shaped transfer corridors, gathering for a long duration of about a week, and personal and managerial preferences are challenging for hosting authorities to ensure crowd safety from arrival till the safe departure of all pilgrims back to their homes. In the past, researchers work limit us to utilize their models over the Hajj crowd partially. However, several constraints' dynamic nature requires designing an intelligent system that can accommodate all and modify demand. In this context, we modelled crowds' mobility during the Hajj and presented the implementation details and related statistics.

Scheduling Model
In this section, we present our model for groups scheduling. Let G ¼ fg 1 ; g 2 ; . . . ; g M g be the set of M groups. The size of groups is denoted with H ¼ fh 1 ; h 2 ; . . . ; h M g. Groups are accommodated in tents, where each tent is connected to one (or more) road segments. Road segments are modelled as the following. Let S ¼ fs 1 ; s 2 ; . . . ; s N g be the set of N unidirectional road segments. Segments have a fixed length of 50 m and are connected at junctions. Let the road segment capacity by C ¼ fc 1 ; c 2 ; . . . ; c N }. We model the connection of the road segments with X ¼ fx 11 ; x 12 ; . . . :; x 1N ; x 21 ; . . . ; x NN g, where x ij = 1, if road segment s j is connected to road segment s j (i.e., the end of the segment s I connects to the start of the segment s j ), and 0 otherwise.
We denote the assignment of groups to road segment by A ¼ fa 11 ; a 12 ; . . . ; a 1N ; a 21 ; . . . ; a MN g, where a ij = hi if the i th the group is dispatched to the j th road segment, and 0 otherwise. The groups are dispatched during specific time periods. We assume that the dispatching periods have a uniform length, e.g., five minutes for the period. We denote the assignment of groups to time slots with where K is the number of time slots during this scheduling process. Let R be the road capacity when the groups are dispatched to the road segments. R can be computed as the following.
Note the R represents the number of people dispatched to the road segment over K time slots. However, R does not model the crowd's mobility in terms of moving from one location to another through the road segments. During Hajj, groups are expected to follow particular paths, starting from tents to Jamarat. To model the actual road capacity based on the flow of groups from their tents, we use F ¼ ff 11 ; f 12 ; . . . ; f 1K ; f 21 ; . . . :; f NK g, whereK = K + N. F can be computed as the following.

Safety-Aware Scheduling
Now, we introduce the formulation of an optimization problem pertaining to scheduling group dispatching over K time slots. The output of the problem is O, i.e., the dispatch assignment to each time slot. This problem's objective is to increase the safety of dispatched groups by reducing the traffic flow in each road segment at each time slot. To achieve that, we formulate the objective function to maximize the difference between the maximum capacity and actual capacity for each segment for each time slot in K. Formally, we model the optimization problem as the following. Fig. 3. depicts an example setup for road segments (S ¼ fs 1 ; s 2 ; s 3 ; s 4 g) and groups (G ¼ fg 1 ; g 2 ; g 3 gÞ. The groups size is H ¼ f150; 200; 300g and the segment capacity is C ¼ f200; 200; 400; 400g. The road segments network is given as the following. For example, x 13 ¼ 1 denotes that road segment s 1 is connected to s 3 . We can also dictate that segment s 3 has is connected to two other segments, i.e., s 1 and s 2 (x 13 ¼ 1 and x 23 ¼ 1). The groups to road assignment are the following. Solving the optimization problem (Equation xx), we obtain the optimal scheduling with a cost of 7950 by dispatching the first, second, and third groups at k1, k2, and k4, respectively. Fig. 4. illustrates the dispatch schedule over time. Group 'g1' reached its destination at time 't3' from segment 'S1'

Mina Area-A Use Case of Hajj
Mina is most important for its role during the entire Hajj event, where the complex nature of pedestrians' walkways and possible crossflows of pilgrims need continuum efforts to integrate crowd behaviour in terms of speed/density with analysis of interconnectivity of the Mina roads. In the Mina area's topographical nature, pilgrims are bound to move through different types of transfer corridors (uphill, downhill, zigzag, Y, L, T, and U-shape). Mina, also known as the largest city of tents globally, is a valley near Makkah covering roughly 20 km 2 (7.7 sq mi) of area. In this area, 2 million pilgrim stays in thousands of camps to perform stoning rituals. There are 16 main roads to access Jamarat and five returns roads towards Mina camps.
Unlike other rituals, stoning at Jamarat (Ramy al Jamarat) (Jamarat is a multi-level pedestrian bridge in the Mina area) is a recurring ritual, whereby pilgrims have to leave their tents and walk for a distance (ranging from a few 100 m to 4.5 km) and gather at the Jamarat bridge to perform the stoning ritual, for three consecutive days (10 th -12 th day of Dhul-Hijjah). Fig. 1b shows a multi-level Jamarat bridge, where pilgrims can throw stones at the three Jamarah pillars 5 (Al-Jamarah Al-Sughra; Al-Jamarah Al-Wusta; and Al-Jamarah Al-Kubra or Jamarat Al-Aqaba) from either the ground level or any other pre-allotted floor. The Jamarat is a five-storey building with a capacity of 100,000 of each level. The facility includes multiple stairs, elevators, and ramps. The top floor of the Jamarat floor is connected with Mina 3 Train station. Fig. 5. shows part of the Mina area and the highlighted camps allotted to south Asian pilgrims (209 tents and 693027 pilgrims) during the Hajj 2019 event. As a part of safe crowd management, these pilgrims were bound only to use the third floor of the Jamarat bridge for stoning the devil ritual. For this purpose, routes G (shown in green) and the pilgrims of tent T1 used r (shown in red). Other than the large section of route G (route R on return) that all the pilgrims of this section commonly used, several sub-routes (used by pilgrims of other tents) merged into this route, agitating the movement of pilgrims of tent T1. A similar can be imagined about pilgrims' movement of other tents using different paths integrating into route G.

Implementation
MATLAB (an abbreviation of "matrix laboratory") has been used to implement the model. We used the R2020b version on i7 processor, 1.6 GHz speed and with 8 GB RAM. MATLAB leverages the mathematical operation and various operation on the matrix. The full implementation of the model is configurable, connecting as many road segments, tents, and pilgrims in each tent. The model also allows the user to update the road's capacity and set the maximum allowed threshold.
The implementation has been divided into two parts. The first part is building up the model with all the configuration and the second part is to select the output with minimum cost. The code also considers special conditions such as partial closing any segment or stopping scheduling for a given period.
To validate our model, we run the simulation and analyses the same using a density heat map. The simulation was carried out using a desktop computer, ensuring no other task was being processed by the machine. The software details are provided in Tab. 1 below.

Results and Discussion
We digitize the small area of Mina with the factual information of pilgrims to prove our proposed model, as shown in Fig. 6. We modelled this area with ten camps and seven segments, where each segment's length is 300 m. A total of 34,575 pilgrims are distributed in 10 different tents, as shown in Tab. 2. We assume that the pilgrims' destination, i.e., the Jamarat building, is at the end of segment seven.  G ¼ fg 1 ; g 2 ; g 3 ; g 4 ; g 5 ; g 6 ; g 7 ; g 8 ; g 9 ; g 10 g.
The groups size is H ¼ f1400; 2750; 5952; 2750; 5500; 2256; 4862; 2600; 2436; 4069g and the segment capacity is C ¼ f9000; 9000; 6000; 6000; 6000; 9000; 9000g. The road segments network is given as the following. The road segment matrix helps stakeholders and decision-makers to identify all the multi-connected and unconnected segments quickly. For example, matrix 'X' rows and columns submission provides deep insights. The following matrix shows the sum of columns and rows of 'X'. If the column sum is more than one, then it means that the segment has multiple inputs, as segment six sum is two, so it implies that segment 6 has two input segments. Similarly, we can find the split segment into more than one parts from the sum of rows.

Schedule the Movement of Pilgrims
To move mobility safe and efficient, the Ministry of Hajj and Umrah need to schedule pilgrims from their camps to the Jamarat with constraints such as road capacity cannot be more than 50%, dispatching pilgrims cannot be done in the meantime forbidden hours etc. Our proposed model schedules pilgrims' mobility plan from different segments and time slots, as shown in Tab. 3. The table also shows the percentage of road utilization during all time slots. The time slots T1, T2 … Tn values can be updated as per requirements, such as the length of the segment and crowd flow speed. Each time slot is with a difference of 5 min in our scenario, assuming the segment's size is 300 m long and the crowd speed is 1 m/s. Therefore, the total time to schedule 34575 pilgrims is 110 min without violating 50% road capacity constraint.

Recommend Minimum Time Frame to Schedule the Given Number of Pilgrims
Operating parties are always interested in minimizing their service time to provide crowd management support. The model takes the infrastructure, i.e., matrix X , capacities of all segments, number of pilgrims in each tent, camp segment assignment list and capacity constraint threshold. Later, our proposed model recommends the minimum time slots require to schedule the given number of pilgrims in a defined infrastructure. Tab. 4 shows that we can schedule 34,575 pilgrims in eleven-time niches without violating the capacity constraint.

Recommend Maximum Number of Pilgrims
As per vision 2030, authorities are planning to increase the number of pilgrims. Our proposed model will recommend the maximum number of pilgrims who can safely schedule the current infrastructure and provide a time frame. First, the model takes the infrastructure, i.e., matrix X , capacities of all segments, time frame, camp segment assignment list and capacity constraint threshold. Later, our proposed model recommends the maximum number of pilgrims from each camp that can be scheduled safely in a given time frame. Tab. 5 shows that we can schedule 45,000 pilgrims in eleven-time slots without violating the capacity constraint. The table shows that segment S6 and S7 are utilized thoroughly to schedule the maximum number of pilgrims. Fig. 7. shows the number of pilgrims that can safely fit in each tent and segment.

Test the Impact of Forbidden Hours
The Ministry of Hajj and Umrah pause the mobility operation during each day of Hajj for a particular period to minimize congestion. For example, Day 10th Dhul Hijjah, 6-10 am, is forbidden for Jamarat rituals. At that time, pilgrims were not allowed to leave their camps for stoning ritual. Our model provides the flexibility to add forbidden hours and generate the schedule plan. Tab. 6 shows that we can schedule 34,575 pilgrims in 28 times slots by adding forbidden time to time slots (4, 5, 6, 7, 8, and 9). The table shows the schedule plan and road utilization.  6.6 Test the Impact of Increasing or Decreasing the Capacity of a Particular Segment/Segments During the season's operation, the corridors' capacity is dynamically changing due to many reasons such as service care blocking the road, accumulation of waste on the passage, or partially closed due to any incident or construction. The model allows the stakeholders to see the impact by increasing or decreasing a specific segment or multiple segments' capacity. The model will also help in decision-making in case authorities plans to enhance the infrastructure. Tab. 7 shows the mobility plan and road utilization after increasing the capacity of segments S6 and S7 by 25%, i.e., 13500. After expanding the capacity, the minimum time slot reduced by two as compared to Tab. 4. On the other side, if we decrease the segment's capacity by 25%, i.e., 6750, the number of time slots will increase by 5.

Validation of the Model using Simulation
The visualization helps the stakeholders identify the bottleneck areas and be in the state of preparedness during the operation phase, as shown in Fig. 8. The model and its results can be easily visualized using any simulation tool. We envisioned the result in the Mass motion 10.5.9 crowd simulation tool on Windows 10. Fig. 8a. demonstrates crowd movement on the intersection of segment S2, S5 and S6, whereas Fig. 8b. shows the movement's analysis with the help of a density heat map.   This paper presented a model to schedule the pilgrims' movement in the Mina area safely and efficiently. The model is generic, and all the inputs are configurable that allows stakeholders to run multiple queries.

Conclusion and Future Work
In this project, we developed a basis for mathematical modelling to model the mobility pattern of the Pilgrims in Mina, considering all of the critical details that govern this action, such as available corridor capacity, limited times, group size restrictions and road segment connectivity. We developed the model based on more information such as group sizes, basic corridor connectivity and dynamic capacity. The model has been used to generate mobility scheduling for the Pilgrims to control their flow on those corridors. We used this model to Understand the corridor connectivity, Generate mobility time schedules according to multiple criteria Find the maximum number of Pilgrims that can occupy a particular area Find the minimum time to schedule all occupants Test the impact on crowd mobility with dynamic changing of corridors capacity, number of pilgrims, group sizes and forbidden times.
We believe that this work can be further developed to mathematically describe the mobility of the crowd in Mina during Hajj seasons in more details and by including more complex parameters to enhance its accuracy. Furthermore, the utilization of this model can be advantageous to related planning and operating authorities such as the Royal Commission of Makkah and the Mashaer, Makkah Region Development Authority, Ministry of Hajj and Umrah and crowd management, security forces to achieve the goal of Vision 2030 of hosting more than 30 Million Umrah and Hajj visitors.