Volume 59 Issue 05 June 2026
Research

Heterogeneity for Flocking and Computation: From Biology to Mathematics

<strong>Figure 1.</strong> Artistic conception of heterogeneity as a design mechanism for flocking. Figure courtesy of Camila F. Montanari.
Figure 1. Artistic conception of heterogeneity as a design mechanism for flocking. Figure courtesy of Camila F. Montanari.

In a murmuration of starlings, abrupt evasive maneuvers from a few birds in response to a passing falcon can trigger a collective response across the whole group. Within a fraction of a second, local turns are amplified through thousands of neighboring interactions between birds, and the entire flock twists and folds as if it were a single organism. During the annual northbound migration of sardines along the coast of South Africa, dense schools rapidly reorganize into spinning bait balls when dolphins approach, using collective geometry to confuse predators and dilute individual risk. On land, herds of millions of wildebeest coordinate traveling direction and timing across open plains and narrow passages during their yearly migration throughout the Serengeti. Desert locusts also march across long distances in the Sahel and Arabian Peninsula, producing vast swarms that move as a unit when tactile stimulation and high population density trigger a phase transition from individualistic to coordinated behavior in the form of rolling waves.

These coordinated group dynamics are often used as a defense mechanism to avoid predation, but they can also support sensing and navigation. Across these and many other examples, animal groups exhibit collective computation: a distributed information-processing system in which local interactions give rise to rapid global decision-making. These interactions are mediated by an underlying interaction network, defined by sensory and communication constraints on vision, touch, hydrodynamic, and acoustic cues. No single agent can influence more than a small number of others, yet information propagates at astonishing speed; for example, a small change in speed and direction by a few Pacific blue-eyed fish in response to a threat is sufficient to trigger an escape wave that propagates through the entire school within seconds [3]. Understanding how this computation works—i.e., what information is processed, how it is propagated, and when the dynamics are robust to noise—has become a central question in the study of collective animal behavior. This problem has also sparked strong interest in engineering, where these principles can be applied to the design of swarms of mobile robots, interacting self-driving vehicles, and flocks of drones [5, 6] (see Figure 1).

<strong>Figure 2.</strong> Phase transition in a Vicsek-type model from a misaligned to aligned flocking state as a function of the density of agents. The results are shown for a time-varying interaction network whose interaction weights are inversely proportional to the inter-agent distances (using periodic boundary conditions). Figure courtesy of Arthur N. Montanari.
Figure 2. Phase transition in a Vicsek-type model from a misaligned to aligned flocking state as a function of the density of agents. The results are shown for a time-varying interaction network whose interaction weights are inversely proportional to the inter-agent distances (using periodic boundary conditions). Figure courtesy of Arthur N. Montanari.

Given these biological and physical motivations, one might expect the foundational model of flocking to emerge from applied mathematics, physics, engineering, or biology; however, the most influential early model came instead from computer science. In 1987, Craig Reynolds introduced the boids model—short for bird-like droids—while working on realistic animation for computer graphics, with the end goal of creating believable collective motion on screen [7]. In this model, each agent follows just three rules:

  1. Alignment (match velocity with nearby agents)
  2. Separation (avoid crowding neighbors)
  3. Cohesion (move toward the center of mass of neighbors).

Despite their simplicity, these rules generate collective motion with remarkably lifelike behavior akin to schools, herds, and flocks. The model was quickly adopted by the film industry—most famously to simulate bat swarms in Batman Forever—and later used in video games such as \(\textit{ABZ}\hat{U}\), where advances in processors and graphics cards allowed thousands of agents to be simulated and rendered in real time.

Physicists and applied mathematicians subsequently recognized flocking as a paradigmatic example of self-organization. This led to the influential Vicsek model, introduced in 1995 as a minimal description inspired by statistical physics [9]. The model can be viewed as a nonequilibrium analogue of the two-dimensional \(XY\) model: instead of spin particles interacting on a fixed lattice, self-propelled particles (agents) move at constant speed \(v_0\) while reorienting their headings \(\theta_i\) to ensure local alignment. Denoting the position of agent \(i\) as \(\pmb{q}_i,\) the discrete-time dynamics can be formulated as

\[\begin{equation}
    \begin{cases}
        \pmb{q}_i(t+1) = \pmb{q}_i(t) + v_0 \Delta t \begin{bmatrix}
            \cos \theta_i(t) \\ \sin\theta_i(t)
        \end{bmatrix}, \quad &\text{(motion)}
        \\\\
        \theta_i(t+1) = \theta_i(t) + \frac{1}{d_i(t)}\sum_j A_{ij}(t) \left(\theta_j(t) - \theta_i(t)\right) + \, \text{noise}, \quad &\text{(alignment)}
    \end{cases}
\end{equation}\tag1\]

where \(A(t)\) is the adjacency matrix associated with a network structure and \(d_i(t) = {\sum}{_j}\; A_{ij}\) represents the node in-degree. The adjacency matrix encodes the time-varying interactions, often defined through distance-weighted couplings of the form \(A_{ij}(t) \propto ||\pmb{q}_i(t) - \pmb{q}_j(t)||^{-\beta}\) for \(\beta \geq 0\) [2]. Despite accounting only for velocity alignment (the first of Reynolds’ rules) while neglecting inertia and explicit attraction-repulsion forces, this simple model exhibits a transition from disordered to coherent motion as the density of agents increases or noise decreases (see Figure 2). The Vicsek model thus provided a theoretical framework for addressing foundational questions, such as the critical density required for self-organization.

<strong>Figure 3.</strong> Collective dynamics and computation in the Olfati-Saber model. <strong>3a.</strong> Flock converging toward its control objective: a lattice-like formation centered at the target position. <strong>3b.</strong> Diagram of the energy landscape \(V\) as a function of the agents’ position state \(\pmb{q},\) quantifying the state deviation from a desired lattice configuration. The state evolution toward low-energy configurations can be interpreted as a form of collective computation, in which agents seek to minimize a global objective through local interactions, as in many neurocomputational models. Figure courtesy of Arthur N. Montanari.
Figure 3. Collective dynamics and computation in the Olfati-Saber model. 3a. Flock converging toward its control objective: a lattice-like formation centered at the target position. 3b. Diagram of the energy landscape \(V\) as a function of the agents’ position state \(\pmb{q},\) quantifying the state deviation from a desired lattice configuration. The state evolution toward low-energy configurations can be interpreted as a form of collective computation, in which agents seek to minimize a global objective through local interactions, as in many neurocomputational models. Figure courtesy of Arthur N. Montanari.

A central issue that emerged from this line of work concerns the nature of the interaction network, i.e., who influences whom in the group and if interactions are determined by the distance between agents or some other criteria. Empirical field studies of starling flocks indicate that self-organization is mediated mainly by topological interactions, in which each bird responds to a fixed and relatively small number of neighbors. This challenged earlier distance-based assumptions [1]. In controlled lab environments, ray tracing (another technique borrowed from computer graphics) allowed researchers to extract interaction networks directly from video recordings [8]. These studies revealed that animal groups are governed by interaction networks that are weighted, directed, and complex.

However, network structure is only part of the story. Over the past decade, ethologists increasingly recognize another crucial dimension in animal behavior: agent heterogeneity. Early models treated agents as identical, but real biological systems are not. Individuals vary in size, sensory acuity, reaction time, and cognitive ability; they also exhibit consistent behavioral differences, with varying levels of boldness, sociability, or exploratory tendency. Empirical studies of fish schooling show that certain inter-individual behavioral differences improve group-level organization and cohesion, demonstrating that collective behavior depends not only on interaction rules but also on the agents’ individual behavior [4]. These studies also make the point that heterogeneity is not noise to be averaged out, but a resource exploited to facilitate coordinated responses, damp fluctuations, and prevent group fragmentation — contrary to the old saying that birds of a feather flock together.

Animation 1: Obstacle maneuvering in flocks of heterogeneous versus homogeneous agents.

A crucial question is whether these insights can be translated into engineered systems. Like animal groups, a swarm of autonomous drones must move cohesively, avoid collisions, track targets, and make real-time decisions under uncertainty. One influential framework to model these systems was introduced by Reza Olfati-Saber, who formulated flocking as a control-theoretic problem [6]. We can illustrate the model considering the problem of a flock tracking a moving target with position \(\pmb{q}^*(t)\). The position \(\pmb{q}_i(t)\) of agent \(i\) is governed by the (continuous-time) second-order differential equation

\[\begin{equation}
    \ddot{\pmb{q}}_i = \underbrace{\textstyle\sum\nolimits_j A_{ij}(\pmb{q}) (\dot{\pmb{q}}_j - \dot{\pmb{q}}_i)}_{\text{alignment}} - \underbrace{\nabla V(\pmb{q})}_{\text{separation}} + \underbrace{b_i(\pmb{q}^*- \pmb{q}_i) + c_i(\dot{\pmb{q}}^* - \dot{\pmb{q}}_i)}_{\text{cohesion}} ,
\end{equation}\tag2\]

where each term has a clear behavioral interpretation. The first term enforces velocity alignment through network interactions, much like the Vicsek model. The second term introduces separation through a carefully designed energy function \(V(\pmb{q})\) whose minima correspond to lattice-like formations; dynamically, the swarm performs a gradient descent on this landscape toward preferred spatial configurations. The final term enforces cohesion, with the feedback gains \(b_i\) and \(c_i\) controlling how strongly each agent is attracted to the target. Taken together, the model implements all three Reynolds’ rules (see Figure 3).

<strong>Figure 4.</strong> Flocking promoted by heterogeneity. <strong>4a.</strong> For identical initial conditions, the snapshots show that the heterogeneous flock converges to a connected, lattice-like formation, while the homogeneous flock remains disconnected. <strong>4b.</strong> When navigating an environment with obstacles, the heterogeneous flock maintains a connected formation, while, in the homogeneous case, the flock fragments and agents collide. In the heterogeneous flocks, agents at the front tend to exhibit distinct gains than those at the center, distinguishing their roles in leadership and group cohesion. Figure courtesy of Arthur N. Montanari.
Figure 4. Flocking promoted by heterogeneity. 4a. For identical initial conditions, the snapshots show that the heterogeneous flock converges to a connected, lattice-like formation, while the homogeneous flock remains disconnected. 4b. When navigating an environment with obstacles, the heterogeneous flock maintains a connected formation, while, in the homogeneous case, the flock fragments and agents collide. In the heterogeneous flocks, agents at the front tend to exhibit distinct gains than those at the center, distinguishing their roles in leadership and group cohesion. Figure courtesy of Arthur N. Montanari.

This formulation can explicitly incorporate agent heterogeneity: the feedback gains \(b_i\) and \(c_i\) encode how strongly each agent responds to positional and velocity deviations from the target motion. Allowing these parameters to vary across agents captures heterogeneity in actuation and responsiveness. Our recent work shows that such heterogeneity substantially improves stability, convergence, and decision-making [5]. In particular, flocks with tunable heterogeneous parameters converge to a desired formation significantly faster than their homogeneous counterparts, accelerating convergence time by approximately 40 percent (see Figure 4a). Agent heterogeneity enhances collective decision-making even in unmapped environments with obstacles, reducing both collision risk and flock fragmentation (see Figure 4b).

From a biological perspective, heterogeneity serves multiple functional roles: a small number of bold individuals can emerge as leaders and guide the group; variability in response times can stabilize collective motion and suppress noise; and sensory diversity can enhance global awareness. Translating these principles into mathematical language leads naturally to models with heterogeneous gains, delays, and interaction rules. These models are directly relevant to engineering applications involving multi-agent systems. As both natural and artificial flocks can be inherently heterogeneous, understanding when diversity enhances flocking, and when it suppresses it, is an exciting frontier in the mathematics of collective behavior.

References 
[1] Ballerini, M., Cabibbo, N., Candelier, N., Cavagna, A., Cisbani, E., Giardina, I., … Zdravkovic, V. (2008). Interaction ruling animal collective behavior depends on topological rather than metric distance: Evidence from a field study. Proc. Nat. Acad. Sci., 105(4), 1232-1237.
[2] Cucker, F. & Smale, S. (2007). Emergent behavior in flocks. IEEE Trans. Automat. Contr., 52(5), 852-862.
[3] Herbert-Read, J.E., Buhl, C., Hu, F., Ward, A.J., & Sumpter, D.J. (2015). Initiation and spread of escape waves within animal groups. R. Soc. Open Sci, 2(4), 140355. 
[4] Jolles, J.W., King, A.J., & Killen, S.S. (2020). The role of individual heterogeneity in collective animal behaviour. Trends Ecol. Evol., 35(3), 278-291.
[5] Montanari, A.N., Barioni, A.E.D., Duan, C., & Motter, A.E. (2025). Optimal flock formation induced by agent heterogeneity. Nat. Comm., 16, 9626. 
[6] Olfati-Saber, R. (2006). Flocking for multi-agent dynamic systems: Algorithms and theory. IEEE Trans. Automat. Contr., 51(3), 401-420.
[7] Reynolds, C.W. (1987). Flocks, herds and schools: A distributed behavioral model. In Proceedings of the 14th Annual Conference on Computer Graphics and Interactive Techniques (pp. 25-34). Anaheim, CA: Association for Computing Machinery. 
[8] Rosenthal, S.B., Twomey, C.R., Hartnett, A.T., Wu, H.S., & Couzin, I.D. (2015). Revealing the hidden networks of interaction in mobile animal groups allows prediction of complex behavioral contagion. Proc. Nat. Acad. Sci., 112(15), 4690-4695. 
[9] Vicsek, T., Czirók, A., Ben-Jacob, E., Cohen, I., & Shochet, O. (1995). Novel type of phase transition in a system of self-driven particles. Phys. Rev. Lett., 75(6), 1226-1229.

About the Authors

Arthur N. Montanari

Postdoctoral scholar, Northwestern University

Arthur N. Montanari is a postdoctoral scholar at the Center for Network Dynamics at Northwestern University. His research interests include network control, nonlinear dynamics, and neurocomputation.

Ana Elisa D. Barioni

Ph.D. student, Northwestern University

Ana Elisa D. Barioni is a Ph.D. student at the Center for Network Dynamics at Northwestern University. Her research interests include nonlinear dynamics in network systems, synchronization phenomena, and applications to complex systems.