Collective Behaviors (Computer Simulation)

How would you simulate the behavior of a flock of birds?


Learning Objectives

After completing Collective Behaviors (BLIMPs), this lesson, and Agent-based Swarm Model, 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

Supplies


NetLogo for Swarm Simulation

In the previous part, we saw how an individual reacts to the positions and velocities of other individuals in the group. In a multi-agent system, the collection of these local interactions results in a collective behavior of the group.  We will use computer simulation to see how the sizes of the behavioral zones affect the types of collective behaviors.

  1. Follow the instructions linked here to create the simulation file “BLIMP_simulation.nlogo”.
  2. Go to NetLogo Web
  3. Find “Upload a Model” on the top right corner of the screen
  1. Click on “Choose File” and navigate to the file you downloaded in step1
  2. You should now see the BLIMP_simulation screen:
  1. Click “setup” and then “go.” This will start the simulation.
  1. To change the population of the swarm, use the “population” slide bar, and don’t forget to hit “setup” again. You can play with this value, but the simulation will become slow if you increase the population too much.

We will now change the parameters r_a, r_o, and r_r to see how they affect the behavior of each individual as well as the behavior of the swarm as a whole. The meaning of these parameters is as follows:

  • r_r is the radius of ZOR (rr)
  • r_o is the width of ZOO (r_o = Δro = ro-rr
  • r_a is the width of ZOA (r_a = Δra=ra-ro)

Fragmenting: We will test how the parameters affect the “cohesiveness” of the swarm, i.e., how the agents can stay together.

  • Set Δra=3, Δro=1, and rr=1
  • Run the simulation a few times and observe what happens to the swarm. (You can click on “setup” to restart the simulation from a new random position.)
  • Increase the value of Δra and find the value for which the group always stays cohesive.
Cohesive swarm

Phase transition: We will now see how the group exhibits different collective behaviors, and how that is dependent on the past. 

  • Set rr=1 and Δra=15.
  • Set Δro=40. Run the simulation and describe the behavior. (You will probably see what’s called the “flocking” behavior.)
  • Gradually reduce the value of Δro and observe how the behavior changes. 
  • At what value of Δro did the behavior change? We’ll call this r_r1.
  • Now, start from Δro=0 and increase it until you see the flocking again.
  • At what value of Δro did you get the flocking? We’ll call this r_r2.

Notice how r_r1 and r_r2 are different. The switching in the behavior happens at different values of Δro depending on whether it was decreased from a higher value or increased from a lower value. This phenomenon is called the hysteresis.

Try different parameter settings and see if you can generate any “new” group behaviors! You can save the parameter values, take a screenshot and share it with us!


Bonus

You can try many other Netlogo simulations (not necessarily related to swarms) from “Search the Models Library” at the top left menu.

Clicking on the “NetLogo Code” allows you to look at the code and even write your own.

You can learn more about it here: https://ccl.northwestern.edu/netlogo/docs/


Next Steps

Interested in understanding the mathematical modeling that makes simulations like this possible? Check out Agent-based Swarm Model.

Otherwise, this is a terrific time to hop back to the curriculum overview to chose your next step in your BLIMP adventure.


Last updated: November 22, 2022.