Epidemic ModelingCore models

Module 6Multi-agent simulation

Agent-based models simulate every person. We build agents with states, rules and neighbours, check that average agents give back the SIR equations, and see what heterogeneity changes. Agents can compute anything, which costs prediction, and their contact loops cost time. Then the building blocks: time steps or events, the update order, the neighbourhood, seeds and reproducibility, common random numbers for sharp comparisons, and richer agents. We finish with two case studies in a toy town (a flu-like illness with a school closure, a COVID-like illness with isolation and behaviour), seven design steps, sensitivity analysis, and the ethics and policy risks of these models.

By the end you should be able to design a small agent-based epidemic model, choose its time step, update order and geometry on purpose, make it reproducible, compare policies with common random numbers, and report its uncertainty, privacy and equity issues honestly.

Key ideas, one per episode

  • Ep. 20Average agents give back SIR; spread-out agents do not. Agents can compute anything, and their contact loops cost time.
  • Ep. 21The time step, the update order and the neighbourhood are modeling choices that change the epidemic.
  • Ep. 22Seeds make runs reproducible; common random numbers make policy comparisons sharp; every richer rule needs data.
  • Ep. 23Structure shows who is infected and where; delays decide what isolation can do; behaviour feeds back.
  • Ep. 24Seven steps: a question with an output, coarse agents, contacts by setting, stage shapes, rules, a deliberate start, enough runs.
  • Ep. 25Split uncertainty into inputs and chance, couple runs for sensitivity, protect privacy, report by group, and don't let detail pass for certainty.

Textbook: Chapter 6 of T. Lazebnik, Epidemic Modeling: Principles, Algorithms, and Applications (Academic Press, 2026). The episodes and slides follow the chapter’s topics in our own words, figures and simulations; nothing is copied from the book.

The title slide of Module 6: Multi-agent simulation

38 slides, written to be read on your own, with worked examples, “try it” boxes, our own small simulations and check-yourself questions (answers at the end). PDF, 1.0 MB.

Watch

6 short episodes for this module. Pick one from the list, and open the transcript to read along: each timestamp plays the episode from there. The narration is generated with a voice clone of Teddy, used with his permission.

Episode 20 · 3:52

Why agents? Their power and their cost

Why simulate every person? We build agents with states, rules and neighbours, check that 10,000 average agents give back the SIR equations, show how spreading out susceptibility shrinks the epidemic, meet Rule 110 and what agents can compute, and count the cost of checking contacts.

Average agents give back SIR; spread-out agents do not. Agents can compute anything, and their contact loops cost time.

TranscriptEpisode 20
0:00

From boxes to agents. Welcome to Module six. Until now, our models moved people between boxes. Today, every person gets a little program of their own. Why would we do that, and what does it cost?

0:17

What an agent is. An agent is one simulated individual. It has a state, like susceptible or infected, plus anything else we care about: age, a household, a timer. It has rules for what it does each step. And it has neighbors: the agents it can meet. A scheduler decides when the agents act. Run the rules, and the epidemic curve comes out at the end. Nobody writes it down in advance.

0:42

Agents give back SIR. First check: can agents reproduce what we already know? Ten thousand agents. Each infectious agent meets ten random people a day and infects each susceptible one with a chance of two and a half percent. It recovers with a chance of ten percent a day. That's R₀ of 2.5. We ran it forty times, starting from ten cases. On average, eighty nine percent of the town got infected. The equations say the same: eighty nine percent. The peaks landed between day forty six and day sixty; the equations put it on day forty nine. So with everyone average and everyone mixing, agents just give back the SIR model, with some noise on top.

1:20

Nobody is average. The point of agents is that nobody has to be average. Keep the same average susceptibility, but spread it out: some people are hardly susceptible, some very much. Now only sixty percent get infected, not eighty nine. The least susceptible fifth: fourteen percent infected. The most susceptible fifth: ninety six percent. The susceptible get infected early, and the wave runs out of fuel sooner. An average hides who drives the epidemic. Agents keep that information.

1:49

Rule 110 and what agents can compute. How far can agents go? All the way. Here's a row of cells, each zero or one. At every step, each cell looks at itself and its two neighbors, and a fixed table gives its next value. This table is called Rule 110. Starting from a single live cell, it builds these patterns. And Matthew Cook proved that Rule 110 can carry out any computation at all. Treat each cell as an agent, and you have an agent model that can do anything a computer can. That's good news for flexibility, and bad news for prediction. No general method can tell you in advance whether an arbitrary agent model will even stop. So in practice we reason about the models we actually build.

2:30

The cost of contacts, and what to report. And those models cost time. The naive way checks every pair of agents every day. In our town that's fifty million pairs a day, and about 7.9 billion over one epidemic. Our agents only checked their ten contacts, so the work followed the infectious agents: about eight hundred ninety thousand checks per run. Nearly nine thousand times less. Grow the town tenfold, and the pairs grow a hundredfold, while the contact checks grow only tenfold. On a contact network, the work follows the edges of infectious agents instead. So when you report an agent model, report its size: how many agents, how many contacts or edges, how many steps, and which loop dominates the time and memory.

3:10

Recap. So: agents are individuals with states, rules and neighbors. With everyone average they give back the equations. Their power is heterogeneity and explicit contacts, and in principle they can compute anything. Their price is design effort and computing time. Next time: building one. How to handle time, who moves first, and the shape of the world the agents live in.

Interactive lab

A town of agents

Simulate one agent per person in a town of households, see how stage durations change timing, and compare a policy with and without common random numbers.

The first panel runs one epidemic in a town of about 1,800 agents; the second runs pairs of epidemics with and without a policy, with independent or common random numbers. Everything runs in your browser.

Simple math

A town of households, one agent per person

About 1,800 agents in 700 households, simulated one day at a time in your browser.

Infection
chance = 1 − (1 − pₕ)^(infectious at home) × e^(−k p × infectious in town ÷ N)

pₕ: chance per day per infectious household member. k: town meetings a day, p: chance per meeting.

Stages
latent 2 days, infectious 4 days, in k stages

One stage is exponential (memoryless); more stages make durations more regular; fixed means always 2 and 4 days.

Common random numbers
Var(A − B) = Var A + Var B − 2 Cov(A, B)

Every random number is tied to a seed, a day and an agent. Runs that share a seed share their luck, so their difference is sharp.

Infected in the end
–
Peak
–
Infectious at the peak
–
Infections at home
–

Running…

Infectious now

Share of the town infectious, day by day (first 200 days).

Challenges

Each one is checked on your current settings, here or in the comparison panel below.

  1. Without changing the three transmission sliders, find a run that peaks after day 70. Hint: stages and seeds.
  2. Make home the place of more than half of all infections.
  3. Compare a 5% cut in town meetings so that no pair of runs points the wrong way.
  4. Get the spread of the difference below 2 points.
Average saving
–
Spread of the difference
–
Pairs pointing the wrong way
–
Pairs needed for ±0.5 points
–

Running…

Differences, pair by pair

Orange bars: pairs where the policy seemed to make things worse.