{'fraction_non_alphanumeric': 0.027763443079781194, 'fraction_numerical': 0.006777445212784257, 'mean_word_length': 4.878260869565217, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Optimizing Indoor Navigation Policies For Spatial Distancing

In this paper, we focus on the modification of policies that can lead to movement patterns and directional guidance of occupants, which are represented as agents in a 3D simulation engine. We demonstrate an optimization method that improves a spatial distancing metric by modifying the navigation graph by introducing a measure of spatial distancing of agents as a function of agent density (i.e., occupancy). Our optimization framework utilizes such metrics as the target function, using a hybrid approach of combining genetic algorithm and simulated annealing. We show that within our framework, the simulation-optimization process can help to improve spatial distancing between agents by optimizing the navigation policies for a given indoor environment.


INTRODUCTION
While many features of a building are quantifiable through existing simulation protocols, crowd management is an ongoing and difficult aspect of occupant experience to analyze. Although past work has studied simulation-based locomotion of agents in an environment, there is a challenge in dictating movement policies that facilitate the best outcome, such as maintaining distance, for a given space.
With the increased recognition of human health and safety, there is an increasingly important role of simulating the experience and conditions of humans themselves in the built environment, compared to the natural conditions such as lighting and heating. These simulations can aid during the design process, but importantly, in the post-occupancy analysis as well. Unlike typical human subjectbased post-occupancy evaluations, questions such as: how can we minimize contact of people? are not feasibly done with people, and instead, we can leverage simulation to aid in the decision process.
While existing work has focused heavily on either the control of crowd simulation or the use of crowd simulation for humancentered performance criteria, few works have considered this system from a management perspective in which generic navigation guidelines or policies are applied to the crowd.
In this paper, we present a novel graph-based model that describes the crowd management policies of an environment. Then, we conduct crowd simulations driven by these policies and collect temporal and spatial statistics of the agents' locomotion in the environment. Next, we evaluate the environment through a Spatial Distancing Index (SDI) value based on the crowd simulation statistics. Finally, we formulate the graph optimization problem using the SDI measuring and devise a novel optimization algorithm to find the best applicable policy of this environment. We demonstrate the efficacy of our method in several case studies to showcase the validity of our measure for social distancing, and the potential of using our framework to discover optimal navigation policies.

RELATED WORK
The growing research area combining crowd modeling and human behavior simulation has led to various examples of how the complexities of occupant movement and interaction with the built environment can provide valuable feedback on design choices.
Simulating crowds has been a topic of interest for many years in the game and animation industry [28]. Two key aspects of crowd simulation that must be considered, especially for building evaluation, are the agents' realistic behavior and decision-making abilities in the simulation. Numerous studies have considered methods for implementing human behaviors such as wayfinding tasks [8], narratives [29], panic [13], building evacuations [14], among others. Likewise, the validity of crowd behaviors has been studied [2], showing varying levels of accuracy to real-world trials. While there is no single simulator that perfectly matches all conditions, the estimation of crowd behavior in simulation is well accepted for important decisions such as egress [4], wayfinding [15], and to analyze building environments for human occupancies in general [33]. It has also been used with numerous commercial software products in existence (e.g., mass motion [25], and anylogic [1]).
Various crowd-based measures can be extracted from the simulations related to the occupant experience and quality of the building design. For example, crowd flow measures the rate at which the agents pass through a given point of interest in the environment (e.g., doors), crowd trajectories yield the path that individual agents follow during the course of the simulation, and evacuation time measures the egress time of the agents. These measures have been widely used to analyze crowd dynamics in building designs [3].
Recently, researchers have been using optimization techniques to optimize various contexts in building design, from lighting layouts [23], furniture [35,37], building layouts [7,9], to urban networks [5,20,24]. With the global impact of COVID-19 [26] forcing new policies of maintaining distance [36] and the economic impacts of complete lockdowns [6], it has become of great interest the ability to balance the number of people in a space with maximal distance. Recent works have used crowd simulation to determine probabilities of infection and spread [10], and to evaluate the impact of an environment's layout for violations to a desired occupant distancing rule [32]. However, the idea of the distance between occupants is not isolated to disease. More generally, psychological, social, and cultural factors influence the comfort levels of people based on their distances [12].
The work presented in [27] used geometry analysis to deduce the environment structure (e.g., topological and geometry information) as a navigation graph, which is then used as the basis for navigation planning and simulation. Graph optimization using simulated annealing has been studied thoroughly [16], while applications regarding crowd control or policy optimization have rarely been conducted. Simulated annealing has been used for the graph and network optimization in various fields such as traffic [39]. Engineering control for indoor environments has also been studied to control the transmission of airborne diseases, while the studied factors are limited, mainly related to airflow control and ventilation [22]. Recently, [10] demonstrated a method to simulate various combinations of a grocery store configuration using navigation graphs and shopping lists. This was to reduce disease spread based on their disease transmission model, while their optimization is a brute-force approach.
The use of an index for evaluating environments (built or virtual) has been of interest and use in the past. There is a walkability index [11] that is commonly used for urban planning and Indoor Walkability Index [30] for building circulation evaluation. We continue this along this human-centric theme by devising an index scoring, or ranking, a buiding's design through the SDI. Further details on the formulation and calculation of SDI can be found in Section 4.

OVERVIEW AND PRELIMINARIES
Our framework consists of 3 major components: (i) the crowd behavior simulation engine, (ii) the SDI model, and (iii) the graph optimizer. An overview of the complete working pipeline is shown in Figure 1. A list of terms used is presented in Table 1.
A complete cycle starts with an environment guidance policy, described by a structural graph. Along with the necessary behavior trees, the structural graph is then utilized by the simulation engine and a corresponding navigational graph is generated. Throughout the simulation, statistical data are collected and sent to the SDI evaluator to calculate the score of the current policy. As the last step in the cycle, the score is sent to the optimizer, which decides the next optimization step to take.

Graph-based Representation of Crowd Management Policies
We propose a graph representation of the directional policies enforced in the environment using a tuple of directed graphs < , ℎ >.
The graphs are represented with nodes and directed edges. Each tuple of graphs contains (i) a structural graph and (ii) a navigational graph ℎ.
For each environment, a structural graph is a static and abstract model that describes the high-level features of the environment, i.e., the directional policies enforced on the edges and the key nodes in Figure 2: The simulation-optimization pipeline. For each graph in a generation, we run a simulation session and SDI is calculated. We then use the graph policy with the minimum SDI value as the parent graph for the next generation or reject it with a decreasing probability. The optimization process terminates if the SDI value meets the set convergence threshold.  the environment. Such key nodes in the structural graph represent significant locations in the environment, e.g., the entrance, the exit, or a joint location of paths. An edge in the graph is considered as an abstract relation between two nodes, i.e., a policy that allows the agent to pass from one node to the other, or forbids such motion. These policies enforce that traveling between any two nodes can only be either bi-directional, single-way, or blocked (disjoint). Based on the structural graph, we dynamically generate a corresponding navigational graph during runtime for the pathfinding of the agents. Nodes in the navigational graph contain detailed navigation points of interest such as a specific shopping item. The navigational edges enumerate all possible paths between any two nodes in the structural graph so that when any agent traverses from one node to another, they can also approach a target shopping item without violating the policies. Figure 3 shows the relationship and difference between the structural and navigational graphs.

Human Behavior Simulation
The human behavior simulation (also known as crowd simulation) uses a Unity-based framework, ADAPT [18], to design and author meaningful animation, navigation, and agent behaviors in virtual environments. The framework consists of three layers: (i) a goaldirected locomotion and collision avoidance layer, (ii) a navigation layer for path planning, and (iii) a behavior tree layer for parameterized agent behaviors.

Locomotion and collision avoidance.
This layer controls the steering capabilities of the agents in the virtual environment. It uses ORCA (Optimal Reciprocal Collision Avoidance) [34] to find the optimal velocities for the agents using gradient descent. It communicates with the navigation layer for agents' path planning. Certain and with a directional edge from to . Along this edge, there are 6 navigational nodes ( 1 , 2 . . . , 6 ) and 16 corresponding navigational edges connecting them. (Bottom) During simulation, the agents will follow the direction for pathfinding. The colored arrows represent the directional policies (e.g., Green → Red).
crowd steering configurations such as walking speed, stopping conditions, and maintaining social distances are also set in this layer.
3.2.2 Path planning. The planning layer uses Unity's AI system for pathfinding in the environment. To compute the path from any two nodes in the graph, our nagivational graph first breaks the path down into small trajectory snippets, then for each trajectory snippet, we provide its starting and ending position to Unity's navigation system to conduct the actual locomotion. The navigation graphs are meticulously designed that any trajectory snippet is small enough to prevent the agents from violating the policies.

Behavior tree.
The behavior tree layer defines all the permissible actions that agents can perform during the simulation. These actions include walking, shopping, queuing, and entering/exiting the environment. The behavior tree layer is also responsible for scheduling and managing the sequence of behaviors that agents carry out during the simulation in an ordered fashion. Please refer to [31] for more details on the underlying implementation and authoring of behavior trees.
In the simulation process, we first load the environment model. All the furniture items (e.g., item shelves and checkout counters) are then procedurally generated. Next, the agents are initialized at the entrances. Initially, there is no agent present in the environment. We gradually let the agents enter the facility at a varying rate until the capped maximum capacity of the environment is reached. Afterward, a new agent is spawned only when an existing agent leaves the environment after performing the assigned behaviors. When an agent is spawned in the environment, it is given a list of randomly generated shopping items. The agents' tasks are to shop all the items from the list by traversing the environment and obeying any enforced navigation policies. Once all the items are obtained, the agent queues up at the checkout counter to pay for the items, and exits the environment. In our experiments, we scaled up the simulation speed for higher runtime efficiency.

Spatial Distancing Index
We present SDI as a function of the occupancy load over time for the given environment. The SDI considers the ability to maintain distances between the occupants, and for a given design (and its navigation policy), the ability to maintain distances at the various occupancy loads allowed in the environment space. For more details, see Section 4.

Optimization
Based on the graph representation of the policies, we devise a hybrid optimization process using the genetic algorithm (GA) and simulated annealing (SA) to approach the optimal policy with the best value of SDI or another arbitrary measuring metric. Details about the optimization framework and implementation of the algorithms are elaborated in Section 5.

SPATIAL DISTANCING INDEX
The SDI is a calculation method that evaluates an environment's proclivity to facilitating distances among occupants with respect to both space and time. While air exchange is included indirectly, this is to provide an estimate and can be applicable to smell, not only human-human disease spread. It is a function of the distances occupants can maintain and the maximum occupancy of the environment. In the real world, an occupant is a person. However, as this calculation is done in simulation, we will refer to the representation of an occupant as an agent.
Given a virtual environment, we define ℎ as the air exchange factor, and respectively as the minimum and maximum distancing threshold, as the total time of simulation, and a set as the agents in a simulation. However not all agents are in the environment at a given time (e.g., at the beginning of the simulation), hence we define a subset ⊂ for time where = { ∈ | is in the environment at time }. Matrix C contains the cells located in the environment. For a given cell, ì denotes the vector of scores, where the , subscript corresponds to the , center of the cell in the virtual environment, and the vector indices are ordered over time.
where ( ) is a function that computes a score relating the distance between a cell ì and an agent as follows: To account for air quality, the air exchanges conducted naturally and by the HVAC system, a secondary factor ℎ can be applied to decrease the score over time. ℎ is a factor from 0 to 1, based on the air exchange rate and time since the last simulation step, where no air exchange is 1 (the calculation does not change), to the ability to completely exchange the air instantly as 0. While this factor is motivated by research into pandemics, it is applicable to smell as well.
Next, an environment score ( ) is defined for each time as the mean of the cell scores.
With the above approach, a general SDI metric for graph can be determined, such that the environment is scored by the average of all ( ) at a given occupancy load .
However, the score of an environment should also consider the ability for the environment to maintain distancing at a rate that is at least the same, but preferably smaller, than the rate of the number of occupants. Therefore, we run the simulation with a varying number of agents over the time of the simulation, where the maximum number of agents at any time is defined by max .
In Figure 4a, the increase in occupants by increments of 10 increases the SDI proportionally. Intuitively, the more agents in the scene, the less distance can be maintained between them. Likewise, we show Figure 4b, with the top row showing agent positions and the bottom row showing the cell scores visualized as a heatmap (brighter is a higher SDI).
While Figure 4 demonstrates the impact of various parameters in the SDI, for the optimization experiments, we use a large enough maximum distance of 1000m which maintains influence of all agents, a minimum distance of 0.3m representing the radius of an agent, and an environment exchange factor ℎ of 1.

OPTIMIZATION FRAMEWORK
For each generation, after all the simulation sessions of a generation finish and all the corresponding SDI values are calculated, one optimizer step is taken to decide and a new generation of graphs is produced, starting the next round of simulation. The optimization is terminated when a fixed number of steps has been taken, or based on a calculated threshold. Figure 1 shows the symbols and notations used in this paper, and a complete pipeline is shown in Figure 2.

Optimization Formulation
Given the structural policy graph and a specified occupancy load parameter , the optimization problem is formulated as arg min where is an edge connecting nodes and in the structural graph , and ( | ) can be an arbitrary scoring metric that measures the performance of the graph, e.g., ( ) SDI( | ). ( ) is the set of all the strongly connected components of .
In other words, our optimization process minimizes the target function by changing the state of the edges, while maintaining the strong connectivity of the structural graph. As an NP-optimization (NPO) problem, this process is an NP-complete combinatorial optimization that requires probabilistic methods (e.g., simulated annealing) to approach the optimal.

Optimization Approach
Due to the NP complexity with regard to the number of nodes in the graph, we use a mixed approach by combining GA and SA to search for the optimal policy. Our GA-SA approach is based on a few definitions and assumptions.

Edit Distance.
Given two isomorphic structural graphs 1 and 2 , the edit distance ( 1 , 2 ) is defined as the total number of edge edits to make 1 and 2 identical. Formally, Given two isomorphic edges, the edit distance value ( , ′ ) is defined by Figure 5, which shows a total of 4 possible states of edges between nodes 1 and 2 : (i) 1 → 2 , (ii) 1 ↔ 2 , (iii) 1 2 , and (iv) 1 ← 2 . The solid lines mark 1 edit between states, while the broken lines mark 2 edits, e.g., the cost from state (i) to (ii) requires 1 edit, and that from state (i) to (iv) requires 2 edits.

Similarity Monotonicity.
We assume that graphs with greater similarity yield closer SDI values. Formally, given graphs , 1 , 2 and an arbitrary mapping function ( ) : → R, we have That said, given a graph and its corresponding score , we will get larger score difference if we apply more edge edits on . Note that we assume "greater similarity" is just sufficient to conclude "smaller difference, " so this assumption is not reversible: we don't assume that graphs are more similar due to smaller SDI difference.

Algorithms
Based on the formulation above, we propose this GA-SA method, described in the following algorithms. The pipeline of the optimization process is described in Algorithm 1 and Figure 2, and detailed implementation of some functions are expanded in Algorithm 2.
When starting the optimization process, we run the optimization process on the first generations of graphs. Starting from the -th Optimization iteration overview. We start with the initial graph 0 and produce a generation of size , then run the simulation with each child and get their corresponding SDI values. We pick the best child as the parent for the next generation with a probability, and terminate the optimization process when the SDI value doesn't change significantly.
generation ( ≥ + 1), we keep track of the mean value of the best SDI scores of the recent generations and that of the ( − 1)-th generation. When a generation is finished, we check if the value change is greater than a threshold and if so, the optimization process is considered ended. As is shown in Figure 3, the (·) function processes the structural graph with the following steps: (1) Inherit all the nodes in the structural graph to the navigational graph; (2) Populate navigation nodes between the structural nodes with proper information, i.e., coordinates and item tags; (3) Connect item nodes with joint nodes with edges complying to the policies defined in the corresponding structural graph. The navigational graphs are only used during the simulation and to calculate the scores of the graphs, and hence are discarded when the current iteration is over and will not be carried to the next generation.
The production function uses the GA method to generate new graphs in the next generation. In the (·) function, the state of the edge will mutate according to the transition relationship shown in Figure 5. There are four states that the edges connecting nodes 1 and 2 can mutate to, and the edge must mutate to one of the rest 3 states where it is not currently in.
When all the children from the current generation finish simulation and evaluation, all the SDI values are used by the optimizer to decide whether to accept the best-performed children as the parent for the next generation or reject it with a threshold and keep the original parent. The threshold decreases as the generation counter input : Base structural graph , Sibling count , Edit distance Randomly pick one edge ∈ increase. This process uses the concept of conditional acceptance in the SA approach, as is shown in line 12-13 of algorithm 1, to prevent the algorithm from falling into a local optimum.

EVALUATION AND CASE STUDY
We evaluate our framework with 2 sections: (i) quantitative and qualitative analysis of SDI, and (ii) simulation-optimization case studies: a simple one with the scoring metric basing on walking distance and another one using the SDI metric.

Distance-based Optimization
In this scenario, the policy optimization process is based on the total traveling distance of all the agents, i.e., the optimizer aims to minimize the traveling distance when optimizing the policies. We verify our optimizer with 2 cases: one without the simulation but the accumulated Euclidean distance by traversing all the items in the shopping list, while the other using live simulations to collect the actual translation data of the agent model traveling in the 3D environment.
The experiments are conducted as follows. To calculate the Euclidean distance without running the simulation, we generate a random shopping list with shopping items, then accumulate the path length from the entrance to the 1st item, then from the 1st item to the 2nd, etc., eventually from the ( − 1)-th item to the -th item. Similarly, for the simulation-based experiment, the path length is calculated by sampling the positions of the agents by each frame.
The results in Figure 6 show that the optimization approach we used can be applied to the traveling distance data collected via simulation. The shaded part of the optimization curve shows the range of traveling distance of all the children in the current generation. As is shown in the graph, starting from a directional policy (6a), both experiments reduce the total travel distance as the optimization proceeds. Both experiments show similar convergence rates, the variance of the simulation experiment is larger and the convergence speed is slower. A possible reason causing such variance is the simulation artifacts. The traveling distance is calculated by  Figure 6: 6a shows the initial policy graph with unidirectional edges for the optimization, 6c shows an optimal policy optimized for static distance (theoretical), 6e shows an optimal policy optimized for simulated distance, 6b shows the objective convergence for 6c, and 6d shows the objective convergence for 6e.
accumulating the translation of the agents by each frame, which is influenced by the position sampling interval, locomotion, and animation system. A higher sampling rate can help record the data with higher accuracy.

Virtual Retail Environment
We created a virtual grocery store that resembles a typical configuration of a grocery market with vertically aligned shelves and horizontal hallways. Based on a constant occupancy setting, we conducted a complete simulation-optimization experiment to search for the optimal policy for this scenario. The optimization starts with the graph that consists of no directional constraints, as is shown in Figure 7a. This is considered as the baseline case for a store environment: normally, all customers can move in the store freely in any direction. Apparently, this policy can potentially cause jamming and blockage, leading to a high SDI value.
During the simulation, the environment is initially empty, and the agents start entering and conduct their shopping behaviors by visiting each target item shown in their shopping lists. When the occupancy load is reached, no more agents are allowed to enter, until any agent in the scene finishes the checkout behavior and exits the scene. Figure 8 shows 3 typical states of one simulation session: agent entering, shopping, and exiting.
The experiment uses 1 edit distance to produce the children of every generation, and the size of each generation is 5. The window size is 20 and the stopping threshold is 10 −5 . We run the simulation for a simulated time of 30 seconds of each scenario to collect data for the SDI model, then the optimizer decides the graphs to use for the next iteration using the returned result of SDI. The optimization process finished in 93 generations. As is shown in Figure 7e, The results show that our optimization process reduced SDI by about 20%. Similar to 6c and 6b, the shaded area shows the range of the SDI values of all the children in a generation.

CONCLUSION
In this paper we demonstrate how a graph optimization technique can be used on navigation graphs, in combination with a standard agent simulator, to find a policy that enables the largest spacing between virtual occupants during a shopping sequence. The approach uses a combination of genetic algorithm and simulated annealing to change a directed navigational graph that virtual occupants follow, while a distance-based metric records regions of densities in the environment.
While we demonstrate a valid optimization through an intuitive and descriptive metric (distance traveled), the ability for the navigational policies to naturally influence occupant distances is more nuanced. Specifically, if the SDI is a properly weighted value, or how people would respond to such policies would be potential studies in future work to validate such approaches, for example through modifications to real buildings. Likewise, our simulation assumes some ideal conditions, such as agents strictly following the policies. Alternative behaviors could be implemented so that a probability of agents not following the policy may be useful. In future work, extending our framework with more robust agent-environment interaction could consider likely sources of disease spread, such as contaminated surfaces, requiring agents to physically interact with objects (e.g., picking up a box of cereal on a grocery shelf or opening the refrigerator door).
It is important to consider if the SDI, or any related work in the community, is meant as a method of tracking probabilities of infection rate, or instead taken more literally to be maintaining distance. While the work here is posed as an aid in the development of navigation policies for environments that have clear application to pandemic response, numerous issues at present limit this application in situ. Researches on social distancing measures aiding in preventing disease are often discussed in terms of pure isolation, or modeled in a way that assumes the number of people that have socially distanced are in fact not even in the same location (i.e., social distancing is treated as lockdown) [21]or are simply counting 'contacts' without reference to the distance or nature of it [38]. Likewise, researchers have emphasized the idea of social distancing set to 2 meters is outdated [17]. Therefore, simply recording the times two people are within that threshold may not be meaningful (i.e., recording 201 cm as safe and 199cm as dangerous). If the virus is transmitted in aerosols, interventions such as air quality control are required [19]. Therefore, our work is not specifically targeting recommendations for the reduction of disease, but rather  as a generalized model that could (1) optimize navigational policies for any metric and (2) a distance-based index that applies outside of pandemics as well.