Agent-based Swarm Model

How do you model a school of fish?


Learning Objectives

After completing Collective Behaviors (BLIMPs), Collective Behaviors (Computer Simulation), and this lesson, the student will be able to diagram and model animal / robot swarms.

Standards

  • NGSS HS-ETS1-3
  • CCSS.Math.Practice.MP1  
  • CCSS.Math.Practice.MP2
  • CCSS.Math.Practice.MP4

Units Used

  • Mass: kilogram (kg)
  • Length: meter (m)
  • Time: second (s)
  • Force: Newton (N) (1 N=1 kg m/s2)

Mathematical Modeling of Swarms

We will look at one of the most basic models that replicate collective motion of animal groups. The agents in the swarms are modeled as point masses that move around in the 2D or 3D space. Each agent can select its direction of motion based on the observed positions and velocities of the nearby agents. 

Time is partitioned into discrete time steps t, with a regular spacing of 0.1 s (corresponding to the response latency of the animal). We use c(t) to denote the position of agent #at time t, and v(t) to denote its velocity vector at time t. The position is then updated according to the following equation:

c(t+0.1) = c(t) + 0.1 v(t).

Suppose agent #1 is initially at c(0) = [0,0] in the xy-space, and suppose its trajectory is as shown in the figure below. What is the history of the velocities of this agent? 
Hint: v1(0) = [2,1]. 
 v(0.1)=  [      ,      ]      v(0.2)= [     ,      ]       

The behavior of the agent is modeled by how the velocity vector is updated based on what it perceives. In the following, we will study basic rules that replicate animal group behaviors.

Repulsion / Collision Avoidance: We first consider how individuals attempt to always maintain a minimum distance between themselves and others. This rule has the highest priority and corresponds to a frequently observed behavior of animals in nature. 

Each agent tries to move away from other agents within the range of rr. This disk centered at the individual with radius rr is called the “zone of repulsion” (ZOR), and the velocity vector will be updated according to

vi(t+0.1)=Σjĉji(t)

where ĉji is a unit vector from agent i to agent j, and the summation is taken over all the neighbors that are in ZOR.  The following figure shows an example of the velocity vector v1 that results from the repulsive behavior.  Observe how #1’s velocity is in the direction that moves away from #2 and #3.

If there are two additional agents (#5 and #6), what will be the resultant velocity vector? Directly draw in the figure.

Let’s look at another example to further understand the repulsive behavior. Suppose agents #2 and #3 are fixed (they do not move) at coordinates [0, 0] and [0.8, 0], respectively.  We consider how agent #1, who is initially located at c1(0)=[0.2, 0] with velocity v1(0)=[0,0], moves in the next few time steps.  Assume that rr=0.5 for this example.

Since the initial velocity is 0, the position at 0.1s is still c1(0.1)=[0.2, 0]. Based on the repulsive behavior, the velocity vector at time 0.1s will be v1(0.1)=[ ___, ___ ] m/s

Continuing the same process, find the position and velocity at time steps 0.2, 0.3, and 0.4:

  • c1(0.2)=______,    v1(0.2)=______m/s
  • c1(0.3)=______,    v1(0.3)=______m/s
  • c1(0.4)=______,    v1(0.4)=______m/s

Observe that agent #1 will not move beyond 0.4 s.  This is because the virtual “repulsive forces” that drive the agent is balanced.  Such a state is called the “equilibrium.”

Orientation and Attraction: If individuals are not performing an avoidance maneuver, they tend to be attracted towards other individuals (to avoid being isolated) and to align themselves with neighbors. Specifically, if no neighbors are within the ZOR, the individual responds to others within the “zone of orientation” (ZOO) and the “zone of attraction” (ZOA).  These zones are circular / spherical except for a volume behind the individual.  This “blind volume” is defined as a cone with interior angle α.

The ZOO starts outside of ZOR and ends at the distance ro.  The ZOA starts outside of ZOO and ends at the distance ra. An individual will attempt to align itself with neighbors within the zone of orientation and move towards the positions of individuals within the ZOA.  These two rules are added together as follows:

vi(t+0.1)=0.5(Σjj(t)+Σjĉji(t))

where j is the unit vector describing the direction of motion of agent #j.  The first summation is taken over all agents in the ZOO, and the second summation is over all agents in ZOA.  Note that ĉji is the vector from i toward j which is the opposite of the one used for the repulsive behavior.

Identify which of the three behaviors (repulsion, orientation, and attraction) are active in the situations shown in the following figures.

Now that you understand some basic rules, let’s see how they work in computer simulation!


Next Steps

Congratulations! You have made it to the end of the unit on a A Day in the Life… of these biologically inspired systems. If you skipped over the collective behaviors computer simulation exercise, this is a great time to hop back to that. Alternatively, you can put this into practice with your BLIMPs if you haven’t already. Otherwise, return to the curriculum to chose your next learning pathway.


Last updated: November 22, 2022.