Active Inference InstituteSimulations

Beyond the TextbookIntermediateNew

When to go out

A colony of red harvester ants has no one in charge, yet minute by minute it settles how many foragers to send into the desert. Each forager waiting inside the entrance counts brief meetings with nestmates coming home with seeds, and leaves when it has met enough. Going out costs water. Seeds give water back.

Instruments

Ants per minute at the entrance30 s average, 10 min

The count inside one antlast 60 s

Waiting in the entrance
Outside
Upper line θ (leave)
Seeds brought in
Water: repaid − spent
Model time

This page is an educational illustration made by the Active Inference Institute. It presents field research from Deborah M. Gordon's laboratory at Stanford University, including the doctoral research of Daniel Ari Friedman, now at the Institute. It has not been reviewed by the authors of the studies it draws on. Where it reports their findings it gives their numbers and a source. Where it goes beyond them it says so.

AII: EduActive · Watch, then do

Three short clips, three things to try

These three passages come from two of the Institute’s livestreams on a paper about ant colonies and active inference. Each is one to two and a half minutes. Watch one, then press its button and look for the same thing at the nest above.

  1. Plays here, from 33:03. Nothing loads from YouTube until you press play.Open on YouTube at 33:03

    Before you start

    No one in charge

    An ant colony has no leader, and its ants cannot signal over long distances. Each ant decides for itself, using only what it has just met. If it meets something often, it becomes more likely to act on it.

    Listen for
    The way it works is that individual ants make probabilistic decisions about behaviour based upon the rate and type of interactions they receive.
    Then try
    The page will pick one waiting ant and draw the count it keeps. Say what you expect the line to do at each meeting, and what you expect it to do between meetings. Then watch the trace.
    In the model the count s

    The speaker’s worked example is refuse work, not foraging: an ant that meets rubbish at a high rate becomes more likely to pick some up. This page applies a rule of the same kind to a different decision, whether a forager waiting in the entrance leaves the nest.

    The speaker says such rules can be written as a drift diffusion model or a response threshold model. The page uses one published drift diffusion model. The decision state s rises by k at each contact, falls at the bias rate d between contacts, and the ant leaves when s reaches the upper line θ. The button sets the noise σ to zero so that the two movements are easy to see.

    The count inside one ant · Mean time to decide

  2. Plays here, from 77:14. Nothing loads from YouTube until you press play.Open on YouTube at 77:14

    While it runs

    Returns set the outgoing rate

    Ants waiting inside the nest meet foragers coming home with food. When many come home, more go out. When few come home, the stream going out dries up. The colony adjusts itself, and no ant needs to know why.

    Listen for
    If you block incoming foragers from coming in, there’s a lag followed by a drop-off in foragers leaving. And if you have an excess of foragers coming in, it leads to an excess going out.
    Then try
    Returning foragers are about to be held back for two minutes of model time. Say how long you expect the outgoing line to hold up, and what you expect when the ants are let go. Then read the chart.
    In the model the rate r

    On the page the feedback runs through the contact rate r. The mean drift of an ant’s count is d + k·r. Above the rate r* = −d/k the count climbs on average and ants leave; below it the count falls and they go back down. In this model the outgoing line drops within about one minute of a removal, which is quicker than the two to three minutes reported from the field.

    The passage ends with a hypothesis about dopamine: that it changes how sensitive an ant is to its interactions. The page does something different. Its treatment multiplies the policy precision γ, which moves the upper line θ (down when γ is raised), and leaves the interaction sensitivity k alone. Both would send more ants out; the page does not decide between them.

    Mean time to decide, and the chance of leaving · Policy precision and the upper line

  3. Plays here, from 53:08. Nothing loads from YouTube until you press play.Open on YouTube at 53:08

    Afterwards

    A forager has no dashboard

    A forager cannot see how many seeds are stored, how many mouths there are to feed, or how much food is outside. It still has to choose: stay in, or go out. That is a decision made without knowing the facts for certain.

    Listen for
    It is faced with this go/no-go decision, stay home or forage, which is influenced by environmental features that it may not have total awareness of.
    Then try
    On a dry day a trip costs more water. The ants are not told this is a dry day. Say whether you think the colony will forage at all at a humidity of 0.15. Then look at the upper line and the water balance.
    In the model G(go) and G(wait)

    The page turns “to forage or not to forage” into a comparison of two policies. The ant holds a belief about whether food is rich or poor, kept as log-odds. Going has two outcomes, ahead or behind in water; waiting has one. The ant goes when “go” is the more probable policy, and that condition is a bound on the log-odds: the upper line θ(h, γ). Lower the humidity and the line rises.

    The speaker compares the choice to an investor’s and gives no equations in this passage. The expected free energy reading is this page’s own. It is minimal: two hypotheses about food, one step of planning, fixed preferences, and a water cost whose numbers are settings.

    Expected free energy of go and wait · The bound and the upper line

The quoted lines are taken from the automatic captions, with punctuation added and hesitations removed. The speakers are discussing ants in general and a different model, not this page; where the two differ, the notes say so. Each clip stops at the end of the passage. The full recordings are listed under Sources.

Learn by doing

Try this

  1. Starve the tunnel. Predict how long the outgoing stream lasts once returners stop arriving. Then remove them for two minutes at four times real speed and read the outgoing line.
  2. A good seed year. Predict which rises first when food triples: ants coming in, or ants going out. Then triple it.
  3. Take the noise away. Predict what is left of the difference between the published count and the exact log-odds when σ is zero.
  4. The dry day. Predict whether this colony will forage at all at a humidity of 0.15. Then look at the upper line and the water balance.
  5. Does restraint pay? Predict which of two colonies ends a dry week with more water: the one that goes out readily, or the one that holds back. Then predict a humid week.

The mathematics

What is being computed

The model has two layers, and they are kept apart. Layer 1 is published ethology: the decision model of a single forager, the feedback between returning and outgoing foragers, and the water cost of a trip. Layer 2 is an active inference reading of the same decision, made for this page. It supplies one thing to the running model: where the upper line sits as humidity and policy precision change.

Layer 1 · the count inside one ant

Davidson et al. (2016), equation 2 ds=(d+k∑jδ(t−tj))dt+σdη(t)

s is the decision state of a waiting ant. Each contact, at time tj, adds k, the interaction sensitivity. Between contacts s moves at the constant bias rate, which the paper writes γ and this page writes d, because γ is needed below for precision. η is a Wiener process (accumulating random noise) of amplitude σ. The ant leaves to forage when s reaches the upper line θ and returns to the deeper nest when s reaches −1. In the paper the upper line is fixed at 1. The bias here is constant; it is not a leak proportional to s. The authors note that a model with a leak might fit as well.

Mean time to decide, and the chance of leaving (first passage) 12σ2T″(s)+dT′(s)+r[T(s+k)−T(s)]=−1,T(−1)=T(s≥θ)=0

If contacts arrive as a Poisson process of rate r, the mean time T(s) until an ant starting at s reaches either line obeys this equation. The same equation with 0 on the right and u(s ≥ θ) = 1 gives u, the probability of leaving. The page solves both on a grid and prints them beside what the colony on the stage has just done. An ant that gives up rests in the deeper nest for a mean of Tdeep and tries again, so the mean time from first arriving to leaving is (T + (1 − u)·Tdeep)/u. The mean drift of s is d + k·r: above the rate r* = −d/k the count climbs on average, below it the count falls.

Layer 1 · water

Water balance of one trip (settings, in units of the water one seed repays) Δwater=g−w(h)Ttrip,w(h)=wd(1−whh)

An ant outside loses water at the rate w, which falls as humidity h rises. A seed repays g. A trip lasts the walk out and back plus a search whose length is random with mean 90 s divided by the food setting. A trip shorter than T* = g/w(h) repays its water. The form of w(h) and its numbers are settings of this page, not measurements.

Layer 2 · the same count as Bayesian evidence

Log posterior odds for Poisson contacts at one of two rates L(t)=lnP(rich∣contacts)P(poor∣contacts)=L0+nlnλ1λ0−(λ1−λ0)t

Suppose the ant entertains two hypotheses: food is rich and contacts come at rate λ1, or food is poor and they come at the lower rate λ0. After n contacts in a time t, the probability of what it has experienced is proportional to λne−λt under either rate. Dividing one by the other and taking logarithms gives the line above. Each contact adds ln(λ1/λ0). Each second without a contact subtracts λ1 − λ0: silence is evidence too. This is the published equation without its noise term, with L = L0 + Bu·s, k = ln(λ1/λ0)/Bu and d = −(λ1 − λ0)/Bu, where Bu is the number of nats in one unit of s. The exact Bayesian drift is constant, as the published bias is. A leaky integrator, whose decay is proportional to its level, would not be exact for this problem. Davidson and colleagues did not present their model as Bayesian and wrote that they did not attempt to define an optimal response for a single ant; the reading is this page's.

Layer 2 · go or wait

Expected free energy of a policy, one step ahead (textbook eq. 2.6 form: risk + ambiguity) G(π)=DKL[Q(o∣π)‖P(o)]+EQ(s∣π)[H[P(o∣s)]]

A policy π is a course of action: here, go or wait. The outcomes o of going are ahead (the trip repays its water) or behind (it does not); the outcome of waiting is none. Q(o | π) is what the ant expects to observe under each policy, given its belief about food. P(o) holds its preferences: it prefers ahead to none, and none to behind. The first term, risk, is how far the expected outcomes are from the preferred ones. The second, ambiguity, is how uncertain the outcome remains even if the state were known. The probabilities of ahead and behind come from the water equation above, so humidity enters here. Lower G is better.

Policy posterior, precision, and the bound it implies Q(π)=σ(lnE−γG),go whenG(wait)−G(go)>eγ

σ here is the softmax function. E is a prior over policies, a habit: it favours waiting by e nats. γ is the precision of beliefs about policies, the quantity that active inference associates with dopamine (Schwartenbeck et al. 2015; Friston et al. 2017). The ant goes when "go" is the more probable policy. Because G(wait) − G(go) rises with the belief that food is rich, this is a bound on the log-odds, B(h, γ), and so an upper line for the count: θ(h, γ) = (B(h, γ) − L0)/Bu, scaled so that θ = 1 at humidity 0.5 and γ = 1. Raising γ shrinks e/γ, so less evidence is needed. When no belief is enough, θ is infinite and no ant leaves.

In a sense, striatal dopamine can be thought of as modulating the balance between inferring what to do and what not to do (Parr 2020).Parr, Pezzulo & Friston (2022), Active Inference, chapter 5, p. 94. Written about the basal ganglia of vertebrates, which ants do not have.

Settings of this page

QuantityValueWhere it comes from

The model's tests are in simulations/tests/harvester_ants.test.js. They check the log-odds formula against brute-force Bayes, the first-passage analysis against an independent simulation, the expected free energy identities, and the behaviours claimed on this page.

Reading

Where this comes from

What is established

Red harvester ants forage for scattered seeds that one ant can carry, and foragers are not sent out by pheromone trails. The rate at which foragers leave the nest depends on the rate at which foragers return with food. This was shown by keeping returning foragers from the nest for a few minutes (Gordon, Holmes & Nacu 2008; Prabhakar, Dektar & Gordon 2012; Gordon, Dektar & Pinter-Wollman 2013). Colonies differ in how readily they adjust (Gordon, Guetz, Greene & Holmes 2011). The intervals between returning foragers are well described by a Poisson process (Prabhakar, Dektar & Gordon 2012).

The link is made inside the entrance, by brief antennal contacts. Pinter-Wollman and colleagues (2013) reported that a forager left the nest 3–8 s after a substantial increase in its interactions with returning foragers, and that when returns were interrupted for more than 4–5 min, waiting foragers went deeper into the nest. Greene, Pinter-Wollman and Gordon (2013) found that the combined odours of a forager's cuticular hydrocarbons and of seeds are needed to stimulate foraging.

Davidson and colleagues (2016) tracked individual ants in the entrance chamber. Ants that left to forage tended to have met returning foragers at a higher rate than ants that went back down. Their decision model, used on this page, reproduced the main trends. They state that the data do not tightly constrain its parameters or its form.

Colonies differ, and the differences last. Gordon (2013) reported that colonies with more offspring colonies tended to forage less when conditions were dry and showed relatively stable foraging when it was more humid, and that colonies which did not forage at all on many days survived as long as those that foraged more regularly. Gordon, Dektar and Pinter-Wollman (2013) found that the effect of each returning forager on the outgoing rate increases with humidity.

Friedman and colleagues (2018) gave foragers dopamine by mouth, which raised brain dopamine 2.67-fold at the dose used in the field. Treated foragers made on average 20.5% more trips than control-treated nestmates in 2016 and 10.3% more in 2017, in the same nine colonies. Foragers given 3-iodotyrosine, an inhibitor of dopamine synthesis, made 19.1% fewer. Colonies that reduced foraging more strongly in dry conditions were more responsive to dopamine. Friedman and colleagues (2020) found that differences among colonies in gene expression in forager brains were associated with the sensitivity of foraging to humidity and with the ratio of dopamine to serotonin in forager brains.

The proposal that dopamine reports the precision of beliefs about policies comes from work on vertebrates (Schwartenbeck et al. 2015; Friston et al. 2017). Friedman and colleagues (2021) built an active inference model of ant colony foraging for a different task, trail formation in a T-maze, and suggested that learning of precision would be worth simulating in ant colonies.

What this model leaves out

The reading in layer 2 is this page's. None of the field studies tested an active inference model. That dopamine increases trips in the field and that higher policy precision increases trips in this model agree in direction; no more is claimed. Friedman and colleagues (2018) offer several other accounts of their result, among them that dopamine changes an ant's sensitivity to contacts or its perception of its own state.

How humidity enters is an assumption. The published decision model has a fixed upper line. Davidson and colleagues suggest that conditions may shift the interaction sensitivity or the bias. Here humidity moves the upper line instead, by the expected free energy calculation, and the lower line stays put. The floor of 0.25 on the upper line is a setting.

Time and size are compressed. A trip here lasts about two minutes so that the feedback can be watched. The ants are drawn several times too large for the mound, which in the field is one to two metres across (Sturgis, Greene & Gordon 2011). There are 220 foragers; colonies have thousands. The light changes through the morning, but only humidity changes the water cost.

Much of the biology is absent. Patrollers, who go out first and set the day's directions (Greene & Gordon 2007). Neighbouring colonies. Temperature. The spatial clustering of contacts in the chamber. Differences between individual ants. Serotonin, tyramine and octopamine. The water model is a sketch: one rate, one seed value.

The ant's model of the world is minimal. Two hypotheses about food, one step of planning, fixed preferences. Contacts in the colony on the stage are not exactly Poisson, since returns come in bursts after a removal. The published model includes noise that the Bayesian quantity does not have.

What did not come out. In the field, foraging usually fell within two to three minutes of a removal. Here it falls within about one, because the published bias rate empties an ant's count in roughly half a minute. Restraint pays in water on dry days in this model and costs water on humid days; over a mixed week the readier colony can end ahead. Raising γ beyond about one and a half times its starting value added few further trips in the tests. The model has no offspring colonies and says nothing about reproductive success.

The free energy principle is a modelling framework. This page is an illustration of it and is not evidence for it.

Daniel Ari Friedman in the field, wearing a sun hat, with desert mountains behind him

The researcher

Daniel Ari Friedman

President & Treasurer, Board of Directors, Active Inference Institute

Daniel Friedman studied colonies of the red harvester ant for his doctorate in the Department of Biology at Stanford University (2019). His thesis is titled “Behavioral, physiological, and transcriptomic variation among colonies of the red harvester ant (Pogonomyrmex barbatus)”. With colleagues he reported that brain dopamine affects how often foragers leave the nest (2018), and he is first author of “Active Inferants” (2021), which treats ant colony behaviour as active inference.

Board of Directors · Thesis record at Stanford