Skip to main content
Proceedings of the National Academy of Sciences of the United States of America logoLink to Proceedings of the National Academy of Sciences of the United States of America
. 2024 Apr 17;121(17):e2320239121. doi: 10.1073/pnas.2320239121

Collective behavior from surprise minimization

Conor Heins a,b,c,d,1, Beren Millidge e, Lancelot Da Costa d,f,g, Richard P Mann h, Karl J Friston d,g, Iain D Couzin a,b,c,1
PMCID: PMC11046639  PMID: 38630721

Significance

We introduce a model of collective behavior, proposing that individual members within a group, such as a school of fish or a flock of birds, act to minimize surprise. This active inference approach naturally generates well-known collective phenomena such as cohesion and directed movement without explicit behavioral rules. Our model reveals intricate relationships between individual beliefs and group properties, demonstrating that beliefs about uncertainty can shape collective decision-making accuracy. As agents update their generative model in real time, groups become more sensitive to external perturbations and more robust in encoding information. Our work provides fresh insights into understanding collective dynamics and could inspire strategies in the study of animal behavior, swarm robotics, and distributed systems.

Keywords: collective motion, active inference, agent-based models, Bayesian inference, animal behavior

Abstract

Collective motion is ubiquitous in nature; groups of animals, such as fish, birds, and ungulates appear to move as a whole, exhibiting a rich behavioral repertoire that ranges from directed movement to milling to disordered swarming. Typically, such macroscopic patterns arise from decentralized, local interactions among constituent components (e.g., individual fish in a school). Preeminent models of this process describe individuals as self-propelled particles, subject to self-generated motion and “social forces” such as short-range repulsion and long-range attraction or alignment. However, organisms are not particles; they are probabilistic decision-makers. Here, we introduce an approach to modeling collective behavior based on active inference. This cognitive framework casts behavior as the consequence of a single imperative: to minimize surprise. We demonstrate that many empirically observed collective phenomena, including cohesion, milling, and directed motion, emerge naturally when considering behavior as driven by active Bayesian inference—without explicitly building behavioral rules or goals into individual agents. Furthermore, we show that active inference can recover and generalize the classical notion of social forces as agents attempt to suppress prediction errors that conflict with their expectations. By exploring the parameter space of the belief-based model, we reveal nontrivial relationships between the individual beliefs and group properties like polarization and the tendency to visit different collective states. We also explore how individual beliefs about uncertainty determine collective decision-making accuracy. Finally, we show how agents can update their generative model over time, resulting in groups that are collectively more sensitive to external fluctuations and encode information more robustly.


The principles underlying coordinated group behaviors in animals have inspired research in disciplines ranging from zoology to engineering to physics (13). Collective motion in particular has been a popular phenomenon to study, due in part to its striking visual manifestation and ubiquity (e.g., swarming locusts, schooling fish, flocking birds, and herding ungulates), and in part to the simplicity of models that can reproduce many of its qualitative features; like cohesive, directed movement (47). Because of this, collective motion is often cited as a canonical example of a self-organizing complex system, wherein collective properties emerge from simple interactions among distributed components.

Popular theoretical models cast collective motion as groups composed of self-propelled particles (SPPs) that influence one another via simple “social forces.” Early models like the Vicsek model (6) consider only a simple alignment interaction, where each particle aligns its direction of travel with the average heading of its neighbors. While oversimplifying the biological mechanisms in play, SPP models—like the Vicsek model—are useful for their amenability to formal understanding, e.g., the computation of universal quantities and relations through hydrodynamic and mean-field limits (811).

Recent research has shifted toward more biologically motivated approaches that aim to model the specific behavioral circuits and decision-rules that govern individual behaviors (1215). While these models are less analytically tractable than SPP models, they are more appealing to domain specialists like biologists, as they can generate predictions about sensory features in an individual’s environment that are necessary and sufficient for evoking behavior. Furthermore, these predictions can be tested experimentally (14, 16). This data-driven approach can thus provide mechanistic insights into the biological and cognitive origins of decision-making (13, 17).

In this work, we propose a model class that blends the first-principles, theoretical approach of physical models with biological plausibility, resulting in an ecologically valid but theoretically grounded agent-based model of collective behavior. Our model class is based on active inference, a framework for designing and describing adaptive systems where all aspects of cognition—learning, planning, perception, and action—are viewed as a process of inference (1821). Active inference originated in theoretical neuroscience as a normative account of self-organizing, biological systems as constantly engaged in predictive exchanges with their sensory environments (2225).

Collective Motion Models: From SPP to Bayesian Agents

In popular SPP models, an individual’s movement is described as driven by a combination of social and environmental forces. These forces are often treated as vectors that capture various tendencies seen in biological collective motion, such as repulsion, attraction (to neighbors or external targets), and alignment. These forces can then be combined with various nonlinearities and weights to capture mechanisms of interaction.

In contrast, the active inference approach forgoes specifying explicit vectorial forces, and instead starts by modeling all behavior as the solution to an inference problem, namely the problem of inferring the latent causes of sensations. Perception and action strive to improve the agent’s predictions of sensory inputs, based on its internal model of its world (Fig. 1A). By equipping this internal model with expectations about the environment’s underlying tendencies, social forces can emerge naturally as agents attempt to suppress sensory data that are mismatched with their expectations. This perspective shift offers a unifying modeling ontology for describing adaptive behavior, while also resonating with cybernetic principles like homeostatic regulation and process theories of neural function like predictive coding (2629).

Fig. 1.

Fig. 1.

(A) Schematic illustrating the Bayesian perspective in the context of our single agents, where the hidden states of the environment are segregated from a focal agent by means of sensory data yt (Right panel of A). This contrasts with classic SPP models (Left panel of A), where environmental or social information manifests in terms of social forces on the focal individual, who emits its own actions based on hand-crafted decision-rules (e.g., changes to heading direction). (B) Schematic illustration of the sector-specific distance tracking. The Left panel shows a Bayesian network representation of a dynamic generative model (i.e., a time-series model), that represents the time-evolution of a latent variable x1,...,T and simultaneous observations y1,...T. Shown are both a standard time-series representation (Lower Left) and its equivalent representation as generalized coordinates of motion x~t=(xt,xt,xt,...) (Right). We show the orders of differentiation used for our model in practice (3 orders of motion for x~ and 2 orders of motion for y~). The Middle panel of B shows how each component of the vectorial hidden state x=(xh,1,...,xh,L) is computed as the average nearest-neighbor distance for the neighbors within each visual sector. Observations are generated as noisy, Gaussian samples centered on the sector-wise distance hidden state (Right panel of B). This requires the agent to estimate the true hidden state xt by performing inference with respect to a generative model of how sensory data are generated p(y~,x~).

Active inference blends the construct validity of cognitivist approaches with the first-principles elegance of physics-based approaches by invoking minimization of a single, all-encompassing objective function that explains behavior: surprise, or, under certain assumptions, prediction error. As an example of this perspective shift, in this work, we investigate a specific class of generative models that can be used to account for the types of collective behaviors exhibited by animal groups. In doing so, we hope to showcase the benefits of the framework, while also proposing a testable model class for use in studies of biological collective motion.

Active Inference and Generative Models of Behavior

A common pipeline in the quantitative study of animal behavior involves selecting a candidate behavioral algorithm or decision rule that may explain a given behavior and then fitting the parameters of the candidate model to experimental or observational data (16, 30). While these approaches often yield strong quantitative fits to data, the explanatory power of the models reduces to the interpretation of hard-coded parameters, which often have opaque relationships to real biological mechanisms or constructs (31).

In the active inference framework, we rather ask: What is the minimal model an organism might have of its environment that is sufficient to explain its behavior? Behavior is cast as the process by which the agent minimizes surprise or prediction error, with respect to this model of the world (22, 32). The principle of prediction-error minimization enjoys empirical support in neuroscience (26, 33) and a theoretical basis in the form of the Free Energy Principle (22, 23, 25), an account of all self-organizing systems that casts them as implicit models of their environments, ultimately in the service of minimizing the surprise (a.k.a., self-information) associated with sensory states (3436).

What states-of-affairs count as surprising hinges on a generative model that can assign a likelihood to sensory data? When it comes to modeling behavior driven by this principle, the challenge then becomes specifying a generative or world model, whereby a particular pattern of behavior simply emerges by minimizing surprise.

According to active inference, agents minimize surprise by changing their beliefs about the world (changing which observations are considered surprising) or by acting on the world to avoid surprising sensory data. The former strategy is thought to correspond to passive processes such as perception and learning, whereas the latter corresponds to processes like active sensing and movement. Action is thus motivated by the desire to generate sensations that are as least surprising as possible.

In this paper, we describe the motion of mobile, mutually sensing agents as emerging from a process of collective active inference, whereby agents both estimate the hidden causes of their sensations, while also actively changing their position in space in order to minimize prediction error. In contrast to models that use prespecified behavioral rules for generating behavior, generative models entail collective behavior by appealing to a probabilistic representation of how an organism’s sensory inputs are generated.

A Generative Model for a (Social) Particle

We now consider a sufficient generative model for an individual in a moving group. We equip this individual, hereafter referred to as the focal agent, with a representation of a simple random variable: the local distance x between itself and its neighbors. For generality, we can expand this into a multivariate random variable to describe a set of distances x=(x1,x2,...,xL) that track the distance between the focal agent and its neighbors within L different sensory sectors (Fig. 1B). We analogize these L sectors to adjacent visual fields of an agent’s field of view (37, 38).

The focal agent possesses a model of the distance(s) x and its sensations thereof y. In particular, our focal agent represents the dynamics of x using a stochastic differential equation (a.k.a., a state-space model) defined by a drift f and some stochastic forcing ω—we refer to this component of the generative model as the dynamics model. The stochastic term ω captures the agent’s uncertainty about paths of x over time. The agent also believes it can sense x via observations y, mediated by a sensory map, which we call the observation model. This is defined by some (possibly nonlinear) function g with additive noise z. The agent’s generative model is then fully described by a pair of equations that detail 1) the time-evolution of the distance and 2) the simultaneous generation of sensory samples of the distance:

Dx~=f~+ω~y~=g~+z~. [1]

All random variables are described using generalized coordinates of motion with the convention q~={q,q,q,...}. Generalized coordinates allow us to represent the trajectory of a random variable using a vector of local time derivatives (position, velocity, acceleration, etc.). The matrix D is a generalized derivative operator that moves a vector of generalized coordinates up one order of motion D(x,x,x,...)=(x,x,x,...). The generalized functions f~ and g~ therefore operate on vectors of generalized coordinates (see SI Appendix, section S1 for details on generalized coordinates and filtering).

Generalized Filtering and Active Inference

An agent equipped with this dynamic generative model then performs active inference by updating its beliefs (state estimation, or filtering) and control states (action) to minimize surprise.

Inference entails updating a probabilistic belief over hidden states x~ in the face of sensory data y~. Our agents solve this filtering problem using generalized filtering (39, 40), an algorithm for approximate Bayesian inference and parameter estimation on dynamic state-space models. This is achieved by minimizing the variational free energy F, a tractable upper bound on surprise (i.e., negative log evidence or marginal likelihood). The agent minimizes the free energy with respect to a belief distribution q(x~) with parameters ν; this approximates the true posterior qν(x~)p(x~|y~), which is the optimal solution in the context of Bayesian inference. The true posterior p(x~|y~) is difficult to compute for many generative models due to the difficult calculation of the marginal (log) likelihood lnp(y~). Variational methods circumvent this intractable marginalization problem by replacing it with a tractable optimization problem: namely, adjusting an approximate posterior to match the true posterior by minimizing F with respect to its (variational) parameters ν.

We parameterize q(x~) as a Gaussian with mean-vector μ~, which is a natural choice for this generative model since the assumption of normally distributed noises z~,ω~ imply that the true posterior will be Gaussian near the posterior mode argmaxp(x~|y~). The implicit Gaussian (i.e., Laplace) assumption is ubiquitous in the modeling and signal processing literature (41) and can be regarded as a “minimal” assumption, by appeal to things like the central limit theorem and related principles (e.g., Jaynes’ maximum entropy principle). According to generalized filtering, μ~ is updated using a sum of prediction errors:

dμ˜dtμ˜Fμ˜,y˜ε˜zε˜ω,where  ε˜z=y˜g˜(μ˜)ε˜ω=Dμ˜f˜(μ˜). [2]

The ensuing evidence accumulation can be regarded as a natural generalization of predictive coding (26, 42, 43), where beliefs about local trajectories μ~ are updated using a running assimilation of sensory and model prediction errors: ε~z and ε~ω, respectively. For notational clarity, we have omitted terms that weigh these prediction errors; the so-called generalized sensory and model precisions Π~z,Π~ω, which encode the agent’s assumptions about the magnitude and correlation structure of noise. The importance of these precisions will become clear later, when understanding the relationship between precision-weighted prediction errors and social forces.

While inference entails changing the approximate posterior means μ~ to best explain sensory data, action entails changing the data itself to better match the data to one’s current beliefs. Similar to the update scheme in Eq. 2, actions are also updated by minimizing free energy:

dadt=aF(μ˜,y˜(a))=y˜F(μ˜,y˜(a))ay˜(a)ε˜zay˜(a). [3]

Actions thus are updated using a product of sensory prediction errors ε~z and a “sensorimotor contingency” ay~(a) or reflex arc. This sort of “reflexive action”—where control is simply targeted at minimizing sensory prediction errors—underlies active inference accounts of motor control (27, 44), and can be formally related to proportional-integral-derivative (PID) control (45). These prediction errors measure how far an agent’s observations are from its expectations; the agent then acts using Eq. 3 to minimize this deviation. Active inference agents are thus driven to act in a way that aligns with their (biased) expectations about the world (46). In the next section, we will see how building a particular type of bias into each agent’s generative model leads to the appearance terms in Eq. 3 that resemble social forces.

Social Forces as a Consequence of Predictive Control

In particular, we take the agent’s action to be its heading direction a=v and examine the case where the agent observes the distance to its neighbors within a single sensory sector, i.e., L=1, x=(x1). We distinguish the agent’s representation of the distance x from the actual distance using the subscript h. Therefore, xh=(xh,1,xh,2,...,xh,L) denotes the average distances (and corresponding sensory samples yh) calculated using the actual positions of other agents. For the case of L=1, and assuming the agent observes both the distance and its rate of change yh,1, this is,

xh,1=1KjNinrjryh,1=xh,1+zh,1,xh,1=dxh,1dtyh,1=xh,1+zh,1. [4]

Nin is the set of neighbors within the agent’s single sensory sector, K is the size of this set, r is the focal agent’s position vector, and rj is the position vectors of neighbor j. The sensory observation of the generalized distance y~h=(yh,1,yh,1) is a sample of the hidden state, perturbed by some additive noises z~=(zh,1,zh,1). By expanding the active inference control rule in Eq. 3, we arrive at the following differential equation for the heading vector:

dvdt=ξzΔr^,ξz=πz,1(yh,1μh,1),Δr^=1KjNinΔrjΔrj,Δrj=rjr. [5]

The average vector Δr^ is exactly the (negative) sensorimotor contingency term ay~(a) from Eq. 3 (see SI Appendix, section S1 for detailed derivations):

vy~(v)=ry=1KjNinrrjrrj=Δr^. [6]

The simple action update in Eq. 5 means that the focal agent moves along a vector pointing toward the average position of its neighbors. Whether this movement is attractive or repulsive is determined by the sign of the precision-weighted prediction error ξz=πz,1(yh,1μh,1), and its magnitude depends on two factors: 1) the sensory precision or “reliability” πz,1 that the agent affords observations of the rate-of-change of yh,1; and 2) the degree to which these rate-of-change observations deviate from their predicted value yh,1μh,1.

The presence of both attractive and repulsive forces depends on the agent’s model of the distance dynamics, captured by the functional form of f~. In particular, consider forms of f~ that relax x to some attracting fixed point η>0. Equipped with such a stationary model of the local distance, inference dynamics (c.f., Eq. 2) will constantly bias its predictions μ according to the prior belief that the distance is pulled to η. Given this biased dynamics model and the action update in Eq. 3, such an agent will move to ensure that distance observations y~h are equal to the fixed point η.

This action update shows immediate resemblance to the attractive and repulsive vectors common to social force-based models (4, 5, 7), which often share the following general form:

FattrjZArijrij,Frepul1KjZRrijrij, [7]

where ZA,ZR refer to distance-defined zones of attraction or repulsion, respectively. In the active inference framework, these social forces emerge as the derivative of the observations with respect to action ay~, where the sign and magnitude of the precision-weighted sensory prediction error ξz determines whether the vector is attractive (toward neighbors) or repulsive (away from neighbors). The transition point between attraction and repulsion is therefore given by η, the point at which prediction errors switch sign.

An important consequence of this formulation is that, unlike the action rule used in social force-based models, the “steady-state” solution occurs when all social forces disappear (when prediction errors vanish). In this case, the agent ceases to change its heading direction and adopts its previous velocity. This occurs when the agent’s sensations align with its (biased) predictions yh,1η. In classic SPP models, this is equivalent to the different social force vectors exactly canceling each other.

We can therefore interpret social force-based models as limiting cases of distance-inferring active inference agents, because one can conceive of social forces as just those forces induced by free energy gradients; namely, the forces that drive belief-updating. In the case of our active inference agents, attractive and repulsive forces emerge naturally when we assume a) agents model the local distance dynamics as an attractor with some positive-valued fixed point η; b) agents can act by changing their heading direction and c) agents observe at least the first time derivative of their observations (e.g., yh,1, but see SI Appendix, section S1 for detailed derivations).

It is worth highlighting the absence of an explicit, vectorial alignment force in this model, consistent with experimental findings in two species of fish (12, 17). The heading vectors of neighbors are nevertheless implicitly incorporated into the calculation of first-order prediction errors ξz via the first-order hidden state xh,1 (c.f., Eq. 4 and SI Appendix, section S1 and Eq. S40). In particular, the xh,1 (from which the observations yh,1 are sampled) is equivalent to the “relative velocity” term used in so-called selective attraction and repulsion models, where the instantaneous rate at which neighbors approach or move away, is used to drive movement (47). However, explicit alignment forces as seen in the Vicsek model (6) and 2- and 3-Zone Couzin models (7, 48) can also be recovered if we assume agents have a generative model of the average angle between their heading vector and those of their neighbors (see SI Appendix, section S2 for derivations of alignment forces).

Multivariate Sensorimotor Control

Having recovered social forces as free energy gradients in the case of a single sensory sector (L=1), we now revisit the general formulation of the generative model’s state-space, where the hidden variable x is treated as an L-dimensional vector state: x=(x1,x2,...,xL), with correspondingly L-dimensional observations y=(y1,y2,...,yL).

Specifically, we consider each xl to represent the average distance-to-neighbors within one of a subset of adjacent sensory sectors, where each sector is offset from the next by a fixed intersector angle (see Fig. 1B for a schematic of the multisector set-up). The rest of the generative model is identical; the agents estimate these distances (and their temporal derivatives xl,xl,...) while changing their heading direction to minimize free energy. Following the same steps as in the case of a single sector, the resulting update rule for v is a weighted sum of “sector-vectors,” where generalized observations from each sector-specific modality y~l are used to compute the prediction errors that scale the corresponding sector-vector. This generalizes the scalar-vector product in Eq. 5 to a matrix-vector product:

dvdt=ξ~zΔR^,ΔR^=vy~1vy~2vy~L, [8]

where now the (negative) sensorimotor contingency ay~=ΔR^ is a matrix whose rows contain the partial derivatives vy~l (i.e., the sector-vectors). Each sector vector is a vector pointing toward the average neighbor position within sector l.

Numerical Results

Given a group of active inference agents—equipped with the generative models described in previous sections—it is straightforward to generate trajectories of collective motion by integrating each agent’s heading vector over time: r˙i=vi,i{1,2,...,N} where N is the number of agents. We update all heading directions {vi}i=1N and beliefs {μ~i}i=1N in parallel via a joint gradient descent on their respective free energies:

v˙1=v1F(μ~1,y~1)μ~˙1=μ~1F(μ~1,y~1)v˙2=v2F(μ~2,y~2)μ~˙2=μ~2F(μ~2,y~2)v˙N=vNF(μ~N,y~N)μ~˙N=μ~NF(μ~N,y~N). [9]

For the simulation results shown here, each agent tracks the average distance xl within a total of L=4 sensory sectors that each subtend 60° (starting at 120° and ending at +120°, relative to the focal agent’s heading direction) and observe the sector-specific distances calculated using all neighbors lying within 5.0 units of the focal agent’s position. Each agent represents the vector of local distances as a generalized state with 3 orders of motion: x~={x,x,x}, μ~={μ,μ,μ}. Agents can observe the first and second orders of the distance y~={y,y}, i.e., the distance itself and its instantaneous rate-of-change. In the numerical results to follow, we use active inference to study the relationship between the properties of individual cognition (e.g., the parameters of agent-level generative models) and collective phenomenology.

Collective Regimes.

Simulated groups of these distance-inferring agents display robust, cohesive collective motion (Fig. 2A and Movies S1–S5). Fig. 2A displays examples of different types of group phenomena exhibited in groups of active inference agents, whose diversity and types resemble those observed in animal groups (49, 50) and in other collective motion models (6, 7, 51). These range from directed, coherent movement with strong interagent velocity correlations (“polarized motion”) to group rotational patterns, like milling, which features high angular momentum around the group’s center of mass.

Fig. 2.

Fig. 2.

(A) Example snapshots of different collective states in schools of N=50 active inference agents. Each line represents the trajectory of one individual, and color gradient represents time, from earliest (light blue) to latest (purple). The polarized regime in the Left panel was simulated with the default parameters listed in SI Appendix, Table S1. The milling regime (Middle panel) was achieved by increasing the variance of velocity fluctuations (encoded in σz,h2) from 0.01 to 0.05 (relative to the default configuration) and increasing λz from 1.0 to 1.2. The disordered regime was achieved by increasing the sensory smoothness parameter to 2.0 and decreasing η from 1.0 to 0.5 and α from 0.5 to 0.1 (relative to the default configuration). (B) Average polarization (Left) and milling probability (Right) shown as a function of the two factorized components of the sensory precision, Γz (log-transformed) and λz. For each combination of precision parameters, we ran 500 independent trials of “free schooling,” and then averaged the quantities of interest across trials. Each free schooling trial lasted 15 s (1,500 time steps with dt=0.01s); the time-averaged metrics (polarization and milling probability, respectively, were computed from the last 10s of the trial.

Relating Individual Beliefs to Collective Outcomes.

In all but the most carefully constructed systems (31, 52, 53), the relationship between individual and collective representations is often opaque. In particular, the relationship between individual-level uncertainty or “risk” and collective behavior is an open area of research. For instance, some research has indicated that increased risk-sensitivity at the level of the individual may lead to decreased risk-encoding at the collective level (54). Inspired by these observations, we use active inference to examine the quantitative relationship between uncertainty at the individual-level and collective phenomenology. We begin by examining common metrics of group motion like polarization and angular momentum (7). In Fig. 2B we explore how polarization and angular momentum are affected by two components of agent-level sensory uncertainty (i.e., inverse sensory precision): 1) the absolute precision that agents associate with sensory noise and 2) the autocorrelation or “smoothness” associated to that noise.

These components are encoded in each agent’s observation model, which assumes generalized distance observations y~ are normally distributed around the generalized state x~:

P(y~|x~)=N(y~;x~,Σ~z), [10]

where we focus on the parameterization of the inverse of the covariance matrix, a.k.a., the precision matrix Π~z=Σ~z1. This precision matrix factorizes into two submatrices, one encoding the amplitude of random fluctuations z and one encoding their temporal smoothness, i.e., the inverse of the covariance between different derivatives of random fluctuations (e.g., between z and z):

Π˜z=ΠzΠ˜zwhere  Πz=Γz,1000Γz,20Γz,L [11]
˜z=1002λz2. [12]

Intuitively, Γz encodes the variance or amplitude that the agent associates with the noise in each of its L sensory sectors zl, and λz encodes how “smooth” the agent believes the noise is (40, 55). A higher value of λz implies that the agent believes sensory noise is more serially correlated (e.g., random fluctuations in optical signals caused by smooth variations in refraction due to turbulence in water). SI Appendix, section S3 shows how the smoothness parameter λz can be derived from a noise process with a Gaussian autocorrelation function. The consequences of this parameterization can be mapped back to the first-order prediction errors ξz that drive action in Eqs. 5 and 8:

ξz=2Γz,1λz2(yh,1μh,1)2Γz,2λz2(yh,2μh,2)2Γz,Lλz2(yh,Lμh,L). [13]

Here, we have simply written the precision assigned to noise zh,l in a particular sensory sector as a product of the amplitude and smoothness parameters: πz,l=2Γz,lλz2.

Fig. 2B shows how the different components (amplitude and smoothness) of the agent’s beliefs about uncertainty determine group behavior, as quantified by average polarization and milling probability. Average polarization is defined here as the time average of the polarization of the group, where the polarization at a given time p(t) measures the alignment of velocities of agents comprising the group (7, 56):

p^=1Tt0t=t0Tp(t)p(t)=1Ni=1Nvi(t). [14]

Note that the time average is calculated once steady state has been reached, where the beginning of this state is indicated by t0 (for the heatmaps shown in Fig. 2B, we calculate these average metrics with t0=5 s). High average polarization indicates directed, coherent group movement. The Left panel of Fig. 2B shows how Γz and λz contribute to the average polarization of the group. An increase in either parameter causes polarization to decrease and angular momentum to increase, reflecting the transition from directed motion to a milling regime, where the group rotates around its center of mass. We calculate the milling probability (c.f. Right panel of Fig. 2B) as the proportion of trials where the time-averaged angular momentum surpassed 0.5. The average angular momentum can be used to quantify the degree of rotational motion, and is calculated as the time- and group-average of the individual angular momenta around the groups’ center of mass c:

m^=1Tt0t=t0Tm(t)m(t)=1Ni=1Nric(t)×vi(t), [15]

where ric is a relative position vector for agent i, defined as the vector pointing from the group center c to agent i’s position: ric. We observed a large range of Γz and λz for which the milling regime (high average angular momentum) was stable (Fig. 2B, Right). This stands in contrast to earlier self-propelled particular models like the original 3-zone Couzin model, where milling was only stable under a relatively limited range of parameters (7).

These collective changes can be understood by recalling how first-order prediction errors ξz (and thus the velocity update) depend on Γz and λz:

ξz2Γzλz2. [16]

In practice, this means that as the group believes in more predictable (less rough) first-order sensory information yz, the group as a whole is more likely to enter rotational, milling-like regimes. However, the enhancing effect of these first-order prediction errors ξz on rotational motion is bounded; if prediction errors are overweighted (e.g., high Γz and/or λz), the group becomes more polarized again and likely to fragment (SI Appendix, Fig. S1). This fragmentation probability occurs at both low and high levels of Γz and λz, implying that there is an optimal range of individual-level sensory precision where cohesive group behavior (whether polarized or milling) is stable. Thus, our model predicts that assuming one’s sensory information is highly precise is neither required, or in fact even desirable, for animals in order to facilitate collective motion.

We have seen how one can use active inference to relate features of individual-level beliefs (in this case, beliefs about sensory precision) to collective patterns, focusing in the present case on common metrics for studying collective motion like polarization and the tendency to mill.

In the following sections, we move from looking at group-level patterns that occur during free movement, to studying the consequences of individual-level uncertainty for collective information-processing. We begin by investigating how collective information transfer depends on individual-level beliefs about the relative precisions associated with different types of sensory information.

Collective Information Transfer.

In this section, we take inspiration from the collective leadership and decision-making literature to investigate how individuals in animal groups can collectively navigate to a distant target (48, 5759). This phenomenon is an example of effective leadership through collective information transfer and is remarkable for a number of reasons; one that speaks to its emergent nature, is the fact that these collective decisions are possible despite—and indeed even because of—the presence of uninformed individuals in the group (57). Fig. 3A shows that active inference agents engaged in this task reproduce a result from earlier work (48) on the relationship between the proportion of uninformed individuals and collective accuracy. Namely, as the proportion of informed individuals increases, so does the accuracy of reaching the majority-preferred target. In the same vein as earlier sections, we also investigated the dependence of this effect, as well as the average target-reaching accuracy, on individual-level beliefs.

Fig. 3.

Fig. 3.

(A) Collective accuracy as a function of proportion informed or pinf for differing values of the sensory precision assigned to social observations ΓzSocial. Average accuracy for each condition (combination of pinf,ΓzSocial,ΓzTarget) was computed as the proportion of successful hits across 500 trials. Here, the average accuracy is further averaged across all the values of the ΓzTarget parameter, meaning each accuracy here is computed as the average of 15,000 total trials (500 trials per condition ×30 different values of ΓzTarget). (B) Collective accuracy as a function of both the social and target precisions (ΓzSocial,ΓzTarget, shown in log-scale) averaged across values of pinf ranging from pinf=0.15 to pinf=0.40. Each condition’s accuracy was computed as the proportion of accurate decisions from 500 trials.

We operationalize the notion of an agent being “informed” (about an external target) by introducing a new latent variable to its generative model; this variable xtarget represents the distance between the informed agent’s position r and a point-mass-like target with position vector T=[T1,T2]. We thus define this hidden state and observation as follows: xtarget=Tr, ytarget=xtarget+ztarget. Just like the “social” distance observations yh, this target distance observation ytarget represents a (potentially noisy) observation of the true distance xtarget. As before, the agent represents both the target distance xtarget and its observations ytarget using generalized coordinates of motion. Each informed agent has a dynamics model of x~target, whereby they assume the target distance is driven by some drift function ftarget(xtarget)=αtxtarget which relaxes to 0. As with the social distances, we truncate the agent’s generalized coordinates embedding of the target distance to three orders of motion and the generalized observations to two orders of motion.

Each informed agent maintains a full posterior belief μ~=(μ~1,μ~2,...,μ~L,μ~target) about the local distances x~1,x~2,...,x~L as well as the target distance x~target.

Using identical reasoning to arrive at the action updates in Eqs. 5 and 8, one can augment the matrix-vector product in Eq. 8 with an extra sensorimotor contingency and prediction error that represents target-relevant information:

dvdt=ξ~zΔR^ΔTΔT=vy~target=TrTr. [17]

This matrix-vector product can then be seen as a weighted combination of social and target vectors, with the weights afforded to each equal to their respective precision-weighted prediction errors:

dvdt=ξsocialΔR^Social vector+ξtargetΔTTarget vector. [18]

This expression is analogous to the velocity update in equation 3 of ref. 48, where a “preferred direction” vector is integrated into the agent’s action update with some predetermined weight. This weight is described as controlling the relative strengths of nonsocial vs. social information. For active inference agents, the weighting of target-relevant information emerges naturally as a precision-weighted prediction error (here represented as ξtarget), and the target vector itself is equivalent to a sensorimotor reflex arc, that represents the agent’s assumptions about how the local flow of the target distance ytarget changes as a function of the agent’s heading direction v. An important consequence of this construction, is that, unlike in previous models where this weight is “baked-in” as a fixed parameter, the weight assigned to the target vector is dynamic, and fluctuates according to how much the agent’s expectations about the target distance μ~target predict the sensed target distance ytarget.

Using this construction, we can simulate a group of active inference agents, in which some proportion pinf of agents represent this extra set of target-related variables as described above. To generate y~target observations for these informed individuals, we placed a spatial target at a fixed distance away from the group’s center-of-mass and then allowed the informed individuals to observe the generalized target distance y~target=(ytarget,ytarget). We then integrated the collective dynamics over time and measured the accuracy with which the group was able to navigate to the target (see Materials and Methods for details). By performing hundreds of these trials for different values of pinf, we reproduced the results of ref. 48 in Fig. 3. We see that as the number of informed individuals increases, collective accuracy increases. However, this performance gain depends on the agents’ beliefs about sensory precision, which we now dissociate into two components: Γz-Social ( the precision assigned to the social distance observations) and Γz-Target (the precision assigned to target distance observations). By varying these two precisions independently, which respectively scale ξsocial and ξtarget in Eq. 18, we can investigate the dependence of collective accuracy on the beliefs of individual agents about the uncertainty attributed to different sources of information.

Fig. 3A shows the average collective accuracy as a function of pinf, for different levels of the social distance precision ΓzSocial. The pattern that emerges is that the social precision, that optimizes collective decision-making, sits within a bounded range. The general effect of social precision is to essentially balance the amplification of target-relevant information throughout the school, with the need for the group to maintain cohesion. When social precision is too high, agents overattend to social information and are not sensitive to the information provided by informed individuals; when it is too low, the group is likely to fragment and will not accurately share target-relevant information; meaning only the informed individuals will successfully reach the target. Fig. 3B shows that a similar optimal precision-balance exists for ΓzTarget. Here, we show average collective accuracy (averaged across values of pinf as a function of social- and target-precision. Maximizing collective accuracy appears to rely on agents balancing the sensory precision they assign to different sources of information; under the active inference model proposed here, this balancing act can be exactly formulated in terms of the variances (inverse precisions) afforded to different types of sensory cues.

Online Plasticity through Parameter Learning.

The ability of groups to tune their response to changing environmental contexts, such as rapid perturbations or informational changes, is a key feature of natural collective behavior (15, 54). However, many SPP models lack a generic way to incorporate this behavioral sensitivity (48) and exhibit damped, “averaging”-like responses to external inputs (60). This results from classical models usually equipping individuals with fixed interaction rules and constant weights for integrating different information sources. While online weight-updating rules and evolutionary algorithms have been used to adaptively tune single-agent parameters in some cases (48, 59, 61), these approaches are often not theoretically principled and driven by specific use-cases [with notable exceptions (6264)].

Active inference offers an account of tunable sensitivity, using the same principle used to derive action and belief-updating in previous sections: minimizing surprise. In practice, this sensitivity emerges when we allow agents to update their generative models per se in real-time. Updating generative model parameters over time is often referred to as “learning” in the active inference literature (65), since it invokes the notion of updating beliefs about parameters rather than states, where parameters and states distinguish themselves by fast and slow timescales of updating, respectively. We leverage this idea to allow agents to adapt their generative models and thus adapt their behavioral rules, referring to this process as plasticity, in line with the notion of short-term plasticity in neural circuits (66). To enable agents to update generative model parameters, we can simply augment the coupled gradient descent in Eq. 9 with an additional dynamical equation, this time by minimizing free energy with respect to model parameters, which we subsume into a set θ:

θ˙=θF(μ~,y~,θ). [19]

The generative model parameters θ represent the statistical contingencies or regularities agents believe govern their sensory world; this includes the various precisions associated with sensory and process noises Π~z,Π~ω and the parameters of the dynamics and observation models, f~,g~. Since the free energy is a smooth function of all the generative model parameters, in theory, learning can be done with respect to any parameter using the procedure entailed by Eq. 19.

In practice, combining parameter learning with active inference usually implies a separation of timescales, whereby learning or plasticity occurs concurrently to state inference and action but at a slower update rate. In all the results shown here, agents update parameters an order of magnitude more slowly than they update beliefs or actions. To furnish an interpretable example of plasticity, in the simulations described here, we enabled agents to update their beliefs about the sensory smoothness parameter λz. We chose sensory smoothness due to its straightforward relationship to the magnitude of sensory prediction errors (c.f. the relation in Eq. 16 and SI Appendix, section S3). As agents tune λz to minimize free energy, belief updating and action will at the same time become quadratically more or less responsive to sensory information.

One example of where behavioral plasticity is crucial for collective information processing is a group’s ability to rapidly amplify behaviorally relevant information, e.g., detecting the presence of a predator (6769). To study the effect of behavioral plasticity on collective responsiveness, we perturbed single agents in groups of active inference agents while enabling or disabling online plasticity. We perturbed groups by inducing transient “phantom” prediction errors in random subsets of agents and measuring the resulting turning response of the group (see Materials and Methods for details). These prediction errors were structured (Fig. 4A) to mimic a transient visual stimulus, e.g., a loom stimulus or approaching predator (70), which reliably induces a sustained turning response in the chosen individual (60). Fig. 4 shows the effect of enabling plasticity on the size and sensitivity of collective responses to these perturbations. Not only do plasticity-enabled groups respond more strongly to perturbations of single-agents, compared to their plasticity-disabled counterparts (Fig. 4B), but the magnitude of the collective response is also more sensitive to the size of the perturbation (Fig. 4C). As has been measured in biological collectives (71), the plasticity-enabled groups collectively encode the size of perturbations with a higher dynamic range than plasticity-disabled controls.

Fig. 4.

Fig. 4.

(A) Schematic of the sensory perturbation protocol. The “pseudomotion” stimulus consists of repetitively perturbing the agent’s sensory sectors with a moving wave of prediction errors in the agent’s velocity-observation modality yh. The Top panel shows the stimulus pattern as a heatmap over (amplitude over time) with two repetitions, starting from negative (red, sectors 1 and 2) and transitioning to positive (blue, sectors 3 and 4) prediction errors. The sign-switch in the stimulus (from negative to positive) mimics a moving object that first moves toward focal individual and then moves away. The temporal order of the stimulus across the sectors can be used to selectively emulate a right-moving vs. left-moving object, relative to the focal individual’s heading-direction. The Bottom panel shows how the stimulated agent’s beliefs about the distance hidden state μ changes over the course of the motion stimulus, with these beliefs being analogized to hypothetical neural activity. (B) Response magnitude to a perturbation in the presence or absence of parameter learning. Left panel: example pair of 2-D trajectories of active inference agents with matched preperturbation histories, in response to an individual perturbation. The ability to perform parameter learning is left on in one stochastic realization (green) and turned off in the other (blue), following the perturbation. Right panel: initialization-averaged collective responses (group turning angle) to perturbation of active inference agents when learning is enabled or disabled. The perturbation response of a 2-zone SPP model (purple line) based on ref. 48 is also shown for reference. (C) Collective response as a function of the number of perturbed individuals, comparing simulations where parameter learning is enabled to those where it’s disabled. Shown is the mean response with highest density regions (HDRs) of integrated turning magnitude within 500 to 1,000 ms of the perturbation (Left) and response probability (Right) computed from Ni=200 independent initializations of each condition. For each initialization, the average metric is computed across Nr=50 independent realizations that were run forward from the same point in time, following a sensory prediction error perturbation (to a randomly chosen set of perturbed agents). Response probability is computed as the proportion of independent realizations, per initialization, where the group turning rate exceeded π radians within the first 10 s of the perturbation.

The active inference framework provides a flexible and theoretically principled approach to modeling adaptive, collective behavior with tunable sensitivity, that eschews ad hoc update rules or expensive evolutionary simulations. The plasticity mechanism proposed here is not limited to updating beliefs about sensory smoothness: it can be extended to update beliefs about any model parameter using the same principle. The ability to adapt generative model parameters in real-time represents a promising avenue for future research in active inference and collective behavior and may lead to more biologically plausible hypotheses about the mechanisms underlying adaptive responses in the natural world.

Discussion

We have proposed active inference as a flexible, cognitively inspired model class that can be used in the theoretical study of collective motion, as well as in empirical settings as an individual-level model of behavior. By framing behavior as the consequence of prediction-error minimization—with respect to an individual’s world model—we offer examples of how naturalistic collective motion emerges in, where individual behavior is driven by the imperative to minimize the surprisal associated with sensory signals. Under mild distributional assumptions, this surprise is scored by an interpretable proxy; namely, prediction error. In the particular case of collective motion, a group of active inference agents equipped with a simple generative model of local social information can recover and generalize the social forces that have been the core mechanism in classical SPP models of collective motion. The active inference framework also provides a probabilistic interpretation of ad hoc “weight” parameters that are often used in these models, in terms of the precisions that agents associate with different types of sensory information.

We have also shown how the active inference framework can be used to characterize the relationship between generative model parameters and emergent information-processing capacities, as measured by collective information transfer and responsiveness to external perturbations. Active inference’s generality allows us to relax the typically static behavioral rules of SPP models, by enabling agents to flexibly tune their sensitivity to prediction errors. This is achieved via principled processes like parameter learning (i.e., “plasticity”), and can be used to model naturalistic features of collective behavior, such as the tendency to amplify salient (i.e., precise) information, that have largely evaded modeling in the SPP paradigm, except in cases where adaptation rules are explicitly introduced (48, 59). However, when we simply allow agents to update parameters, in addition to beliefs and agents, using the principle of surprise-minimization, many hallmarks of these naturalistic behaviors can be easily obtained.

The surprise minimization approach adopted here is both theoretically grounded in fundamental physical, cybernetic, and informational principles (23, 7274) while also biologically inspired, due to the scalability of the belief and action update rules, which are hypothesized to be implementable on neuronal circuits (43). Our approach thus also harmonizes with modern “data-driven” approaches in behavioral biology, that aim to quantitatively estimate the behavioral algorithms used by different biological systems directly from experimental data (1315).

By providing a flexible modeling approach that casts perception, action, and learning as manifestations of the single drive to minimize surprise, we have highlighted active inference as a toolbox for studying collective behavior in natural systems. Future work in this area could explore how the framework can be used to investigate other forms of collective behavior (not just collective motion), like multichoice decision-making, social foraging, and communication (75, 76). The results shown in the current work serve primarily as a proof of concept: we started by writing down a specific, hypothetical active inference model of agents engaged in group movement, and then generated naturalistic behaviors by integrating the resulting equations of motion (i.e., free energy gradients) for this particular model. Taking inspiration from fields like computational psychiatry (77, 78), we emphasize the ability to move from simple forward modeling of behavior to data-driven model inversion, whereby one hopes to infer the values of parameters that best explain empirical data (of e.g., behavioral movement data). Instead of using “force mapping” techniques to estimate social forces from behavioral measurements (79, 80), our approach would instead frame the problem as one of computational phenotyping, where alternative generative models that a particular animal might be equipped with, could be estimated from behavioral or neural data acquired from that animal. The resulting social forces or interaction rules would then emerge as those behaviors that minimize surprise, relative to the generative model that best explains the animal’s behavior. Both the estimation of model parameters and alternative model structures can be achieved through Bayesian model inversion and system identification methods like Bayesian model selection, averaging, or reduction (81).

Materials and Methods

For all simulations we randomly initialized the positions and (unit-magnitude) velocities of N particles, and integrated the equations of motion for active inference and generalized filtering using a forward Euler–Maruyama scheme with an integration window of Δt=0.01s (see SI Appendix, section S6 for details). We varied group size N and the length of the simulation T (in seconds) depending on the experiment. Detailed background on generalized filtering, active inference, and derivations specific to the generative model we used for collective motion can be found in SI Appendix, section S1. All other parameters used for simulations, unless stated otherwise, are listed in SI Appendix, Table S1. The code (written in JAX and Julia) used to perform simulations can be found in the following open-source repository: https://github.com/conorheins/collective_motion_actinf.

Quantifying Fragmented Groups.

For all experiments, we excluded trials where the group failed to maintain cohesion (or fragmented) to a sufficient degree. We deemed any given trial fragmented, when at least one individual was further than 2.0 dimensionless units away from all other individuals for at least 3 of the last 10 s of the trial. For the perturbation experiments, groups were excluded if this criterion was reached during the last 5 s of the 20 s postperturbation period.

Collective Information Transfer Experiments.

For each trial of collective target-navigation, we initialized a group of N=30 agents with random positions and velocities (centered on the origin) and augmented the generative models of a fixed proportion pinf of the total number of agents, where pinf ranged from 0.05 to 1.0, with extra latent and observed variables representing the distance to the target with position vector T. The distance to the target was always 10 units from the origin. We measured collective accuracy as follows: we count a given trial as successful if the group is able to navigate to within 0.25 units of the target without losing cohesion within T=15 s (the length of each trial). The accuracy for a given experimental condition was then computed as the proportion of successes observed in 500 total trials.

Perturbation Experiments.

For the perturbation experiments, we simulated Ni=200 randomly initialized independent runs of N=50 agents, which we term independent initializations. We ran each initialization forward for T=100 s, a point at which metrics like average polarization, angular momentum, and median nearest-neighbor distance were highly likely to have stopped changing and fluctuate around a stationary value. Starting at T=100 we then split each initialization into two further sets of Nr=50 parallel realizations. Each realization used a different random seed used to a) generate the action- and observation-noises; and b) select the candidate agent(s) for perturbation. Note that the splitting of seeds at T=100 means that each realization has an identical history up until that point. We enabled parameter learning of λz in one set of realizations and we left it disabled in the other. We then perturbed random subsets of agents in both learning-enabled and -disabled realizations (2 to 50% of the group, i.e., 1 to 25 agents), by transiently inducing first-order prediction errors ξz in the perturbed individuals (see SI Appendix, section S5 for perturbation details). We computed the relative group turning angle after the perturbation for 20 s to generate the plots in Fig. 4 B and C.

Supplementary Material

Appendix 01 (PDF)

Movie S1.

Example of a simulation of N = 96 agents that includes a dynamic transition from polarized to milling regime. Parameters: σz',h2=0.05; Sector angle = 80°; R0 = 10 units; κa = 0.2; λω = 0.5; λz = 2.0. Unless specified, all remaining parameters are as listed in Table S1.

Download video file (2.4MB, mp4)
Movie S2.

Example of a polarized group of N = 64 agents. Parameters: Sector angle = 80°;; κa = 0.2; λω = 0.5; λz = 1.5.

Download video file (2.4MB, mp4)
Movie S3.

Example of a milling regime observed in N = 64 agents. Parameters: σz',h2=0.04; Sector angle = 80°; α = 1.0; κa = 0.2; λω = 0.8; λz = 1.8.

Download video file (2.4MB, mp4)
Movie S4.

Example of a disordered regime observed in N = 96 agents. Parameters: Number of sensory sectors = 2; Sector angle = 160°; R0 = 10.0 units; α = 0.2; η = 0.5, κa = 0.2; λω = 0.1; λz = 1.787.

Download video file (2.4MB, mp4)
Movie S5.

Metastable ‘snaking’ configuration observed in N = 64 agents. Parameters: σz',h2=0.04; Sector angle = 80°; α = 0.1; κa = 0.2; λω = 0.5; λz = 2.2.

Download video file (2.4MB, mp4)

Acknowledgments

We would like to thank Brennan Klein, Jake Graving, Armin Bahl, Dimitrije Markovic, Thomas Parr, Pawel Romanczuk, and Manuel Baltieri for discussions during the writing of this manuscript, and Maya Polovitskaya for creating the fish schematic used in the figures. C.H. and I.D.C. acknowledge support from the Office of Naval Research Grant N0001419-1-2556, Germany’s Excellence Strategy-EXC 2117-422037984 (to I.D.C.), the Max Planck Society, the European Union’s Horizon 2020 research and Innovation Programme under the Marie Skłodowska-Curie Grant agreement (to I.D.C.; #860949), the PathFinder European Innovation Council Work Programme (to I.D.C.; #101098722), and the John Templeton Foundation (to C.H.; #61780). L.D.C. is supported by the Fonds National de la Recherche, Luxembourg (Project code: 13568875) and the Engineering and Physical Sciences Research Council Centre for Doctoral Training in Mathematics of Random Systems: Analysis, Modelling and Simulation (EP/S023925/1). R.P.M. is supported by UK Research and Innovation Future Leaders Fellowship (MR/S032525/1) and the Templeton World Charity Foundation Inc. (TWCF-2021-20647). K.F. is supported by funding for the Wellcome Centre for Human Neuroimaging (Ref: 205103/Z/16/Z), a Canada-UK Artificial Intelligence Initiative (Ref: ES/T01279X/1) and the European Union’s Horizon 2020 Framework Programme for Research and Innovation under the Specific Grant Agreement No. 945539 (Human Brain Project SGA3).

Author contributions

C.H., B.M., L.D.C., R.P.M., K.J.F., and I.D.C. designed research; C.H. performed research; C.H. contributed new reagents/analytic tools; C.H. analyzed data; C.H., B.M., L.D.C., R.P.M., and I.D.C. editing/review of the manuscript; K.J.F. editing/review of the manuscript and software consultation; and C.H., L.D.C., and I.D.C. wrote the paper.

Competing interests

The authors declare no competing interest.

Footnotes

This article is a PNAS Direct Submission.

Contributor Information

Conor Heins, Email: cheins@ab.mpg.de.

Iain D. Couzin, Email: icouzin@ab.mpg.de.

Data, Materials, and Software Availability

Github repository data have been deposited in https://github.com/conorheins/collective_motion_actinf (82).

Supporting Information

References

  • 1.Major P. F., Dill L. M., The three-dimensional structure of airborne bird flocks. Behav. Ecol. Sociobiol. 4, 111–122 (1978). [Google Scholar]
  • 2.Camazine S., et al. , Self-Organization in Biological Systems (Princeton University Press, 2003). [Google Scholar]
  • 3.M. Rubenstein, C. Ahler, R. Nagpal, “Kilobot: A low cost scalable robot system for collective behaviors” in 2012 IEEE International Conference on Robotics and Automation (IEEE, 2012), pp. 3293–3298.
  • 4.Aoki I., A simulation study on the schooling mechanism in fish. Nippon Suisan Gakkaishi 48, 1081–1088 (1982). [Google Scholar]
  • 5.C. W. Reynolds, “Flocks, herds and schools: A distributed behavioral model” in Proceedings of the 14th annual conference on Computer graphics and interactive techniques (1987), pp. 25–34.
  • 6.Vicsek T., Czirók A., Ben-Jacob E., Cohen I., Shochet O., Novel type of phase transition in a system of self-driven particles. Phys. Rev. Lett. 75, 1226 (1995). [DOI] [PubMed] [Google Scholar]
  • 7.Couzin I. D., Krause J., James R., Ruxton G. D., Franks N. R., Collective memory and spatial sorting in animal groups. J. Theor. Biol. 218, 1–12 (2002). [DOI] [PubMed] [Google Scholar]
  • 8.Toner J., Tu Y., Flocks, herds, and schools: A quantitative theory of flocking. Phys. Rev. E 58, 4828 (1998). [Google Scholar]
  • 9.Sumpter D. J., The principles of collective animal behaviour. Philos. Trans. R. Soc. B: Biol. Sci. 361, 5–22 (2006). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 10.Bertin E., Droz M., Grégoire G., Boltzmann and hydrodynamic description for self-propelled particles. Phys. Rev. E 74, 022101 (2006). [DOI] [PubMed] [Google Scholar]
  • 11.Degond P., Motsch S., Continuum limit of self-driven particles with orientation interaction. Math. Models Methods Appl. Sci. 18, 1193–1215 (2008). [Google Scholar]
  • 12.Herbert-Read J. E., et al. , Inferring the rules of interaction of shoaling fish. Proc. Natl. Acad. Sci. U.S.A. 108, 18726–18731 (2011). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Calovi D. S., et al. , Swarming, schooling, milling: Phase diagram of a data-driven fish school model. New J. Phys. 16, 015026 (2014). [Google Scholar]
  • 14.Hein A. M., et al. , An algorithmic approach to natural behavior. Curr. Biol. 30, R663–R675 (2020). [DOI] [PubMed] [Google Scholar]
  • 15.Fahimipour A. K., et al. , Wild animals suppress the spread of socially transmitted misinformation. Proc. Natl. Acad. Sci. U.S.A. 120, e2215428120 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 16.Gautrais J., et al. , Deciphering interactions in moving animal groups. PLoS Comput. Biol. 8, e1002678 (2012). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 17.Katz Y., Tunstrøm K., Ioannou C. C., Huepe C., Couzin I. D., Inferring the structure and dynamics of interactions in schooling fish. Proc. Natl. Acad. Sci. U.S.A. 108, 18720–18725 (2011). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18.Friston K. J., Daunizeau J., Kiebel S. J., Reinforcement learning or active inference? PLoS ONE 4, e6421 (2009). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 19.Friston K., FitzGerald T., Rigoli F., Schwartenbeck P., Pezzulo G., Active inference: A process theory. Neural Comput. 29, 1–49 (2017). [DOI] [PubMed] [Google Scholar]
  • 20.Parr T., Pezzulo G., Friston K. J., Active Inference: The Free Energy Principle in Mind, Brain, and Behavior (MIT Press, 2022). [Google Scholar]
  • 21.Da Costa L., et al. , Active inference on discrete state-spaces: A synthesis. J. Math. Psychol. 99, 102447 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 22.Friston K., A theory of cortical responses. Philos. Trans. R. Soc. B: Biol. Sci. 360, 815–836 (2005). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 23.Friston K., Kilner J., Harrison L., A free energy principle for the brain. J. Physiol.-Paris 100, 70–87 (2006). [DOI] [PubMed] [Google Scholar]
  • 24.Friston K., What is optimal about motor control? Neuron 72, 488–498 (2011). [DOI] [PubMed] [Google Scholar]
  • 25.Friston K., et al. , The free energy principle made simpler but not too simple. Phys. Rep. 1024, 1–29 (2023). [Google Scholar]
  • 26.Rao R. P., Ballard D. H., Predictive coding in the visual cortex: A functional interpretation of some extra-classical receptive-field effects. Nat. Neurosci. 2, 79–87 (1999). [DOI] [PubMed] [Google Scholar]
  • 27.Adams R. A., Shipp S., Friston K. J., Predictions not commands: Active inference in the motor system. Brain Struct. Funct. 218, 611–643 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 28.Ali A., Ahmad N., de Groot E., van Gerven M. A. J., Kietzmann T. C., Predictive coding is a consequence of energy efficiency in recurrent neural networks. Patterns 3, 100639 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 29.Caucheteux C., Gramfort A., King J. R., Evidence of a predictive coding hierarchy in the human brain listening to speech. Nat. Hum. Behav. 7, 430–441 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 30.Laland K. N., Social learning strategies. Anim. Learn. Behav. 32, 4–14 (2004). [DOI] [PubMed] [Google Scholar]
  • 31.Krafft P. M., et al. , Bayesian collective learning emerges from heuristic social learning. Cognition 212, 104469 (2021). [DOI] [PubMed] [Google Scholar]
  • 32.M. Baltieri, C. L. Buckley, Generative models as parsimonious descriptions of sensorimotor loops. arXiv [Preprint] (2019). 10.1017/S0140525X19001353 (Accessed 4 May 2023). [DOI] [PubMed]
  • 33.Uran C., et al. , Predictive coding of natural images by v1 firing rates and rhythmic synchronization. Neuron 110, 1240–1257.e8 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34.Friston K., The free-energy principle: A rough guide to the brain? Trend. Cognit. Sci. 13, 293–301 (2009). [DOI] [PubMed] [Google Scholar]
  • 35.Hohwy J., The self-evidencing brain. Noûs 50, 259–285 (2016). [Google Scholar]
  • 36.K. Friston, A free energy principle for a particular physics. arXiv [Preprint] (2019). 10.48550/arXiv.1906.10184 (Accessed 10 January 2021). [DOI]
  • 37.Collignon B., Séguret A., Halloy J., A stochastic vision-based model inspired by zebrafish collective behaviour in heterogeneous environments. R. Soc. Open Sci. 3, 150473 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 38.Bastien R., Romanczuk P., A model of collective behavior based purely on vision. Sci. Adv. 6, eaay0792 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 39.Friston K., Stephan K., Li B., Daunizeau J., Generalised filtering. Math. Problems Eng. 2010, 621670 (2010). [Google Scholar]
  • 40.Friston K., Mattout J., Trujillo-Barreto N., Ashburner J., Penny W., Variational free energy and the Laplace approximation. Neuroimage 34, 220–234 (2007). [DOI] [PubMed] [Google Scholar]
  • 41.MacKay D. J., Mac Kay D. J., Information Theory, Inference and Learning Algorithms (Cambridge University Press, 2003). [Google Scholar]
  • 42.Jehee J. F., Rothkopf C., Beck J. M., Ballard D. H., Learning receptive fields using predictive feedback. J. Physiol.-Paris 100, 125–132 (2006). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 43.Spratling M. W., A review of predictive coding algorithms. Brain Cognit. 112, 92–97 (2017). [DOI] [PubMed] [Google Scholar]
  • 44.Maselli A., Lanillos P., Pezzulo G., Active inference unifies intentional and conflict-resolution imperatives of motor control. PLoS Comput. Biol. 18, e1010095 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 45.Baltieri M., Buckley C. L., PID control as a process of active inference with linear generative models. Entropy 21, 257 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 46.Buckley C. L., Kim C. S., McGregor S., Seth A. K., The free energy principle for action and perception: A mathematical review. J. Math. Psychol. 81, 55–79 (2017). [Google Scholar]
  • 47.Romanczuk P., Couzin I. D., Schimansky-Geier L., Collective motion due to individual escape and pursuit response. Phys. Rev. Lett. 102, 010602 (2009). [DOI] [PubMed] [Google Scholar]
  • 48.Couzin I. D., Krause J., Franks N. R., Levin S. A., Effective leadership and decision-making in animal groups on the move. Nature 433, 513–516 (2005). [DOI] [PubMed] [Google Scholar]
  • 49.Becco C., Vandewalle N., Delcourt J., Poncin P., Experimental evidences of a structural and dynamical transition in fish school. Physica A 367, 487–493 (2006). [Google Scholar]
  • 50.Tunstrøm K., et al. , Collective states, multistability and transitional behavior in schooling fish. PLoS Comput. Biol. 9, e1002915 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 51.Giardina I., Collective behavior in animal groups: Theoretical models and empirical studies. HFSP J. 2, 205–219 (2008). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 52.Kaufmann R., Gupta P., Taylor J., An active inference model of collective intelligence. Entropy 23, 830 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 53.C. Heins, B. Klein, D. Demekas, M. Aguilera, C. L. Buckley, “Spin glass systems as collective active inference” in Active Inference: Third International Workshop, IWAI 2022, Grenoble, France, September 19, 2022, Revised Selected Papers (Springer, 2023), pp. 75–98.
  • 54.Sosna M. M., et al. , Individual and collective encoding of risk in animal groups. Proc. Natl. Acad. Sci. U.S.A. 116, 20556–20561 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 55.Parr T., Limanowski J., Rawji V., Friston K., The computational neurology of movement under active inference. Brain 144, 1799–1818 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 56.Buhl J., et al. , From disorder to order in marching locusts. Science 312, 1402–1406 (2006). [DOI] [PubMed] [Google Scholar]
  • 57.Couzin I. D., et al. , Uninformed individuals promote democratic consensus in animal groups. Science 334, 1578–1580 (2011). [DOI] [PubMed] [Google Scholar]
  • 58.Strandburg-Peshkin A., Farine D. R., Couzin I. D., Crofoot M. C., Shared decision-making drives collective movement in wild baboons. Science 348, 1358–1361 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 59.Sridhar V. H., et al. , The geometry of decision-making in individuals and collectives. Proc. Natl. Acad. Sci. U.S.A. 118, e2102157118 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 60.Kolpas A., et al. , How the spatial position of individuals affects their influence on swarms: A numerical comparison of two popular swarm dynamics models. PLoS ONE 8, e58525 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 61.Bizyaeva A., Franci A., Leonard N. E., Nonlinear opinion dynamics with tunable sensitivity. IEEE Trans. Autom. Control 68, 1415–1430 (2022). [Google Scholar]
  • 62.H. Hamann, “Evolution of collective behaviors by minimizing surprise” in Artificial Life Conference Proceedings (MIT Press One, Cambridge, MA, 2014), pp. 344–351.
  • 63.Kaiser T. K., Hamann H., Innate motivation for robot swarms by minimizing surprise: From simple simulations to real-world experiments. IEEE Trans. Robot. 38, 3582–3601 (2022). [Google Scholar]
  • 64.Gandolfi D., et al. , Emergence of associative learning in a neuromorphic inference network. J. Neural Eng. 19, 036022 (2022). [DOI] [PubMed] [Google Scholar]
  • 65.Friston K., et al. , Active inference and learning. Neurosci. Biobehav. Rev. 68, 862–879 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 66.Hennig M. H., Theoretical models of synaptic short term plasticity. Front. Comput. Neurosci. 7, 45 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 67.Ward A. J., Herbert-Read J. E., Sumpter D. J., Krause J., Fast and accurate decisions through collective vigilance in fish shoals. Proc. Natl. Acad. Sci. U.S.A. 108, 2312–2315 (2011). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 68.Strandburg-Peshkin A., et al. , Visual sensory networks and effective information transfer in animal groups. Curr. Biol. 23, R709–R711 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 69.Davidson J. D., et al. , Collective detection based on visual information in animal groups. J. R. Soc. Interface 18, 20210142 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 70.Harpaz R., Nguyen M. N., Bahl A., Engert F., Precise visuomotor transformations underlying collective behavior in larval zebrafish. Nat. Commun. 12, 6578 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 71.Gómez-Nava L., et al. , Fish shoals resemble a stochastic excitable system driven by environmental perturbations. Nat. Phys. 19, 663–669 (2023). [Google Scholar]
  • 72.Conant R. C., Ashby W. R., Every good regulator of a system must be a model of that system. Int. J. Syst. Sci. 1, 89–97 (1970). [Google Scholar]
  • 73.Wissner-Gross A. D., Freer C. E., Causal entropic forces. Phys. Rev. Lett. 110, 168702 (2013). [DOI] [PubMed] [Google Scholar]
  • 74.Hornischer H., Herminghaus S., Mazza M. G., Structural transition in the collective behavior of cognitive agents. Sci. Rep. 9, 12477 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 75.Friedman D. A., Tschantz A., Ramstead M. J., Friston K., Constant A., Active inferants: An active inference framework for ant colony behavior. Front. Behav. Neurosci. 15, 647732 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 76.Albarracin M., Demekas D., Ramstead M. J., Heins C., Epistemic communities under active inference. Entropy 24, 476 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 77.Montague P. R., Dolan R. J., Friston K. J., Dayan P., Computational psychiatry. Trend Cognit. Sci. 16, 72–80 (2012). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 78.Smith R., Badcock P., Friston K. J., Recent advances in the application of predictive coding and active inference models within clinical neuroscience. Psych. Clin. Neurosci. 75, 3–13 (2020). [DOI] [PubMed] [Google Scholar]
  • 79.Escobedo R., et al. , A data-driven method for reconstructing and modelling social interactions in moving animal groups. Philos. Trans. R. Soc. B 375, 20190380 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 80.Mudaliar R. K., Schaerf T. M., An examination of force maps targeted at orientation interactions in moving groups. PLoS ONE 18, e0286810 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 81.Penny W. D., Mattout J., Trujillo-Barreto N., Bayesian Model Selection and Averaging. Statistical Parametric Mapping: The Analysis of Functional Brain Images (Elsevier, London, UK, 2006). [Google Scholar]
  • 82.C. Heins, Collective motion ActInf. Github. https://github.com/conorheins/collective_motion_actinf. Deposited 27 July 2023.

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Appendix 01 (PDF)

Movie S1.

Example of a simulation of N = 96 agents that includes a dynamic transition from polarized to milling regime. Parameters: σz',h2=0.05; Sector angle = 80°; R0 = 10 units; κa = 0.2; λω = 0.5; λz = 2.0. Unless specified, all remaining parameters are as listed in Table S1.

Download video file (2.4MB, mp4)
Movie S2.

Example of a polarized group of N = 64 agents. Parameters: Sector angle = 80°;; κa = 0.2; λω = 0.5; λz = 1.5.

Download video file (2.4MB, mp4)
Movie S3.

Example of a milling regime observed in N = 64 agents. Parameters: σz',h2=0.04; Sector angle = 80°; α = 1.0; κa = 0.2; λω = 0.8; λz = 1.8.

Download video file (2.4MB, mp4)
Movie S4.

Example of a disordered regime observed in N = 96 agents. Parameters: Number of sensory sectors = 2; Sector angle = 160°; R0 = 10.0 units; α = 0.2; η = 0.5, κa = 0.2; λω = 0.1; λz = 1.787.

Download video file (2.4MB, mp4)
Movie S5.

Metastable ‘snaking’ configuration observed in N = 64 agents. Parameters: σz',h2=0.04; Sector angle = 80°; α = 0.1; κa = 0.2; λω = 0.5; λz = 2.2.

Download video file (2.4MB, mp4)

Data Availability Statement

Github repository data have been deposited in https://github.com/conorheins/collective_motion_actinf (82).


Articles from Proceedings of the National Academy of Sciences of the United States of America are provided here courtesy of National Academy of Sciences

RESOURCES