Animal: An Agent-Based Model of Circulation logic for Dynamo

Categories: Blog
By Christian Sjoberg, Chris Beorkrem, Jefferson Ellinger, and Alireza Karduni- Presented at ACSA 2017
Link to full paper

Computational tools used by designers exist within an ecosystem of software providing packages of functionality to the user. The ultimate goal of this project is to create an agent based modeling tool which can provide designers with a means of integrating human movement into the computational design process. In order to maximize the usability of the tool, this project has been developed as a package for Dynamo, the scripting environment for the BIM software Autodesk Revit. This tool was written primarily in Python programming language using the Dynamo API with some additional functionality provided by standard Dynamo components. This allows designers to use this tool within the context of scripts or graphs which they may already be producing during the design process.

Each type of object in a designer’s model may have different effects on the behavior of agents navigating the space. At their most basic level, walls serve to impede the movement of an agent, furniture impedes movement but not visual perception, and circulation elements such as stairs and elevators may serve as attractors pulling agents through a lobby towards levels above.  Additionally, certain programmatic elements may attract or repel the agents based on their desires. This package for Dynamo will provide designers with a method for defining and integrating the effects that these elements may have on occupants into the computational processes they use for design.

This agent based tool requires four primary inputs. First, the user specifies the quantity of occupants that they wish to simulate.  Agents must then receive a list of possible starting states. This is provided as an input to the tool in the form of a list of point locations. Third, the system requires a list of point locations to serve as the agent’s possible destinations. Starting and ending locations are then randomly matched in order to provide a location-target pair for each agent in the simulation. Finally, the user provides the system with an array of solid geometries defining the environment for the agents to occupy. These geometries are selected by the user from their Revit model. The user must also define the appropriate response to the agent to the objects provided. Some additional settings for agent speed and other variables can be manipulated by the user as well. These inputs create the basic conditions for the simulation.

In order to simulate the movement of occupants in a space, the system relies on a set of algorithms which provide the agents with a method for handling the presence of obstacles in their path. An agent’s ability to select an appropriate direction for movement relies primarily on information present within its field of vision. This field is created as an array of vectors radiating from the agent’s current location. In order to approximate the human field of vision, a set number of these vectors are arrayed at even intervals from the direction of the agent’s last step up to ninety degrees in either direction. Each array in the agent’s field of vision is cast out to the environment and returns a list of intersections with objects. The distance from the agent to the nearest intersection in the list provides the value for that vector of the agent’s vision. This calculation is repeated to form an array of distances which the agent can “see” at each interval of its vision. This creates the equivalent of two-dimensional vision consisting of a line of pixels with a brightness representing the visible distance in each direction. Using this basic vision, confined to a two-dimensional plane, the agent gathers basic distance information about its environment.

Once this information is collected for the agent’s current location, it must evaluate its possible movement vectors against reaching its target location. This is accomplished by scoring each vector of the view array. The view distance of the vector is multiplied by the inverse of the angle between the view vector and a vector to the agent’s target location. Distance values are normalized as a value between zero and one. The values for the angle between the view vector and target vector are also scaled to a value between zero and one. This ensures calculations reflect scoring relative to possible options by normalizing the values. These values are then be multiplied by a weight coefficient. This allows for adjustment of which factor the system will prioritize when selecting the appropriate movement vector.  Weights in the system include user defined variables for agent behavior and response to specific object types. This formula effectively ensures that each view vector is scored by its chance of moving the agent toward the target without coming in contact with an obstacle.  (Figure 2)

The algorithm defines the agent’s path by repeating this process of vector casting and scoring from each position which the agent moves to. The speed at which the agent travels during the simulation is defined by the user. This is then divided by the number of iterations that the system goes through per second to determine the appropriate distance to move the agent at each iteration.

In order to prevent the system from calculating only one possible solution for each starting point to target pair, the weight coefficients of both distance and direction factors are multiplied by a random value within a specified range. Each agent receives a specific set of weight coefficients which they will use to score at each iteration along their path. This helps to simulate the variations in behavior between individuals when navigating space.

In addition to this basic movement algorithm, agents are also repelled from objects that are less than a user specified distance from them. This helps to prevent the agent from occupying only the shortest path between the starting location and the target. For example, an agent who is rounding a corner to reach a target may see the greatest distance and angle at the edge of the obstacle corner. This would then result in a consistently high score along that vector. In order to prevent all agents from turning at the sharp corner of the object, the agent will be repelled from the geometry by a value proportional to the distance between their location and the geometry. All wall geometry within the model incorporates this logic in order to avoid collision.

Following this logic, the agent begins at a location provided by its location-target pair and steps iteratively toward its target while navigating the space of the model. These algorithms are written in Python within a Dynamo component. This allows for the recursive execution of the stepping function for each agent. This process repeats until the user-defined number of iterations has been reached.

The tool generates a visual output for the user by drawing a spline between all locations the agent stepped through on their path. This process is repeated for each agent in the simulation. The tool also outputs a two dimensional list of all point locations for each agent. This allows the user to easily incorporate this movement data into their script.