Estimating Social Contacts in Mass Gatherings Through Agent-Based Simulation Modeling: Case of Hajj Pilgrimage

Most mass gathering events have been suspended due to the SARS-CoV-2 pandemic. However, with vaccination rollout, whether and how to organize some of these mass gathering events arises as part of the pandemic recovery discussions, and this calls for decision support tools. Hajj , one of the world's largest religious gatherings, was substantively scaled down in 2020 and it is still unclear if it will take place in 2021 and sub-sequent years. Considering the disease trends and vaccination conditions in the pilgrims’ country of origin, and the operational and logistical aspects of implementing public health measures, Hajj reopening conditions could be very complex. Simulating disease transmission dynamics during the Hajj season under different conditions can provide some insights for better decision-making. Since most disease risk assessment models require data on the number and nature of possible close contacts between individuals, we seek to use integrated agent-based modeling and discrete events simulation techniques to capture risky contacts among the pilgrims in one of the Hajj major sites, namely Masjid-Al-Haram. In particular, we assessed different scenarios concerning the total number of pilgrims and enforced physical distancing measures. Our simulation results show that a plethora of risky contacts may occur during the rituals. Also, as the total number of pilgrims increases at each site, the number of risky contacts increases, and physical distancing measures may be challenging to maintain beyond a certain number of pilgrims in the site.


Introduction
According to the World Health Organization, mass gatherings can be defined as "events attended by a sufficient number of people to strain the planning and response resources of a community, state or nation" 1 . The Hajj (pilgrimage), the yearly pilgrimage to the holiest city of Mecca, Kingdom of Saudi Arabia, and one of the five pillars of the Islamic creed represents the largest annual mass gathering worldwide. During the Hajj event, pilgrims perform rituals and prayers in mass in some predefined indoor and outdoor spaces, often under very close, shoulder to shoulder, and dense and crowded conditions, creating an ideal environment for disease transmission. During the Hajj event, pilgrim density in some areas reaches up to six persons per square meter 2 ; under these conditions, respiratory infectious diseases could easily affect a large percent of pilgrims 3 .
Although disease transmission during the Hajj has been a concern for decades, it has become one of the key issues during recent years, particularly in 2009 during H1N1 influenza, in 2012 MERS outbreaks 2,4 , and now in the COVID-19 pandemic. Although the Hajj event has rarely been canceled in the past, major historical disease outbreaks such as the plague of 1967 have caused the cancellation of the pilgrimage. Recent disease outbreaks have been treated through the implementation of specific public health interventions such as mandatory vaccination (i.e. polio and meningitis), education campaigns, and country-specific restrictions, such as the restrictions applied to the countries impacted by the Ebola crisis 4 . Given that a large number of pilgrims take part in Hajj from more than 180 countries 5,6 , it can potentially serve as a superspreading event, and an outbreak can have significant global impacts.
With the emergence of the COVID-19 pandemic, concerns were raised about mass gathering events including Hajj. The Hajj for 2020 was not fully canceled. Instead, Saudi Arabia's government decided to organize a very small pilgrimage with the total number of pilgrims limited to only 1,000 7 . Participants were randomly selected from nationals of 160 countries who were already residing in Saudi Arabia 3 . This allowed a much easier and more practical physical distancing among the pilgrims in all major Hajj sites 8,9 . Otherwise, the risk of virus transmission would have been very high. For example, Yezli & Khan (2020) estimated that the total number of primary COVID-19 cases per one million participants to be around 1,392 cases, including 472 imported cases 9 . This could go up to 4,872 after adjusting for secondary cases, which could easily overwhelm the hospital and ICU capacities in the cities hosting Hajj-related programs.
In 2020, specific criteria were applied to qualify Hajj pilgrims to enter the random pool. In particular, they had to be between 20-65 years of age, not obese and without any chronic illnesses, and had to carry valid (recent) negative covid-19 tests. All participants had to go through medical examinations, screening, 14 days of quarantine before arriving for Hajj, and 4 days of quarantine in a hotel upon arrival in Mecca. Moreover, during the Hajj event, pilgrims were instructed to maintain a physical distance of 1.5 meters from each other, wear face masks, follow hygiene protocols, and inform public health staff in case of experiencing any symptoms 3 . Pilgrims were also divided into groups of 20 people, and each group was assigned a healthcare professional for guidance and support. The Saudi government was prepared to respond to potential outbreaks among the pilgrims and the local residents 3 . In addition, all local service providers were subject to regular COVID-19 screening and testing 10 .
As a result of strict rules and the limited number of pilgrims, no outbreak was reported during the 2020 Hajj 3 , and our simulations will confirm that the social contacts under this population size were so low that indeed outbreak potential was small. Despite the unusually low number of participants, this program was good practice for the organizers to better understand COVID-19 challenges in different Hajj sites and helped them be better prepared for an expanded 2021 Hajj experience under such conditions 4 . However, the emergence of More transmissible new variants and the uncertainty that still exists about the effectiveness of vaccines on different COVID-19 variants and the duration of the protection afforded by the various vaccines, combined has further complicated the situation for the 2021 Hajj planning.
In order to better inform our understanding of the potential contact dynamics during the Hajj event, we have developed a simulation tool that estimates the potential number and duration of risky contacts in one of the Hajj main sites, the Grand Mosque, where almost every pilgrim visits several times during the pilgrimage. The information obtained regarding risky contacts can be used to assess the feasibility of physical distancing measures as well as to estimate disease transmission rates under different policy choices and scenarios.

Total and unique contacts
Assuming the Mata'af area is a circle with a radius of 60 m, given that the Kaaba radius is 10 m, the free surface area for Tawaf would be about 11,000 m² ( Figure 1). The total number of pilgrims in this area can reach up to 72,000 with a density of 6-7 people per square meter (about 0.15 m² per pilgrim). As previous studies indicated 11 , for an efficient and physically safe Tawaf, the maximum number of pilgrims in Mata'af should be limited to 30,000 pilgrims per hour.
The rate of pilgrims' entrance to the Masjid-Al-Haram varies depending on the time of day and the season. The maximum rate in a peak season has been between 15 and 18 pilgrims per second 11 .
Knowing that each efficient and safe Tawaf takes an average of 850 seconds, the maximum number of pilgrims in Mata'af should be limited to about 7,000 pilgrims that would yield an average density of 0.64 pilgrims per square meter. Therefore, the rate of the entrance to Mata'af should be restricted to remain at this level. The results of the Monte Carlo simulation for the Mata'af and the Masa'a areas are presented in Figure 1b, and Tables 1 and 2. Based on this simulation, the number of contacts can exponentially increase with the increase of the total number of pilgrims. The contact parameters in the Masa'a are slightly less than the corresponding parameters in the Mata'af. Once the number of pilgrims becomes greater than 2,500 people, almost everybody experiences at least one contact. Performing the rituals is a continuous and dynamic movement and pilgrims are moving from an area to another after each step is completed. Therefore, the number of pilgrims in an area is varying in time. To be able to calculate the number of contacts for a certain number of populations, we traced and counted the number of pilgrims in Mata'af and Masa'a.     To find the potential number of contacts during Tawaf and Sa'ay rituals, several scenarios were defined considering the total number of pilgrims in each of these areas while observing social distancing measures. In this study, we report the results for a total population between 1,000 and 10,000 entering Masjid-Al-Haram through the entrance gates. Tables 3 and 4 summarize the number of contacts for different numbers of the total population in the Tawaf and Masa'a areas, respectively.   in Mata'af (in which pilgrims are mostly in rotation) is more than those of Masa'a (in which pilgrims mostly move in a straight path). This is due to the difference in the length of motion of pilgrims that are walking at different distances from Kaaba that increases the probability of becoming too close to other pilgrims. Also, more congestion occurs in the Tawaf ritual due to the fact that individuals circulating on the inner circular paths need to exit Mata'af once they finish their seven rounds, thereby meeting individuals on the outer circular paths. Figure Figure 4. Distribution of the average number of total contacts and the average time a pilgrim spends in the Masjid-Al-Haram

Contacts and physical distancing
To examine the effect of social distancing on the number of contacts, we assumed that a controlled pattern of pilgrim distribution is applied in Mata'af during the Tawaf ritual around Kaaba. Several circular paths with a distance of 0.5 meters were assumed to be the path of Tawaf. The distribution of pilgrims entering the area was assumed to be related to the length that they should pass in the circulation. Therefore, instead of an initial uniform distribution perpendicular to Kaaba (In Figure   5, we have = where and are the numbers of pilgrims inside and outside the circle, respectively), a triangular distribution was used ( Figure 5, < ). More pilgrims are sent to the outer circles at a larger radius.
Applying this method, pilgrims are well distributed on the predefined circles. Figure 10b demonstrates the distribution of the total number of 2,000 pilgrims with a distance of two meters around the Kaaba using a random triangular distribution. A few local congestions can be seen in this figure, which are the results of the discrepancies in the speed and random direction of the circulating pilgrims. This is similar to real situations where physical distancing is enforced in the Mata'af area, thus we accepted those congestions. In addition, when this type of social distancing is applied in reality, the distance with the preceding pilgrim in a path should be controlled by the pilgrim and in real conditions, they cannot be forced to keep the desired distances. Therefore, we assume that the random distribution on a circular path that is controlled by the entrance rate of the pilgrims is reflective of the real situation. Using this approach, we assumed various such distances with different numbers of total pilgrims and calculated the number of contacts under each scenario.
We report here the results for an average distance of 0.5 to 4 meters for 2,000, 2,500, and 3,000 pilgrims in the Mata'af area. These numbers of pilgrims correspond to densities of 0.18, 0.23, and 0.27 per square meter, respectively, which guarantees the applicability of physical distancing within the assumed parameter values. Figure 6 shows the number of unique risky contacts under different physical distancing rules among the pilgrims around in Mata'af area. With these population sizes, applying distances equal to or greater than four meters would result in more people being placed in the same length of the path, which leads to fewer front distances and more contacts. Increasing the number of contacts due to less gap between the pilgrims can be seen in Figure 6 for four-meter distancing.

Discussion and Conclusion
In this paper, we presented a simulation tool that enables us to calculate social contacts among the

Hajj pilgrimage locations and sites
Within Saudi Arabia, there are at least three major cities that are visited by pilgrims, namely Madinah, Jeddah, and Mecca (Figure 1a). Madinah is where the Masjid-Al-Nabi is located; some pilgrims arrive by plane to this city first and stay a few days here. This visit is not mandatory for pilgrims. Jeddah is where the major airport is located that handles the majority of international arrival and departure for Hajj Pilgrimage. Mecca is where all mandatory Hajj rituals take place. Tawaf is about 30,000 Tawafs per hour 11 . The distance between the Safa and Marwa is around 450 m, therefore, seven trips back and forth sums up to roughly 3.6 km. This area is divided into two 16 m wide corridors. Recently, the Masjid-Al-Haram has a much higher throughput due to the increased capacity of the Masa'a building 11 . Measurements indicate that the current maximum rate of entrance and exit from the Masjid-Al-Haram can reach up to 55,000 to 65,000 pilgrims per hour in peak seasons 11 .
Pilgrim speed in the Mata'af area is a function of the pilgrims' densities, time of the day, and age of pilgrims. There are fluctuations in the speed due to turbulence in the pilgrim flux, and oscillation on the pilgrims' paths caused by shock waves which are affected by the repulsive forces between the pedestrians in the high-density crowd 13 . The average measured speed varies from 0.3 m/s in the higher-density areas to 1.1 m/s in lower-density areas 13 .

Simulation method
In this study, we used a mix of agent-based modeling and discrete events simulation techniques.
Agent-based models can be used to model the pedestrians' behaviors in crowds 12   Pilgrims pray there for about five minutes before leaving for Masa'a building using a path outside the Mata'af area (following purple color arrows). Pilgrims enter the Masa'a building near the Safa hill and begin their Sa'ay ritual. After seven rounds of Sa'ay, pilgrims leave the Masjid from one of the five main gates (following red color arrows). To simulate and direct pilgrims' movements around Kaaba in Mata'af, we first created 36 fiftymeter radial lines around Kaaba, each divided into 100 half-meter segments (Figure 10a). Pilgrims have to cross one of these segments when passing the radial lines. Using this high-resolution setting for the path of pilgrims for the Tawaf ritual, it is possible to control the movements of pilgrims in half meters distance ranges perpendicular to Kaaba. This allows us to set the average radius of each circulation path, the extent of movement perpendicular to the circular motion, and the density of pilgrims in different locations before running the simulation. This also allows us to implement various movement patterns such as wavy motion, and social distancing perpendicular to the circulation in the Tawaf which has been practiced during the 2020 Hajj (Figure 10b). Code walkthroughs, debugging, and time measurements were used to verify the simulation.
(a) (b) (c) (d) Figure 10. Model characteristics and features, a) Geometrical setting of pilgrims' paths (3,600 radial segments to control the movements around the Kaaba), b) Social distancing perpendicular to the circulation (2,000 pilgrims in distance on circles with the distance of 2.0 m), c) Density map of 2,500 pilgrims (Legends show the number of pilgrims per square meter of area, and d) Density map of 5,000 pilgrims.
According to previous studies (e.g., 13 ), the average speed of pilgrims is assumed to be 1.1±0.1 (m/s) in low-density areas. Since the movement of pilgrims is controlled by the embedded social forces method in AnyLogic's Pedestrian Library, the speed of pilgrims in high-density locations is adapted based on population density. Because of the randomness of movement, different time of entrances, different lengths of circulation on each circle and time of Tawaf, differences in approaching or departing direction of pilgrims that are entering or exiting Tawaf with who are circulating, different densities and consequently various speeds form in Mata'af. In the model, we set the rate of entrance and path of pilgrims from the entrance gates to the Mata'af, and let pilgrims randomly uniformly distributed over 100 circles around the Kaaba. All other movements are automatically controlled by the Pedestrian Library which simulates the motion like the real pedestrians. Initial tests of the model showed that using this setting, we can simulate different numbers of populations (Figure 10c and d). At a population of more than 4,000 people, some congestion occurred behind the Place of Abraham near the Kaaba, which is similar to what has been observed in the real world.

Contact calculation
Close (risky) contacts are the main contributor to COVID-19 disease transmission. The CDC defines a close contact as someone who is within two meters of an infected person for at least 15 minutes within a 24-hour period 14 . We adopt this definition for contact, without specifying the infection status of individuals and considering the duration of contact, to calculate the number of such events taking place. We used two approaches: 1) A Monte Carlo sampling simulation to obtain the potential contacts between individuals in an area one moment in time, and 2) a simplified version of the simulation-based contacts matrix calculator method presented by 15 .
For the first method, it is assumed that different total numbers of individuals with an area of 0.15 m² are randomly distributed in an area with a certain geometry in a moment. Pairwise distances between all individuals were calculated. Distances less than two meters were taken as a contact. In the second method, 15 methodology was used to calculate the number of contacts. In this model, each pilgrim finds other pilgrims within a two-meter radius of himself/herself (close contact) at every time step. In short, if each close person is not the same as the people that were in close contact in the previous time step, a new contact case is added to the pilgrim's contact memory.
These calculations begin when a pilgrim is at the entrance gate and stop when the pilgrim leaves the Masjid-Al-Haram. The contacts are accumulated during the ritual for each pilgrim and averaged over all pilgrims. We calculated the number of contacts in different locations of Masjid-Al-Haram, normalized for the total number of pilgrims. In addition, we calculated the unique contacts that each pilgrim experiences during the ritual. This was done by recording the new contacts in the memory of the pilgrim without considering the time of contact.