S S symmetry

Article Crowd Simulation with Arrival Time Constraints

Mankyu Sung 1 and SeongKi Kim 2,*

1 Department of Game & Mobile, Keimyung University, Daegu 42601, Korea; [email protected] 2 Division of SW Convergence, Sangmyung University, Seoul 03016, Korea * Correspondence: [email protected]; Tel.: +82-2-2287-6157

 Received: 12 October 2020; Accepted: 29 October 2020; Published: 31 October 2020 

Abstract: Finding collision-free paths for crowd simulation has been a core technique in video games and the film industry; it has drawn a great deal of attention from computer researchers for several decades. Additionally, theoretical modeling of pedestrian has been a hot topic in physics as well because it allows us to predict any architectural failure of buildings and many city planning problems. However, the existing studies for path planning cannot guarantee the arrival order, which is critical in many cases, such as arrival symmetry of the characters within video games or films. To resolve this issue, a path planning algorithm has been developed with a novel method for satisfying the arrival-order constraints. The time constraint we suggest is the temporal duration for each character, specifying the order in which they arrive at their target positions. In addition to the algorithm that guarantees the arrival order of objects, a new user interface is suggested for setting up the arrival order. Through several experiments, the proposed algorithm was verified, and can successfully find collision-free paths, while satisfying the time constraint set by the new user interface. Given the available literature, the suggested algorithm and the interface are the first that support arrival order, and their usability is proven by user studies.

Keywords: ; crowd simulation; multi-agent simulation; time constraints

1. Introduction Crowd simulation has been one of the core techniques in many industries including entertainment, transportation and architecture for many years. Particularly, computer games and feature films have many scenes where numerous agents move together. To create those crowd scenes, we need a technique to obtain collision-free paths for each individual. Various approaches have been proposed till now, under the category of multi-agent path planning techniques. One of the most popular methods is the velocity obstacles (VO) method. It can predict where the other moving objects might be in the future within the pre-defined time duration by extrapolating their velocities; hence, collisions are avoided accordingly [1]. These methods formulate a set of collision regions in the velocity domain from all neighboring characters and static obstacles at each time frame and use an optimization technique to find an optimal velocity that is as close as possible to the preferred velocity and does not intersect with the collision region. This continuous optimal speed selection creates collision-free paths for every individual. Extensions of the original idea have been proposed, such as HRVO (hybrid reciprocal velocity obstacle) [2], ORCA (optimal reciprocal collision avoidance) [3], and AVO (acceleration velocity obstacle) [4], which have their own advantages and disadvantages. Because these methods can produce collision-free paths for many three-dimensional (3D) characters successfully, they have been integrated into current commercial game engines, such as Unity or Unreal. However, in many cases, collision-free paths alone do not suffice. If game designers or movie directors were able to control crowds so that they arrive at a particular position in a particular order, it would be possible to express various effects. For example, an entire crowd can be moved from

Symmetry 2020, 12, 1804; doi:10.3390/sym12111804 www.mdpi.com/journal/symmetry Symmetry 2020, 12, 1804 2 of 18 an initial position to a target position at the same time, and could be made to engage with enemies. However, none of the previous studies [2–4] consider these critical time constraints when simulating multi-agents. Instead, they are concerned with ensuring that no collisions occur while the agents move to their target positions. In this study, we try to obtain the collision-free paths for crowds, subject to arrival-time constraints. Since we assume that agents have zero knowledge about the environment, they do not know how long it takes to get to the intended position. Therefore, it is very difficult to set the absolute arrival time. Instead, our algorithm focuses on the relative time difference among the agents’ arrivals. This would give the arrival-order constraints over the crowds. For example, all agents could be made to arrive at their intended position simultaneously, or given an initial line formation, we can make them arrive at their target positions from left to right. As another example, we can make moving objects symmetrically arrive at the targeted positions at the video games, or the films. Furthermore, we can control the arrival times of drones to give more impressive effects to attendances. In summary, supporting the relative arrival times of objects to specific positions can further increase the controllability of objects. To solve the ordered arrival-time constraint, this study proposes algorithms featuring three main contributions. First, to meet the time constraints, we put a velocity-adjustment layer on top of the existing ORCA method. This layer adjusts the velocities of all agents so that they arrive at their target positions in a particular order. Whereas the original ORCA method has a fixed range of speed, the proposed method allows the maximum speed parameter to change, to meet the time constraints. Although the original ORCA algorithm creates collision-free paths for multiple agents, it cannot be used to control their relative arrival times. That is, it cannot control the order in which the agents arrive. However, the proposed methods not only produce the collision-free paths, but also satisfy the arrival-time constraints. Second, to find a set of waypoints for a highly complicated environment, a modified PRM (probabilistic roadmap) method is proposed, which can reduce the potential future collisions for multiple agents. The modification scatters the shared waypoints of multiple agents slightly so that the agents can have different waypoints; this has the effect of reducing future collisions. Third, a novel user interface is proposed for setting the time constraints. Usually, the timeline interface has been widely used for time-domain multimedia applications. However, it is not efficient for multi-agent simulation because a timeline must be given for each agent. If hundreds of agents are to be simulated, then the same number of timelines must be created, which is not easy to control. The novel interface instead integrates the time constraints with the environment. Specifically, it is assumed that the y-axis (up vector) of the environment is a time domain. When the target position of each agent is set up, another time point is allowed for setting their arrival time. The farther the point is from the ground, the later the agent arrives at the goal. A key point is that the time point does not represent the absolute time of arrival. Instead, the gap between two time points is of significance, as it represents the time difference between two arrival times. Through a series of experiments, it was verified that the proposed algorithm could exactly create paths for many agents satisfying diverse time constraints in real-time. Furthermore, a new user interface is proposed that can be used to set constraints around 30 percent faster than the timeline interface. The remainder of this paper is organized as follows: Section2 lists and overviews all the related work. Section3 illustrates the proposed algorithm in detail. In Section4, we show experimental results, including performance graphs. Finally, Section5 concludes the paper with discussion and future work. In this paper, the terms “crowds” and “multi-agents” are used interchangeably.

2. Related Work For the past few decades, crowd simulation has been one of the more active research areas in the computer animation research community, and many different approaches have been proposed [5]. Excellent module-based software architecture for pedestrians, including motion synthesis and path planning has also been proposed [6]. Crowd simulation techniques can be divided into two categories: Symmetry 2020, 12, 1804 3 of 18 macroscopic models and microscopic models [7–9]. Macroscopic models usually view the entire crowd as a single group and focus on the natural flow of crowd movement. Continuum crowds and aggregate dynamics [10] are two popular macroscopic crowd simulation models. As these approaches do not factor in individual behavior, detailed quality of motion in simulation is not their top priority. Recently, Karamouzas et al. analyzed a large corpus of real crowd data and found that interaction energy between two pedestrians follows a power law as a function of their projected time to collision [11]. Using this law, they were able to simulate a more realistic flow of movement, including the self-forming lane phenomena. They further proposed an implicit crowd simulation [12] method. This method was based on an energy-based formulation in a physics-based simulation. To update the agent’s position, they proposed an optimization-based integration scheme. In their formula, the entire crowd was considered to solve the optimization; this made it hard to implement the method for large crowds in real-time, although the overall movement of crowds was quite realistic. Conversely, microscopic models focus on individual behaviors and interactions between agents. The classical social force model and model [13,14] are two widely used models, for simulating flocks based on interactions between individuals. Another algorithm integrates the popular A* path planning with crowd density information so that agents could avoid high-density areas when they plan a path [15]. In [16], the algorithm applies PLE (principle of least effort), a general principle of crowds, to find a biomechanically energy-efficient collision-free trajectory by performing an optimization on the total amount of metabolic energy used when traveling to the goal. Some other methods have been proposed for multi-agent path planning to meet constraints. For example, the MAPF-POST (multi-agent path finding) algorithm suggested in [17] took into account kinematic constraints such as the maximum translational and rotational velocities of agents, and built a simple temporal network to post-process the output of an MAPF solver using artificial intelligence (AI) to create a plan-execution schedule. This method is similar to our proposed method, in that both methods targets creating collision-free paths for a multi-agent system, while satisfying constraints. However, the constraints in [17] include only kinematic constraints. The proposed study aims to solve the problem of temporal constraints, which gives more controllability to the agents. The proposed method solves the time constraint problem by augmenting a new functional layer that adjusts velocities to meet the given time constraints on the existing velocity-based models. Among the velocity-based models, ORCA (optimal reciprocal collision avoidance) has an advantage in obtaining a collision-free path for n-body moving objects [3]. In this formulation, each agent considers a neighboring moving object and constructs a half-plane defined in velocity space that is selected to guarantee collision avoidance. The agent then keeps selecting their optimal velocity from the intersection of all half-planes, which can be done efficiently using a simple optimization technique [3]. This method enables agents to avoid collisions while they are moving to their respective target positions. However, there are still some cases when they get stuck, and it takes time to extract themselves from the situation. In addition, the original ORCA method does not focus on how long it takes for agents to arrive at the target positions. Instead, it only emphasizes obtaining only collision-free paths. The proposed method modified the existing ORCA to satisfy time constraints. First, the algorithm checks the visibility to the current waypoint, all the time. If the waypoint is visible, it uses the time-constrained maximum speed parameter rather than the fixed one, which can expand the range of speeds, to support constrained arrival times. Second, once the ORCA decides the collision-free final velocity through the optimization process, the algorithm adjusts it automatically to meet the time duration constraints. Meanwhile, the robotics research community has been working on computing collision-free, feasible motion paths for an object from a given starting position to a given target, in a complicated workspace. To this end, the probabilistic roadmap (PRM) approach is a commonly used motion planning technique [18]. The core part of this approach is a sampling method that samples the configuration space of the moving objects. In a simple two-dimensional (2D) environment where agents are moving on a flat ground, the sampling involves obtaining a set of 2D points distributed in Symmetry 2020, 12, 1804 4 of 18 the environment that do not collide with static obstacles. Further, those 2D points are connected to generate a roadmap. The roadmap is then used as a set of waypoints to find a path. To find a path for the given initial and target points, the Dijkstra algorithm is applied on the roadmap [19]. One of the problems of the method is that it is not made for multi-agents. Although the method can produce a path in a highly complicated environment where a lot of obstacles exist, for a finite number of samples, if the initial and final positions of two agents are similar, then there is a high probability that these two agents keep colliding during the simulation. To solve this problem, a method is proposed to perturb waypoints in the paths so that the agents have slightly different waypoints in their respective paths; this can reduce the possibility of collision. In terms of setting time constraints, the timeline interface has been used for multimedia-related authoring tools [20]. In the timeline interface, a horizontal bar represents an event in the time domain. Users can put a marker on the bars, cut them out or concatenate them together. This is quite efficient for a simple time-related manipulation task. However, it is not efficient for crowd simulation, because a timeline must be created for each agent. As the number of individuals increases, the number of timelines must increase as well. In this paper, the timeline interface is integrated with the environment directly. Through this interface, users can conveniently set the time duration constraints interactively. In addition, users can use a grouping tool for setting time constraints to multiple agents at the same time.

3. Proposed Algorithms

3.1. Problem Statement The problem consists of path planning for N agents, with arrival time constraints between agent pairs. Each agent is assigned a target point, which is denoted as G R2, where 0 i N n o i ∈ ≤ ≤ and each G consists of a set of waypoints W R2 to get to the target G , where 0 j m. i j ∈ i ≤ ≤ The arrival-time constraints are represented as T R, and ∆T is the difference of adjacent two T and i ∈ i i their average Tˆ. Given these configurations, collision-free paths must be found for all agents such that for each agent, the difference between the actual arrival time and the estimated average arrival time, ∆A = Aˆ A matches ∆T . j − i i 3.2. Overview The simulation follows the steps illustrated in Figure1. In the pre-processing step within Figure1, given a set of static obstacles, the algorithm constructs a roadmap through the PRM planning method. At run time, the user first specifies the target position and time duration constraints for all agents. Then, the waypoints are obtained through a roadmap query to the PRM. The waypoints behave like sub-goals, as the agent moves to the target. The current waypoint is set to the starting waypoint in the beginning, and moves to the next waypoint as the agent passes by. The preferred velocity can be computed from the current waypoint and the agent’s position. Further, the visibility is checked to see if there are any obstacles up to the current waypoint. If there is no obstacle, then the maximum speed parameter is adjusted so that the agent can move through the current waypoint, while satisfying the time constraints. As illustrated in [3], given the preferred velocity and maximum speed parameter, the algorithm constructs a set of ORCA half-planes from neighboring agents and static obstacles, and applies linear programming to obtain the optimal velocity. At the final step, the optimal velocity is adjusted again to satisfy the time duration constraint. Once the final velocity is computed, an Euler integration is applied to update the agents’ positions. Symmetry 2020, 12, 1804 5 of 18 Symmetry 2020, 12, x FOR PEER REVIEW 5 of 18

Symmetry 2020, 12, x FOR PEER REVIEW 5 of 18

FigureFigure 1.1. AlgorithmAlgorithm Overview.Overview. Figure 1. Algorithm Overview. 3.3.3.3. Pre-ProcessingPre-Processing StepStep 3.3. Pre-Processing Step ThisThis sectionsection explainsexplains thethe roadmaproadmap constructionconstruction using using the the PRMPRM method.method. ToTo navigatenavigate throughthrough thethe highlyhighly complicated complicatedThis section environmentexplains environment the roadmap where where many construction many static static obstacles using obstacles the exist, PRM exist, the method. agents the agentsTo must navigate have must through a roughhave a picturethe rough highly complicated environment where many static obstacles exist, the agents must have a rough ofpicture the paths of the that paths they that move they along. move For along. this For purpose, this purpose, the algorithm the algorithm constructs constructs a roadmap a roadmap that guides that picture of the paths that they move along. For this purpose, the algorithm constructs a roadmap that agentsguides to agents the target to the positions. target positions. There are manyThere sophisticatedare many sophisticated high-level motionhigh-level planning motion algorithms planning guides agents to the target positions. There are many sophisticated high-level motion planning available in robotics research, including PRM, RRT (rapidly-exploring random tree), and others [18]. algorithmsalgorithms available available in in robotics robotics research, research, includinging PRM, PRM, RRT RRT (rapidly-exploring (rapidly-exploring random random tree), tree), and and Among them, we use the PRM owing to its simplicity in implementation. Figure2 shows an example othersothers [18]. [18]. Among Among them, them, we we use use the the PRMPRM owing to to its its simplicity simplicity in inimplementation. implementation. Figure Figure 2 shows 2 shows ofan a examplean roadmap example of constructed ofa roadmapa roadmap byconstructed constructed the PRM. byby the PRM.PRM.

FigureFigure 2. Roadmap 2. Roadmap constructed constructed by by the the PRM. PRM. TheThe red rectan rectanglesgles represent represent the the static static obstacles. obstacles. The Thered red circles are the initial positions whereas the blue circles are target positions. The yellow lines represent circlesFigure are 2. Roadmap the initial positionsconstructed whereas by the thePRM. blue The circles red rectan are targetgles positions.represent the The static yellow obstacles. lines represent The red the pathsthe paths obtained obtained from from the PRMthe PRM query. query. Note Note that that given given maximum maximum number number of connections,of connections, two two nearly circlesnearly are nodes the initial are connected positions as whereas an edge thewhen blue they circ arlese visible are target each other,positions. otherwise, The yellow the nodes lines are represent not nodes are connected as an edge when they are visible each other, otherwise, the nodes are not connected. the connected.paths obtained The nodes from are the sampled PRM inquery. the environment Note that togiven avoid maximum all static obstacles. number of connections, two Thenearly nodes nodes are are sampled connected in the as environment an edge when to avoidthey ar alle visible static obstacles. each other, otherwise, the nodes are not connected. The nodes are sampled in the environment to avoid all static obstacles.

Symmetry 2020, 12, 1804 6 of 18 Symmetry 2020, 12, x FOR PEER REVIEW 6 of 18 Symmetry 2020, 12, x FOR PEER REVIEW 6 of 18 One issueissue ofof the the original original PRM PRM is thatis that it does it does not supportnot support multiple multiple agents, agents, due to due which to which two agents two canagents sometimes Onecan sometimesissue have of the similar have original pathssimilar PRM if paths theiris that initialif ittheir does and initial not target support and positions target multiple positions are agents, not separatedare due not to separatedwhich far enough. two far agents can sometimes have similar paths if their initial and target positions are not separated far Toenough. solve thisTo solve problem, this theproblem, proposed the algorithmproposed randomlyalgorithmperturbs randomlythe perturbs path when the the path two when agents the share two enough. To solve this problem, the proposed algorithm randomly perturbs the path when the two theagents same share waypoint. the same Assume waypoint. that Assume there are that two there paths areP 1twoand pathsP2 as 𝑃 shown and in𝑃 Figure as shown3. In in Figure Figure3a, 3. agents share the same waypoint. Assume that there are two paths 𝑃 and 𝑃 as shown in Figure 3. itIn happens Figure 3a, that it happens both P1 andthatP both2 have 𝑃 theand same 𝑃 have waypoint the samewi. Inwaypoint this case, 𝑤 if . thoseIn this two case, agents if those have two a In Figure 3a, it happens that both 𝑃 and 𝑃 have the same waypoint 𝑤 . In this case, if those two similaragents have speed, a similar then there speed, is a then high there chance is thata high the chance two agents that the would two bumpagents intowould each bump other into at some each agents have a similar speed, then there is a high chance that the two agents would bump into each other at some point in time. To prevent this collision, the algorithm maintains an internal count pointother in time.at some To point prevent in time. this collision, To prevent the this algorithm collision, maintains the algorithm an internal maintains count an variable internal forcount each variable for each waypoint. If a certain path uses a waypoint, then the count variable increases its waypoint.variable Iffor a each certain waypoint. path uses If a a certain waypoint, path thenuses thea waypoint, count variable then the increases count variable its value. increases If another its pathvalue.value. lies If onanotherIf another the same path path waypoint, lies lies on on th thenthee same same instead waypoint,waypoint, of using then the originalinstead of waypoint,of usingusing the the the original original algorithm waypoint, waypoint, finds athe new the positionalgorithmalgorithm that finds finds is close a newa new to position the position original that that waypoint.is is close close to to theThethe originaloriginal new position waypoint. should The The not new new lie position position on any should static should obstacles not not lie lie andon onany should any static static be obstacles aobstacles within and a and threshold should should be distancebe a a within within range aa thresholdthreshold from the distance original range range waypoint. from from the the Figure original original3b explains waypoint. waypoint. the newFigureFigure position, 3b 3b explains explains perturbed the the ne ne fromww position, position, the original perturbed perturbed waypoint. fromfrom the original waypoint.waypoint.

FigureFigure 3. Left:3. Left: The The two two paths paths (p(𝐩1𝟏and andp 𝐩2)𝟐) have have a a commoncommon waypointwaypoint 𝐰w𝐢i.. Right: Right: The The waypoint waypoint 𝐰𝐢w isi is Figure 3. Left: The′ two paths (𝐩𝟏 and 𝐩𝟐) have a common waypoint 𝐰𝐢. Right: The waypoint 𝐰𝐢 is changedchanged to tow ′𝐰for𝐢 for the the second second path path for for a a given given range range parameterparameter r, so that that the the two two resulting resulting paths paths have have changed to 𝐰i0 for the second path for a given range parameter r, so that the two resulting paths have slightly different𝐢 waypoints. Note that the waypoints represented as circles are the part of PRM road slightlyslightly didifferentfferent waypoints.waypoints. Note that the waypoints represented as circles are thethe partpart of PRMPRM road maps. Additionally, the 𝐰′is a random point inside the circle center at 𝐰 with radius r. maps. Additionally, the w0′is𝐢 a random point inside the circle center at wi 𝐢 with radius r. maps. Additionally, the 𝐰i𝐢 is a random point inside the circle center at 𝐰𝐢 with radius r. 3.4.3.4. ORCA ORCA with with Modified Modified Preferred Preferred Velocity Velocity 3.4. ORCA with Modified Preferred Velocity TheThe velocity velocity obstacle obstacle (VO) (VO) is is defined defined asas aa setset ofof velocitiesvelocities that lead lead to to a a collision collision for for moving moving an an agentagentThea, a ifvelocity, theif the agent agent obstacle maintains maintains (VO) itsis its defined current current as velocityvelocity a set of forfor velocities aa shortshort thatperiod period lead [1], [1 to], given givena collision other other fordynamically dynamically moving an movingagentmoving a, agentsif agentsthe agent playing playing maintains the the role role its of of current moving moving velocity obstacles.obstacles. for In Ina shortgeneral, general, period VO VO is[1], is defined defined given inother in velocity velocity dynamically space. space. moving agents playing the role of moving obstacles. In general, VO is defined in velocity space. Specifically,Specifically, assume assume that thatVO 𝑉𝑂ais is a a VO VO induced induced byby agent aa. .Then, Then, VO VO is isconstructed constructed by bytranslating translating a aSpecifically, collisioncollision cone,cone, assume aa setset that ofof velocitiesvelocities𝑉𝑂 is a VOthat inducedlead lead to to a aby collision collision agent aeventually,.eventually, Then, VO given is given constructed the the velocity velocity by oftranslating ofagent agent a, aa, collision cone, 𝑣a set of velocities that lead to a collision eventually, given the velocity of agent a, denoteddenoted by byva. Figure. Figure4 illustrates 4 illustrates the the VO VO for for agent agent a given a given another another agent agentb. b Although. Although we we discuss discuss the methoddenotedthe method only by 𝑣 for only. Figure agent for a agent4given illustrates a anothergiven the another agent VO for bagent, the agent methodb, the a given method can another be can applied be agent applied to the b. to agentAlthough the bagentgiven we b agentgivendiscuss a, becausetheagent method thea, because methodonly for the isagent method reciprocal. a given is reciprocal. another agent b, the method can be applied to the agent b given agent a, because the method is reciprocal.

FigureFigure 4. Left:4. Left: Two Two agents agents (a (and𝒂 andb )𝒃 are) are at atp 𝒑and𝒂 andp ,𝒑 respectively.𝒃, respectively. Their Their current current velocities velocities are arev 𝒗and𝒂 a b a vb,and and 𝒗 their𝒃, and radii their are radiira areand 𝒓𝒂rb .and Middle: 𝒓𝒃. Middle: A velocity A velocity obstacle obstacle of agent of agenta ( aVO (𝑽𝑶a)𝒂 induced) induced by by agentagent b, Figure 4. Left: Two agents (𝒂 and 𝒃) are at 𝒑 and 𝒑 , respectively. Their current velocities are 𝒗 shownb, shown in velocity in velocity space. space. Right: Right: A reciprocal A reciprocal velocity𝒂 velocity obstacle𝒃 obstacle of of agent agenta a(RVO (𝑹𝑽𝑶a𝒂)) induced induced byby agentagent b𝒂, shownandb , 𝒗shown𝒃 in, and velocity in their velocity radii space. space. are 𝒓 𝒂 and 𝒓𝒃. Middle: A velocity obstacle of agent a (𝑽𝑶𝒂) induced by agent b, shown in velocity space. Right: A reciprocal velocity obstacle of agent a (𝑹𝑽𝑶𝒂) induced by agent b, shown in velocity space.

Symmetry 2020, 12, 1804 7 of 18

SymmetryTo avoid2020, 12 collision,, x FOR PEER the REVIEW agent should find a new optimal velocity outside VOa. The meaning7 of of18 optimal in our approach requires the input of a preferred velocity. The preferred velocity is a vector obtainedTo avoid by multiplying collision, the a speed agent parameter should find with a new a direction optimal vector. velocity The outside direction VO vectora. The meaning is defined of a optimalunit vector in our from approach the agent’s requires position th toe input the current of a preferred waypoint. velocity. The optimal The preferred velocity must velocity then is be a chosenvector obtainedto stay outside by multiplying of VOa and a speed to be asparameter close to the with preferred a direction velocity vector. as possible.The direction In our vector approach, is defined rather a unitthan vector using fixedfrom maximum the agent’s speed positionSmax, itto isthe allowed current change, waypoint. depending The optimal on the visibility. velocity Thismust approach then be chosenmakes theto stay agent outside arrive of at 𝑉𝑂 thewaypoint and to be a as little close early, to the which preferred gives velocity some extra as possible. time to adjust In our the approach, velocity ratherto meet than the using time constraint. fixed maximum speed 𝑆, it is allowed change, depending on the visibility. This approachThe visibility makes the check agent decides arrive ifat there the waypoint are obstacles a little to theearly, current which waypoint. gives some Clearly, extra time all waypoints to adjust theare velocity sampled to so meet that the they time are constraint. not inside static obstacles. Therefore, the visibility checking here only accountsThe visibility for other check moving decides agents if inthere the are straight obstacles line to the current waypoint. waypoint assumingClearly, all that waypoints current waypointare sampled is visibleso that from they theare currentnot inside agent static unless obstac thereles. are Therefore, other agents the visibility in between. checking Mathematically, here only accountsassume that for weother have moving agent aagentsat the in position the straightpa and li theirne to currentthe current waypoint waypoint is wi. assuming Then, if the that distance currentd, waypointthe length is of visible the perpendicular from the current vector agent to w unlesspa as indicatedthere are other in Figure agents5, is in smaller between. than Mathematically, the agent’s size i − assumera, it shows that that we thehave waypoint agent 𝒂w iatis the not position visible from 𝑝 andpa. Otherwise, their current the waypoint agent can gois 𝑤 to . the Then, waypoint if the distancedirectly. The𝑑, the distances length ofd andthe perpendicularl are calculated vector by following to 𝑤 −𝑝 Equations as indicated (1) and in (2):Figure 5, is smaller than the agent’s size 𝑟 , it shows that the waypoint 𝑤 is not visible from 𝑝 . Otherwise, the agent can go r to the waypoint directly. The distances 𝑑 and 𝑙 are calculated2 by following Equations (1) and (2): 2 d = −−−−→pbpa l (1) k k − 𝑑=‖𝑝𝑝⃗‖ −𝑙 (1) w𝑤i −𝑝pa = 𝑙=𝑝l −−−→pb𝑝p⃗a ∙ − (2)(2) · ‖w𝑤 −𝑝pa ‖ k i− k

a b w Figure 5. Given two two agents agents a andand b,, the the visibility visibility checks checks whether whether the the current current waypoint waypoint 𝒘𝒊i is visible to the the agent agent a.a This. This means means that that there there should should be no be other no otheragents agents (for example, (for example, agent b) agent in sight,b) towards in sight, thetowards waypoint. the waypoint.

Depending on the visibility, thethe preferredpreferred velocityvelocity cancan bebe calculatedcalculated asas follows:follows:

∗ 𝑤wi −𝑝pa 𝑆S∗max − : i f: visible𝑖𝑓 𝑣𝑖𝑠𝑖𝑏𝑙𝑒 pre f  wi pa v = ‖k𝑤−−𝑝k ‖ (3) 𝑣 a =  wi pa Smax 𝑤 −−𝑝 : i f not visible (3) wi pa 𝑆 k − k : 𝑖𝑓 𝑛𝑜𝑡 𝑣𝑖𝑠𝑖𝑏𝑙𝑒 ‖𝑤 −𝑝‖ = where wi is the current waypoint, pa is the current position of agent a and S∗max Smax∗ l k. Smax∗ is the where 𝑤 is the current waypoint, 𝑝 is the current position of agent 𝒂 and 𝑆 ∗ ∗ =𝑆 ∗𝑙∗ modified maximum speed of the agent, which is a scalar value, where Smax is the original maximum 𝑘. 𝑆∗ is the modified maximum speed of the agent, which is a scalar value, where 𝑆 is the speed parameter and k is the distance constant value, which works as a control parameter on how original maximum speed parameter and 𝑘 is the distance constant value, which works as a control parameterimminent theon collisionshow imminent are. The the scalarcollisionsl represents are. The the scalar length 𝑙 represents of the projection the length of the of vectorthe projection−−−→pbpa on of to the vector −−−→w𝑝ip𝑝a⃗. Theon to value the vector of k controls 𝑤𝑝⃗. The the value magnitude of 𝑘 controlsof Smax. the magnitude of 𝑆. Then, the optimal velocity 𝑣 can be defined as follows:

𝑣 =𝐚𝐫𝐠𝐦𝐢𝐧𝑣−𝑣 (4) where 𝑣 ∈ 𝑣∈R |‖𝑣‖ 𝑆,𝑣 ∉𝑉𝑂}.

Symmetry 2020, 12, 1804 8 of 18

opt Then, the optimal velocity va can be defined as follows:

opt pre f v = argmin v v a n a o 2 k − k (4) Symmetry 2020, 12, x FOR PEER REVIEWwhere v v R v < Smax, v < VOa . 8 of 18 ∈ ∈ k k

ToTo choosechoose anan optimaloptimal velocity,velocity, itit mustmust bebe outsideoutside ofof thethe VO𝑉𝑂a andand bebe asas closeclose toto thethe preferredpreferred velocityvelocity as as possible. possible. The The optimal optimal velocity velocity can be can found be throughfound through a mathematical a mathematical optimization optimization technique suchtechnique as a linear such programmingas a linear programming [1]. [1]. TheThe problemproblem ofof thethe originaloriginal VOVO isis thatthat sometimessometimes oscillationsoscillations maymay occuroccur duringduring simulationsimulation becausebecause therethere isis nono guaranteeguarantee thatthat thethe desireddesired velocityvelocity chosenchosen byby thethe agentagenta alies lies outsideoutside thethe VOVO whenwhen anotheranother agentagent chooseschooses theirtheir velocityvelocity simultaneously.simultaneously. To fixfix thisthis issue,issue, thethe algorithmalgorithm isis upgradedupgraded soso thatthat eacheach agentagent takestakes halfhalf ofof thethe responsibilityresponsibility ofof avoidingavoiding collision.collision. ItIt isis calledcalled thethe RVORVO (reciprocal(reciprocal velocityvelocity obstacle). obstacle). To To implement implement the the RVO RVO efficiently efficiently while while minimizing minimizing unnatural unnatural movement, movement, the ORCA the algorithmORCA algorithm was proposed was proposed [3]. The [3]. ORCA The ORCA argues argues that the that velocity the velocity obstacles, obstacles, along withalong the with so-called the so- half-planecalled half-plane that contains that contains a set of collision-freea set of collisio velocities,n-free velocities, generate generate smooth trajectories. smooth trajectories. Let va represent Let 𝑣 therepresent current the velocity. current In ORCA, velocity. a new In parameterORCA, a callednew parameter the finite time called horizon the τfiniteis introduced. time horizon The finite𝜏 is timeintroduced. horizon Theτ is thefinite period time that horizon guarantees 𝜏 is the collision-free period that movement, guarantees which collision-free means that movement, future collisions which 𝜏 𝜏 τ 𝑉𝑂 𝑉𝑂 aremeans ignored that beyondfuture τcollisions. With τ, theare VOignoreda is often beyond truncated . With into VO, thea , which is would often reshapetruncated the into collision , 𝑞 τ conewhich (to would be rounder). reshape Let theq becollision the nearest cone point(to be onrounder). the border Let of VO be athe, u benearest the vector point connecting on the borderq and of 𝑉𝑂 𝑢 𝑞 𝑣 𝑛τ 𝑞 𝑉𝑂 va, and , n bebe the the outwardvector connecting normal vector and of q and, andVO a .be Then, the qoutwardcan be calculated normal vector as follows: of and . Then, 𝑞 can be calculated as follows:

𝑞=𝐚𝐫𝐠𝐦𝐢𝐧q = argmin‖𝑢−𝑣u ‖v a τ k − k (5) (5) where v <VOa , u = q va where 𝑣 ∉ 𝑉𝑂 ,𝑢 =𝑞−𝑣 − ToTo calculatecalculate thethe optimaloptimal vectorvector forfor nn neighboringneighboring agents,agents, ORCAORCA definesdefines thethe half-planehalf-plane asas aa planeplane 1 τ perpendicularperpendicular to ton at𝑛 theat the point pointva + 𝑣2 u+. Figure𝑢. Figure6 shows 6 shows the ORCA the ORCA and the and truncated the truncatedVOa . More 𝑉𝑂 details. More ondetails ORCA on algorithmORCA algorithm can be found can be in found [3]. in [3].

Figure 6. Two agents a and b are at the positions 𝒑 and 𝒑 , respectively. Their current velocities are Figure 6. Two agents a and b are at the positions pa𝒂and pa𝒂, respectively. Their current velocities are τ 𝝉 v𝒗a𝒂and andv b𝒗,𝒃 and, and their their radii radii are arera 𝒓and𝒂 andrb. For𝒓𝒃. For time time horizon horizonτ, the 𝝉, VOthe a𝑽𝑶of𝒂 agent of agenta induced a induced by agent by agentb is theb is truncatedthe truncated cone cone (gray (gray cone), cone), inthe in the velocity velocity space. space. Then, Then, ORCA, ORCA, which which is is built built by by augmenting augmenting τ𝝉 VO𝑽𝑶a𝒂 with withan anadditional additionallinear linearconstraint, constraint, providesprovides aa half-planehalf-plane ofof velocityvelocity ofof collisions,collisions, oscillations,oscillations, andand reciprocalreciprocal dancesdances [[1].1].

3.5.3.5. AdjustmentAdjustment ofof VelocityVelocity forfor TimeTime ConstraintsConstraints GivenGiven arrival-timearrival-time constraints, constraints, the the velocity velocity of the of agent the mustagent be must adjusted be toadjusted satisfy theto constraints.satisfy the First,constraints. the algorithm First, the calculates algorithm the calculates arrival-time the arrival- to thetime target to ofthe each target agent. of each To calculateagent. To it,calculate the total it, lengththe total of length the path of forthe apath given for set a ofgiven waypoints set of wa isypoints needed. is For needed. this, theFor distancesthis, the distances between adjacentbetween

adjacent waypoints are summed. Assume that the set of waypoints for agent a is 𝑤}. Then the total length of the path, 𝐷, can be calculated as follows:

𝐷 = ‖𝑤 −𝑤‖ (5)

Since the 𝐷 does not take collision avoidance into account, the actual trajectory that the agent moves along may be different from this path. Assuming that the agent a maintains its current

Symmetry 2020, 12, 1804 9 of 18 waypoints are summed. Assume that the set of waypoints for agent a is w . Then the total length of { i} the path, Da, can be calculated as follows: X Da = wi wi 1 (6) k − − k

Since the Da does not take collision avoidance into account, the actual trajectory that the agent moves along may be different from this path. Assuming that the agent a maintains its current velocity, and that Da is the total length of the path it traverses, the estimated arrival time Aa can be calculated as follows: Da Aa = , (7) ( va + ε) k k where va is the current velocity, and ε is the smallest floating point value to prevent division by zero. Since Aa is estimated at every time frame, ε is required, as sometimes the agent may not move during the simulation, which generates a zero velocity. Given the estimated value Aa for agent a, the velocity can be recalculated for given time constraints Ta. The time constraint Ta R, is a scalar ∈ value that indicates the arrival time of agent a. The key point to note is that Ta does not mean the absolute time at which the agent a arrives at the target. In the proposed simulation, the difference of this value with time constraints of other agents is of more importance. Mathematically, assume that there is a set of constraints T where 0 i n. For example, T is the time constraint for agent 0, T is i ≤ ≤ 0 1 the time constraint for agent 1, and so on. Succinctly, the value of Ti is meaningful only when it is compared with some other Tj. That is, if Ti is smaller than Tj, agent i arrives at its target position faster than agent j. The extent by which the agent i arrives before agent j depends on the difference between Ti and Tj. For example, let three agents and their Ti be 0.1, 0.5, and 0.3, respectively. Then, the order of arrival is the first, the third, and the second. The difference between two Ti is the difference in arrival times. By changing values, the arrival time can be controlled. For instance, if Ti is the same for all agents, they must arrive at their targets simultaneously. For the three-agent example above, the suggested algorithm does not distinguish between the cases when all Ti are 0.1, or when all Ti are 0.2. To adjust the speed of agents based on Ti, a standard arrival-time is needed. In this approach, the standard arrival time is set as the average of Ti, denoted as Tˆ. Controlling the speed of particular agents, now depends on the difference between Ti and Tˆ. Similarly, the algorithm calculates the average arrival time, Aˆ, for all agents:

1 X Aˆ = A (8) n i ˆ ˆ Given A and T, the adjusted velocity vi0 can be calculated for agent i by:

(Aˆ min(∆ti, ∆tmax)) + Ai vi0 = − vˆi (9) Di where ∆t = Tˆ T , ∆tmax is the allowable maximum ∆t, and vˆ is the normalized velocity. i − i i In the proposed algorithm, velocity is allowed to change only when the current waypoint is visible. This basic strategy is to make each agent adjust their speed as often as possible whenever the current waypoint is visible. The maximum ∆tmax is set so that ∆ti cannot be larger than a threshold, which is needed to prevent an unnecessarily large arrival-time difference.

3.6. User Interface for Setting Time Constraints To set a time constraint for a specific agent, an efficient user interface is needed. The timeline interface has been used for multimedia applications that require time-domain data. However, it is not easy to apply it for crowd simulations, where a lot of agents move together. If a timeline is to be put for each agent, the number of timelines can be too many, which needs a lot of scrolling for a given fixed window size. In the proposed approach, a simple interface is designed, integrated with the Symmetry 2020, 12, 1804 10 of 18 environment directly. Figure7 shows the user interface. It is assumed that the y-axis (up vector) of the environment is the time domain. Then, the target points are duplicated into so-called time points, and each time point is allowed to move along the y-axis. The farther the time point is from the ground, the longer the corresponding agent takes to arrive. By changing this target position on the y-axis, the order of arrivals can be controlled. Simply selecting with a mouse and dragging enable control over the time points. Group selection can also be allowed so that multiple constraints can be moved up Symmetry 2020, 12, x FOR PEER REVIEW 10 of 18 and down at the same time.

Symmetry 2020, 12, x FOR PEER REVIEW 10 of 18

FigureFigure 7. Proposed 7. Proposed user user interface interface for timefor time constraints: constraints: the the user user can can control control the the time time points points (green (green circles) to changecircles) their to change time (y)their coordinates. time (y) coordinates.

4. Experiments4. Experiments

A crowdA crowd simulation simulation system system was was built built onon MicrosoftMicrosoft Windows Windows 10. 10. The The hardware hardware specifications specifications includedincluded the following:theFigure following: 7. Proposed a singlea single user interface Intel Intel i7 i7for CPU CPUtime constraints: with a a 16 16the GBuser GB maincan main control memory. memory. the time The points The graphics (green graphics card cardwas was circles) to change their time (y) coordinates. NVidia’sNVidia’s GeForce GeForce GTX GTX 1060. 1060. OpenGL OpenGL was was usedused for 3D . rendering. The The library library for forthe original the original ORCA ORCA algorithm was provided by [17]. For all the experiments in this section, the number of samples of the algorithm was4. Experiment provideds by [17]. For all the experiments in this section, the number of samples of the PRM planning was set to 1000, the perturbation value of r was set to 1.0, and the distance constant k PRM planning wasA crowd set simulation to 1000, thesystem perturbation was built on Microsoft value ofWindows r was 10. set The to hardware 1.0, and specifications the distance constant for calculating 𝑆∗ in Equation (3) was set to 5.0. For the ORCA, the maximum speed 𝑆 was included the following: a single Intel i7 CPU with a 16 GB main memory. The graphics card was k for calculating S∗max in Equation (3) was set to 5.0. For the ORCA, the maximum speed Smax was set to 2.0NVidia’s and the GeForce agent’s GTX size, 1060. 𝑟 OpenGL was heuristically was used for 3Dset rendering. to 0.5. For The fast library neighbor for the original searching, ORCA a simple set togrid-bin 2.0 and algorithmmethod the agent’s was provided used size, on byr ia [was 17KD]. For (K-dimension) heuristically all the experiments tree set in tostructure. this 0.5. section, For To the fast increase number neighbor ofthe samples understandability searching, of the a simple grid-binof the method figuresPRM planning wasin this used section,was set on to aa 1000, KDresult the (K-dimension) video perturbation was created. value tree of rPlease structure.was set refer to 1.0, Toto and the increase the accompanying distance the constant understandability video k and ∗ of thesupplementary figuresfor in ca thislculating material section, 푆 푚푎푥 at ainonlin result Equatione https://youtu.be/qu_sxFoRhdg. video (3) was was set to created. 5.0. For the Please ORCA, refer the maximum to the accompanyingspeed 푆푚푎푥 was video and set to 2.0 and the agent’s size, 푟 was heuristically set to 0.5. For fast neighbor searching, a simple Figure 8 shows the simulation 푖result for 10 agents. In the first scenario, the simulation without Supplementarygrid- Materialsbin method was at onlineused on https:a KD (K//-youtu.bedimension) /treequ_sxFoRhdg structure. To increase. the understandability Figuretime constraints8 ofshows the figures theis compared simulationin this section, with resulta result the foronevideo 10 with was agents. created.time Inconstraints. Please the firstrefer scenario,to The the accompanyininitial the positions simulationg video of and agents without are time constraintsarranged issupplementary comparedvertically. with materialThe thetime at oneonline constraints with https://youtu.be/qu_sxFoRhdg. time are constraints. set such Thethat initialall agents positions arrive of at agents their aretargets arranged Figure 8 shows the simulation result for 10 agents. In the first scenario, the simulation without vertically.simultaneously. The time If constraintsthe time constr areaints set were such not that set, all all agents agents arrivewould atmake their their targets way to simultaneously. the target independently.time constraints However, is compared when withthe thetime one constraintwith time constraints.s are set, The the initial agents positi onsadjust of agents their are velocities If the time constraintsarranged vertically. were The not time set, constraints all agents are would set such make that all their agents way arrive to the at their target targets independently. considering all other agents, and finally arrive at the targets at the same time. Fast-moving agents However, whensimultaneously. the time Ifconstraints the time constraints areset, were the not agentsset, all agents adjust would their make velocities their way to considering the target all other decreaseindependently. their speed, and However, slow-moving when the agents time const increaseraints aretheir set, speed. the agents The adjusttotal amount their velocities of time taken agents,to reach and finallyconsideringtheir targets arrive all isother similar at theagents, targetsin andboth finally cases at the arrive (13 same andat the 12 time. targets s, respectively). Fast-movingat the same time. agents Fast-moving decrease agents their speed, and slow-movingdecrease agents their speed, increase and slow their-moving speed. agents The increase total their amount speed. ofThe time total amount taken toof time reach taken their targets is similar in bothto rea casesch their (13 targets and is 12 similar s, respectively). in both cases (13 and 12 s, respectively).

1 2 1 2

33 4 4

5 6

5 6 (a) Figure(a 8.) Cont.

Symmetry 2020, 12, x FOR PEER REVIEW 11 of 18

Symmetry 2020, 12, 1804 11 of 18 Symmetry 2020, 12, x FOR PEER REVIEW 11 of 18

1 2

1 2

3 4

3 4

55 6 6

(b)) Figure 8. LineFigure formation 8. Line formation scenario: scenario: (a) Simulation(a) Simulation without time time constraints constraints (b) Simulation (b) Simulation with time with time Figure 8. Lineconstraints formation (all agents scenario: arrive at(a )their Simulation targets at th withoute same time) time (Refer constraints to the video). (b )Note Simulation that all with time constraints (allsequences agents are from arrive left to at right theirtheir in each targetstargets row, and atat thethenthe from samesame top time) time)to bottom (Refer(Refer to the tonextto the therow. video). video). Note that all sequences are fromfrom leftleft toto rightright inin eacheach row,row, andand thenthen fromfrom toptop toto bottombottom toto thethe nextnext row. row. Figure 9 shows the proposed user interface for time constraints integrated with the environment. Figure9 Usersshows can theadjust proposed the relative user time gap interface between fortwo timeagents constraints by moving the integrated time points up with and down, the environment. Figure 9i.e., shows by conveniently the proposed dragging user the interfacemouse. In this for scenario,time constraints agents were integratedrequired to arrive with at the their environment. Users can adjusttarget thepositions relative in the timeleft-to-right gap order. between The simulation two agents result by shows moving that the the constraints time pointsare exactly up and down, i.e., by convenientlysatisfied. The dragging total simulation the mouse. time was In around this scenario, 14 s. The time agents difference were between required the first to arrive and last at their target i.e., by convenientlyarrivals was dragging around 6 s. Thethe value mouse. of ∆𝑡 betweenIn this two scenario, adjacent timeagents constraints were was required 1.5–2.0 s. to arrive at their positionstarget positions in theleft-to-right in the left-to-right order. The order. simulation The simulation result shows result that shows the constraintsthat the constraints are exactly are satisfied. exactly Thesatisfied. total simulationThe total simulation time was aroundtime was 14 s.around The time 14 s. di Thefference time between difference the between first and the last first arrivals and waslast aroundarrivals 6was s. The around value 6 ofs. The∆t between value of two ∆𝑡 adjacent between timetwo adjacent constraints time was constraints 1.5–2.0 s. was 1.5–2.0 s.

1 2

3 4 1 2

5 6

3 4

5 6

Figure 9. Linear shape ordered scenario: Top: Blue points represent the time constraints set in the user interface. All other pictures show the simulation over time (refer to the video). Note that the sequences are from left to right in each row, and then from top to bottom to the next row. Symmetry 2020, 12, x FOR PEER REVIEW 12 of 18

Figure 9. Linear shape ordered scenario: Top: Blue points represent the time constraints set in the user Symmetryinterface.2020, 12 All, 1804 other pictures show the simulation over time (refer to the video). Note that the sequences12 of 18 are from left to right in each row, and then from top to bottom to the next row.

Figure 10 shows another simulation example, wh whereere all agents formed a circle at the beginning and tried to get to the opposite target positions. Th Thee time constraints were set to make them arrive at the targets simultaneously, whichwhich isis aa harshharsh condition,condition, asas therethere isis heavy tratrafficffic at the center. The result shows that all agents were able to solve the situatio situation,n, and eventually maneuver to their targets at the same time. The total simulation time was around 24 s, which took longer than other scenarios due to the heavy tratrafficffic in the middle.middle.

1 2

3 4

5 6

Figure 10. CircleCircle formation formation scenario: An An example example of of circle circle formation-agents formation-agents are in a circular circular formation in the beginning, and their target positions areare setset oppositeopposite to the circle (Refer(Refer toto the video). Note that the sequences are from leftleft toto rightright in each row,row, andand thenthen fromfrom toptop toto bottombottom toto thethe nextnext row.row.

Figure 11 shows the scenario where the environmentenvironment hashas staticstatic obstacles.obstacles. The algorithm applies the modifiedmodified PRM to obtain the waypoints for each agent. The arrival order was set in an arch and symmetry style so that agents gradually arrive at theirtheir targets, from thethe center toto both ends. The result shows that the agents avoided all all ob obstaclesstacles and and made made their their way way to to their their targets targets in in a a specific specific order. order. The totaltotal simulation simulation time time was was around around 14 s. 14 In s. addition, In addition, to test theto test scalability the scalability of the proposed of the algorithm,proposed italgorithm, was tested it withwas moretested agents with more and in agents more complicatedand in more environments. complicated environments. Figure 12 shows Figure the simulation 12 shows resultthe simulation of 30 agents result in of the 30 environment agents in the with environm relativelyent with more relatively obstacles. more To make obstacles. the scenario To make more the complex,scenario more all agents complex, were all required agents to were arrive required at their to target arrive positions at their simultaneously.target positions The simultaneously. result shows thatThe result the proposed shows that algorithm the proposed satisfies algorithm the arrival-time satisfie constraintss the arrival-time for all constraints the agents. for all the agents.

Symmetry 2020, 12, 1804 13 of 18

Symmetry 20202020,, 1212,, xx FORFOR PEERPEER REVIEWREVIEW 1313 of of 18

1 2

3 4

5 6

Figure 11. Arch-shapeArch-shape ordered scenario: a complex envienvironment ronment example-redexample -red blocks represent fixedfixed obstacles. Yellow lineslines indicate indicate the the connection connection of of waypoints waypoints for for each each agent. agent. The The time time constraints constraints are are set inset a in way a way that that all agentsall agents can can arrive arrive at the at the target target positions positions in a in specific a specific order order (refer (refer(refer to the to video).the video).

1 2 3 4 Figure 12. Complex environment example where 30 agents are moving to arrive at their target Figurepositions 12. (referComplex to the environment video). example where 30 agents are moving to arrive at their target positions (referFigure to 12. the Complex video). environment example where 30 agents are moving to arrive at their target Figurepositions 13 ( refershows to thehow video). the algorithm makes the agents satisfy the arrival-time constraints. The x- axis representsFigure 13 shows the particular how the algorithm agents and makes y-axis the indicates agents satisfy the time the arrival-timedomain. The constraints. time constraint The x-axis and representsthe actualFigure arrival the 13 shows particular times how are agents the put algorithm in and they-axis same makes time indicates the domain agents the together time satisfy domain. thefor arrivalcomparison, The- timetime constraintconstraints. although andthe The two the x- actualareaxis conceptually represents arrival times the different. particular are put The in agents the value same and of time timey-axis domain cons indicatestraints together theshown time for comparison, indomain. blue lines Thealthough indicatetime constraint they, the two time and are conceptuallypointsthe actual of the arrival dienvironment,fferent. times The are valueputand in orange of the time same lines constraints time indicate domain shown absolute together in blue arrival for lines comparison, times. indicate Asy, can thealthough be time seen points the in twothe of thefigure,are environment, conceptually the two lines and different. have orange almost The lines value identical indicate of time absoluteshapes, constraints meaning arrival times. shown that Asthe in can agents’ blue be lines seen arrival inindicate the times figure, y,satisfy the the time twothe linesconstraints.points have of the almost environment, identical shapes, and orange meaning lines that indicate the agents’ absolute arrival arrival times times. satisfy As the can constraints. be seen in the figure,The the graph two lines in Figure have a14lmost represents identical the shapes, performance. meaning Onthat the the same agents’ complicated arrival times environment satisfy the asconstraints. in the final scenario, the number of agents were increased from 5 to 100 and the frame rate was checked. The result shows that the proposed algorithm has linear performance as the number of agents is increased, and maintains a stable real-time performance. Even when the number of agents was increased to 100, the framerate did not go below 40 frames/s, which substantiates the real-time performance. Note that the framerate takes the simulation and rendering times into account.

Symmetry 2020, 12, x FOR PEER REVIEW 14 of 18

Symmetry 2020, 12, 1804 14 of 18 Symmetry 2020, 12, x FOR PEER REVIEW 14 of 18

Figure 13. Orange lines indicate the time constraints for 10 agents. Blue lines show the arrival time of the agents. Note that the two lines must have the same shape to meet the constraints.

The graph in Figure 14 represents the performance. On the same complicated environment as in the final scenario, the number of agents were increased from 5 to 100 and the frame rate was checked. The result shows that the proposed algorithm has linear performance as the number of agents is increased, and maintains a stable real-time performance. Even when the number of agents was increased to 100, the framerate did not go below 40 frames/s, which substantiates the real-time Figure 13. Orange lines indicate the time constraints for 10 agents. Blue lines show the arrival time of performance.Figure 13. NoteOrange that lines the indicate framerate the time takes constraints the simulation for 10 agents. and rendering Blue lines timesshow theinto arrival account. time of the agents. Note that the two lines must have the same shape to meet the constraints.

The graph in Figure 14 represents the performance. On the same complicated environment as in the final scenario, the number of agents were increased from 5 to 100 and the frame rate was checked. The result shows that the proposed algorithm has linear performance as the number of agents is increased, and maintains a stable real-time performance. Even when the number of agents was increased to 100, the framerate did not go below 40 frames/s, which substantiates the real-time performance. Note that the framerate takes the simulation and rendering times into account.

Figure 14. Simulation performance. In summary, the proposed algorithm was tested in several scenarios. Given a set of targets, In summary, the proposed algorithm was tested in several scenarios. Given a set of targets, the the targets were specified to the agents randomly. This setting generates a different result for each targets were specified to the agents randomly. This setting generates a different result for each simulation. It was found that the simulation time ranges between 10–20 s, when the Euclidean distance simulation. It was found that the simulation time ranges between 10–20 s, when the Euclidean between agent and target is around 10 units. During the simulation, no collisions were observed distance between agent and target is around 10 units. During the simulation, no collisions were between the agents. This demonstrates that the proposed algorithm is reliable and has a stable observed between the agents. This demonstrates that the proposed algorithm is reliable and has a real-time performance. stable real-time performance. Since the suggested algorithm is the first for path planning with time constraints, it was compared Since the suggested algorithmFigure is the14. Simulationfirst for paperformance.th planning with time constraints, it was with the A* path planning algorithm in Table1, in terms of the total amount of time taken for compared with the A * path planning algorithm in Table 1, in terms of the total amount of time taken construction. The amount of time includes the pre-processing steps, in both cases. More details on the for construction.In summary, The the amountproposed of algorithm time includes was testedthe pr e-processingin several scenarios. steps, in Given both cases.a set of More targets, details the A* algorithm and its efficiency can be found in [21,22]. ontargets the A* were algorithm specified and to its the efficiency agents canrandomly. be found This in [21,22]. setting generates a different result for each simulation. It was found that the simulation time ranges between 10–20 s, when the Euclidean Table 1. Comparison between the proposed modified PRM and the A* algorithm in terms of distance between agent and target is around 10 units. During the simulation, no collisions were construction time. observed between the agents. This demonstrates that the proposed algorithm is reliable and has a stable real-time performance. Modified PRM A* Since the suggested algorithmTime is the first 1.2 for s path planning 3.2 s with time constraints, it was compared with the A * path planning algorithm in Table 1, in terms of the total amount of time taken for construction. The amount of time includes the pre-processing steps, in both cases. More details on the A* algorithm and its efficiency can be found in [21,22].

Symmetry 2020, 12, x FOR PEER REVIEW 15 of 18

Table 1. Comparison between the proposed modified PRM and the A* algorithm in terms of construction time.

Symmetry 2020, 12, 1804 Modified PRM A* 15 of 18 Time 1.2 s 3.2 s

To thisthis end,end, 3000 3000 samples samples were were used used for thefor PRMthe PRM and aand grid a size grid of 0.1size was of set0.1 inwas the set A* algorithm,in the A* in the environment of size 1000 1000 units. The result shows that the modified PRM is 2.6 times algorithm, in the environment of× size 1000 × 1000 units. The result shows that the modified PRM is 2.6faster times than faster the A* than algorithm, the A* even algorithm, while supporting even wh theile supporting time constraint the thattime the constraint A* algorithm that does the not.A* algorithmThe speculation does behindnot. The this, speculation is that the A*behind algorithm this, is requires that the a significant A* algorithm amount requires of time a tosignificant calculate amountall-pair-paths. of time Once to calculate the pre-processing all-pair-paths. is done,Once th actuale pre-processing path planning is done, for the actual given path initial planning and target for thepositions given caninitial be and done target in real-time, positions for can both be cases.done in real-time, for both cases. To check the the efficiency efficiency of of the the proposed proposed user user inte interface,rface, a simple a simple experiment experiment was was performed, performed, in whichin which 30 30agents agents were were created created and and the thetime time taken taken to set to the set thetime-arrival time-arrival constraints constraints was waschecked. checked. For comparison,For comparison, a timeline a timeline interface interface was wasalso alsobuilt built with with FLTK FLTK (fast (fast light light toolkit). toolkit). Figure Figure 15 shows 15 shows the two the usertwo userinterfaces interfaces together. together. Three Three students students were wereasked asked to randomly to randomly set generated set generated time constraints time constraints with withboth bothinterfaces, interfaces, and the and amount the amount of time of timetaken taken to set to the set constraints the constraints was waschecked. checked. Table Table 2 shows2 shows the comparisonthe comparison result. result. The Theproposed proposed interface interface enabled enabled the users the users to set to the set time the timeconstraint constraint around around 30% faster30% faster than thanthe generic the generic timeline timeline interface. interface. The The reason reason for for this this is isthat that the the users users spent spent a a considerable considerable amount of time scrolling across the screen to findfind the timeline for aa particularparticular agent. This would be worse when the number of agents is beyond the display-limitdisplay-limit of the widget.widget. In the proposed user interface, however, the user can change the position of the camera, and the perspective so that many many time points can be seen at the same time, whichwhich helps the user findfind thethe constraintsconstraints faster.faster.

Figure 15. TwoTwo user interfaces for comparison.

Table 2. Table 2. Usability test result.

Age/GenderAge/Gender Timeline Timeline Interface ProposedProposed Interface Interface A A 24/F 24/ F 196 ss 152 152 s s B B 28/M 28/M 224 ss 175 175 s s C 27/M 222 s 165 s C 27/M 222 s 165 s Average 214 s 164 s Average 214 s 164 s 5. Discussions In this study, a time-constrained crowd path planning algorithm is proposed. The constraint that was enforced over the agents is a time gap. By doing so, it is possible to control the arrival time of each agent, and symmetrical arrival orders of objects can be specified for various effects in video Symmetry 2020, 12, x FOR PEER REVIEW 16 of 18

5. Discussions In this study, a time-constrained crowd path planning algorithm is proposed. The constraint that was enforced over the agents is a time gap. By doing so, it is possible to control the arrival time of eachSymmetry agent,2020 ,and12, 1804 symmetrical arrival orders of objects can be specified for various effects in video16 of 18 games, films, and robots. The basic collision avoidance structure of the proposed algorithm is based ongames, the popular films, and ORCA robots. algorithm. The basic Ho collisionwever, to avoidance use it for a structure highly complicated of the proposed environment, algorithm the is basedPRM methodon the popular is applied ORCA to obtain algorithm. the waypoints However, up to to use the it target for a highlyposition. complicated The preferred environment, velocity, which the PRM is themethod important is applied parameter to obtain in thethe waypoints ORCA, is upalso to adju the targetsted automatically, position. The preferred rather than velocity, keeping which it fixed is the duringimportant the simulation. parameter in The the final ORCA, velocity is also is also adjusted altered automatically, to satisfy the rather time duration than keeping constraints it fixed at during each frame.the simulation. Through Theexperiments, final velocity it was is alsoverified altered that to the satisfy proposed the time algorithm duration can constraints simulate atthe each agents frame. to meetThrough the time experiments, constraints it was in real-time, verified that and the the proposed paths were algorithm planned can 2.6 simulate times faster the agents than tothe meet A* algorithm.the time constraints In addition in real-time,to proposing and the pathsalgorith werem for planned supporting 2.6 times time faster constraints, than the a A* novel algorithm. user interfaceIn addition was to also proposing suggested, the algorithm where target for supportingpoints are represented time constraints, by relative a novel positions user interface in the was y-axis. also Itsuggested, is assumed where that targetthe y-axis points of arethe representedenvironment by is relative the time positions domain. in By the dragging y-axis. It a is mouse, assumed users that can the convenientlyy-axis of the environmentchange the position is the time along domain. the y-axis By dragging and control a mouse, the timeline users can 30% conveniently faster than changea general the interface.position along the y-axis and control the timeline 30% faster than a general interface. However,However, the the proposed proposed algorithm algorithm and and the the user user in interfaceterface have have limitations. limitations. Since Since we we assume assume that that thethe y-axisy-axis ofof the the environment environment represents represents time, thetime, algorithm the algorithm is not applicable is not toapplicable non-flat environments. to non-flat environments.However, this However, can be resolved this can as thebe heightresolved of as the th environmente height of the can environment be taken into can account be taken when into the accounttime constraints when the are time set. constraints Figure 16 shows are set. an Figu example.re 16 Althoughshows an Aexample. and B have Although different A heights and B alonghave differentthe y-axis, heights their arrival along the times y-axis, should their be arrival the same time becauses should their be distancesthe same frombecause the their ground distances are the from same. theWe ground would likeare tothe extend same. theWe proposedwould like interface to extend for the this proposed kind of uneven interface terrain. for this Another kind of limitation uneven terrain.is that thereAnother may limitation be cases is where that there the time may constraint be cases where cannot the be time satisfied. constraint In particular, cannot be when satisfied. agents In particular,are occupied when with agents avoiding are collisions,occupied with there avoiding is no time collisions, to adjust theirthere velocitiesis no time to satisfyto adjust the their time velocitiesconstraints. to satisfy In that the case, time our constraints. algorithm In may that not case, work. our Foralgorithm example, may when not work. a large For number example, of agentswhen aare large densely number packed of agents in a are highly densely complicated packed in environment a highly complicated they get environment stuck and barely they moveget stuck to theirand barelytargets. move In this to case,their adjustmenttargets. In this of velocities case, adjustme cannotnt be of carried velocities out as cannot all agents be carried are engaged out as in all avoiding agents arecollisions. engaged In in the avoiding future, wecollisions. would likeIn the to findfuture, a density we would threshold like to parameter find a density within threshold which the parameter proposed withinalgorithm which would the continueproposed to algorithm work. Furthermore, would contin all experimentsue to work. areFurthermore, carried out assumingall experiments that all are the carriedconstraints out assuming are set reasonably. that all the However, constraints arbitrarily are set reasonably. set constraints However, may cause arbitrarily the algorithm set constraints to fail. mayOn thecause user the interface algorithm level, to these fail. kinds On ofthe constraints user inte canrface be level, prohibited these bykinds limiting of constraints the position can of time be prohibitedpoints. This by can limiting be taken the upposition as a future of time study. points. This can be taken up as a future study.

Figure 16. Non-flat environment. Figure 16. Non-flat environment.

AsAs another another potential potential investigation investigation for for the the future, future, we we would would like like to to implement implement the the proposed proposed algorithmalgorithm on on a a GPU GPU (graphics (graphics processing processing unit). unit). To To animate animate a a large large number number of of agents, agents, the the high high performanceperformance of aa GPUGPU can can be be exploited. exploited. Using Using a GPU a GPU is quite is quite appropriate appropriate for crowd for simulationcrowd simulation because becauseeach agent each can agent independently can independently decide its velocity-warrantingdecide its velocity-warranting the use of the the parallel use of computational the parallel computationalpower of the GPU.power As of anotherthe GPU. prospective As anotherstudy, prospective rather study, thanrepresenting rather than representing the agent as the a sphere, agent aswe a wouldsphere, likewe would to use like a real to use 3D a character real 3D charac and utilizeter and its utilize motion its datamotion instead. data instead.This would This would pose a poseproblem a problem in synthesizing in synthesizing motion motion because because the agents the may agents change may their change speed their continuously. speed continuously. In the future, In we would like to integrate a motion synthesizing algorithm with the current path planning method.

Supplementary Materials: The accompanying video is available online https://youtu.be/qu_sxFoRhdg. Symmetry 2020, 12, 1804 17 of 18

Author Contributions: Methodology, M.S.; software, M.S.; investigation, M.S. and S.K.; writing—original draft preparation, M.S. and S.K.; writing—review and editing, M.S. and S.K.; supervision, M.S.; project administration, M.S.; funding acquisition, M.S. All authors have read and agreed to the published version of the manuscript. Funding: This research was supported by Basic Science Research Program through the National Research Foundation of Korea (NRF), funded by the Ministry of Education (2018R1D1A1B07048414). Conflicts of Interest: The authors declare no conflict of interest.

References

1. Van den Berg, J.; Lin, M.; Manocha, D. Reciprocal Velocity Obstacles for Real-Time Multi-Agent Navigation. In Proceedings of the IEEE International Conference on Robotics and Automation (ICRA), Pasadena, CA, USA, 19–23 May 2008. 2. Snape, J.; Berg, J.v.d.; Guy, S.; Manocha, D. The Hybrid Reciprocal Velocity Obstacle. IEEE Trans. Robot. 2011, 27, 696–706. 3. Van den Berg, J.; Guy, S.; Lin, M.; Manocha, D. Reciprocal n-body Collision Avoidance, Robotics research. In Proceedings of the 14th International Symposium ISRR, Lucerne, Switzerland, 31 August–3 September 2009; Selected papers based on the presentations at the symposium. Springer: Berlin, Germany, 2011. 4. Van den Berg, J.; Snape, J.; Guy, S.; Manocha, D. Reciprocal Collision Avoidance with Acceleration-Velocity Obstacles. In Proceedings of the IEEE International Conference on Robotics and Automation (ICRA), Shangai, China, 9–13 May 2011. 5. Jin, X.; Deng, Z. Crowd Simulation and its Applications: Recent Advance. J. Comput. Sci. Technol. 2014, 29, 799–811. 6. Curtis, S.; Best, A.; Manocha, D. Merge: A Modular Framework for Simulating Crowd Movement. Collectiv. Dyn. 2016, 1, 1–40. 7. Ijaz, K.; Sohail, S.; Hashish, S. A Survey of Latest Approaches for Crowd Simulation and Modeling using Hybrid Techniques. In Proceedings of the 17th UKSIM-AMSS International Conference on Modelling and Simulation, Cambridge, UK, 25–27 March 2015; pp. 25–27. 8. Berg, J.; Patil, S.; Sewall, J.; Manocha, D.; Lin, M. Interactive Navigation of Individual Agents in Crowded Environments. In Proceedings of the Symposium on Interactive 3D Graphics and Games (I3D), Redwood City, CA, USA, 15–17 February 2008; pp. 15–17. 9. Barnett, A.; Shum, H.; Komura, T. Coordinated Crowd Simulation with Topological Scene Analysis. Comput. Graph. Forum 2016, 35, 6. 10. Cooper, A.; Cooper, S.; Popovic, Z. Continuum Crowds. ACM Trans. Graph. 2006, 25, 3. 11. Karamouzas, I.; Skinner, B.; Guy, S. A universal power law governing pedestrian interaction. Phys. Rev. Lett. 2014, 113, 238701. 12. Karamouzas, I.; Sohre, N.; Narain, R.; Guy, S. Implicit Crowds: Optimization Integrator for Robust Crowd Simulation. ACM Trans. Graph. 2017, 36, 1–13. 13. Helbing, D. A fluid dynamic model for the movement of pedestrians. Complex. Syst. 1992, 6, 391–415. 14. Reynolds, C.W. Flocks, , and Schools: A Distributed Behavioral Model. In Proceedings of the 14th Annual Conference on and Interactive Techniques, ACM SIGGRAH, Anaheim, USA, 27–31 July 1987; Volume 1, pp. 25–34. 15. Toll, W.; Cook IV, A.; Geraets, R. Real-time density-based crowd simulation. J. Comput. Anim. Virtual Worlds 2012, 23, 59–69. 16. Guy, S.; Chhugani, J.; Curtis, S.; Dubey, P.; Lin, M.; Manocha, D. PLEdestrians: A Least-Effort Approach to Crowd Simulation. In Proceedings of the ACM SIGGAPH/Eurographics Symposium on Computer Animation, Chapel Hill, NC, USA, 2 July 2010; pp. 119–128. 17. RVO2 Library. Available online: http://gamma.cs.unc.edu/RVO2/ (accessed on 9 October 2020). 18. Yang, L.; Qi, J.; Song, D.; Xiao, J.; Han, J.; Xia, Y. Survey of Robot 3D Path Planning Algorithms. J. Control. Sci. Eng. 2016, 2016.[CrossRef] 19. Sung, M.; Chenny, S.; Gleicher, M. Scalable Behavior for Crowd Simulation. Comput. Graph. Forum 2014, 23, 519–528. Symmetry 2020, 12, 1804 18 of 18

20. Kurihaha, K.; Vronay, D.; Igagashi, T. Flexible Timeline User Interface using Constraints. In Proceedings of the CHI’05 Extended Abstracts on Factors in Computing Systems, Portland, OR, USA, 2 April 2005; pp. 1581–1584. 21. Korkmaz, M.; Durdu, A. Comparing of optimal Path Planning Algorithms. In Proceedings of the International Conference on Advanced Trends in Radio-electronics, Telecommunications and Computer Engineering, Slavske, Ukraine, 20–24 February 2018. 22. Guruji, A.; Agawal, H.; Parsediya, D.K. Time-efficient A* algorithm for Robot Path Planning. Proc. Technol. 2016, 23, 144–149.

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

© 2020 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).