---
kind: concept
slug: compartmental-epidemic-model
title: Compartmental epidemic model
summary: >-
  Compartmental models sort a population or network into states such as susceptible, infected and recovered, and move members between them at timed or rate-based transitions. Three cards: an agent-based SEIR model, an SIR form with an awareness factor, and an SIRD model with per-node risk for traffic-network failures. None is validated against observed outcomes.
tags: [epidemiology, seir, sir, sird, simulation, network-resilience]
papers: ["2005.01385", "2006.10532", "2609.27903"]
related: [agent-based-simulation]
status: draft
updated_at: 2026-10-19
---

## Overview

A compartmental model groups the population into states (compartments) and
describes how people move from one state to the next. In an SEIR model the
states are susceptible, exposed (infected but not yet infectious), infectious
and recovered. The paper that is in this repository calls its own model an
agent-based SEIR model and compares it with the equation-based SIR and SEIR
models that are common in the field [arxiv:2006.10532 §2].

The shared idea is the state set and the transitions between states. The
transitions can be fixed durations (incubation, transmission, recovery) or
probabilities drawn per contact or per case [arxiv:2006.10532 tab. 2]
[arxiv:2006.10532 §3.3.2]. What differs between variants is whether the state is
kept as counts for the whole population or as one record per person, and how
contacts reach the states.

The repository holds three cards. The agent-based card gives the per-person
form in full. The equation-based card, a social-distancing paper, gives a
rate-based SIR form with an awareness term as background only: its monitor does
not implement it and the paper does not fit it to data
[arxiv:2005.01385 §II]. The third card applies a SIRD form with a per-node risk
value to failures in a transport network. Its "infection" is a failure spreading
between nodes, not disease [arxiv:2609.27903 §3.1]. Per-person detail lives on
[Agent-based simulation](/concepts/agent-based-simulation).

## Variants

### Equation-based SIR with an awareness factor

The equation-based form uses counts of susceptible (S), infected (I) and
recovered (R) people. Infection moves people from S to I at a rate that is
scaled by an awareness factor a. Recovery moves them from I to R at rate δ
[arxiv:2005.01385 §II, eq. 1]. The awareness factor is a power of the share of
people who are not infected, with a behaviour exponent k ≥ 0. A long-term form
also counts the recovered people, and a short-term form uses infected people
only [arxiv:2005.01385 §II, eq. 2–3]. Card: [Monitoring COVID-19 social
distancing](/papers/2005.01385).

The paper introduces these equations as background to its own monitor and does
not run or fit them. Its equation 1 writes the awareness factor as a(I, N),
while the text names a(I, R) [arxiv:2005.01385 §II]. Treat the form as a
starting point that an implementer must check, not as a calibrated model.

### SIRD with a per-node risk value on a network

The network form again uses four states, but the counts are susceptible,
failed (I), recovered and dead (D). A susceptible node fails at rate β when it
meets a failed node, a failed node recovers at rate μ and collapses at rate λ
[arxiv:2609.27903 §3.1] [fig. 2]. Each node also has a risk value f in [0, 1]
that scales the rates: infection becomes f·β0, recovery (1 − f)·μ0 and collapse
f·λ0 [arxiv:2609.27903 §3.1] [fig. 4]. Lower-risk nodes fail less, recover more
and collapse less [arxiv:2609.27903 §3.1]. The card's experiments use β = 0.3,
μ = 0.1 and λ = 0.02 on a 4,807-node traffic network with one initially failed
node [arxiv:2609.27903 §4] [arxiv:2609.27903 §4.1]. Card: [A Resilience Recovery
Method for Complex Traffic Network Security Based on Trend
Forecasting](/papers/2609.27903).

The paper goes beyond the ODEs. It defines a resilience score from a network
performance curve, forecasts that curve with an LSTM, and triggers protection
or recovery of nodes from the forecast [arxiv:2609.27903 §3.2–§3.4]. Those
parts sit outside the compartmental model itself. Its forecast accuracy and
its resilience gains are author-reported on a single simulated setup
[arxiv:2609.27903 tab. 3] [arxiv:2609.27903 tab. 8].

### Agent-based SEIR with per-person states

The COVID-ABS model keeps one state per person. A person is susceptible,
immune, or infected. An infected person has an incubation period, a
transmission period and a recovery period of 20 days [arxiv:2006.10532 tab. 2].
Each infected person is assigned one of three severities, asymptomatic,
hospitalised or severe, with age-dependent probabilities for hospitalisation,
critical care and death [arxiv:2006.10532 §3.3.2] [arxiv:2006.10532 tab. 5].
Infection passes between two person agents within a contact distance, with a
fixed probability per contact [arxiv:2006.10532 §3.3.2]. A healthcare limit
caps the number of hospitalised or severe agents the system can treat, and the
surplus has no bed [arxiv:2006.10532 §3.3.2].

Its scenarios are compared on deaths, infection peak, peak day and per-group
wealth change, each averaged over 35 runs of two simulated months
[arxiv:2006.10532 §4]. Card: [COVID-ABS](/papers/2006.10532).

Because the state is per person, this variant can express interventions that
change who meets whom. An equation-based model with the same states cannot
represent that directly, which is the paper's stated reason for choosing agents
[arxiv:2006.10532 §1].

## When to use which

| Situation | Use | Why |
|---|---|---|
| The question is about how the population as a whole moves between states, and individual contact structure does not matter | Equation-based SIR with awareness, as a starting form only | The equations give the state flows and an awareness term in closed form [arxiv:2005.01385 §II, eq. 1–3]. The paper does not fit or test them, so parameters must come from elsewhere. The agent paper's case for agents rests on movement, household and workplace structure and economic exchange [arxiv:2006.10532 §1] |
| Interventions change individual contact, such as isolating a subgroup, masking, or a conditional lockdown | Agent-based SEIR | The paper's scenarios work this way, for example isolating over-65s and under-18s, or a random fraction of people [arxiv:2006.10532 §5.5] [arxiv:2006.10532 §5.6] |
| Health outcomes must be read alongside economic outcomes | Agent-based SEIR with economic coupling | The model links hourly spending and monthly taxes and wages to each person's state [arxiv:2006.10532 §3.3.3] |
| Population size is large and runs must be fast | Equation-based form, or an agent model with a cost plan | Each person checks every other agent at each step, which the paper gives as O(n²) [arxiv:2006.10532 §3.3]. The equation form has a fixed set of state counts, so its per-step work does not grow with that pairwise check. Neither card reports run times |
| Failures spread over a network and nodes differ in how exposed they are | SIRD with a per-node risk value, as a starting form | The risk value scales each rate, and the paper's Table 9 shows higher worst-case and overall resilience than a run without it [arxiv:2609.27903 §3.1] [arxiv:2609.27903 tab. 9]. The paper's single network setup and random risk values mean this is one author-reported comparison, not a general rule |
| Parameters cannot be checked against case or death data | Treat results as scenario comparisons | The agent paper states its results are not validated against real counts [arxiv:2006.10532 §5] and gives no numbers for most of its figure-only results [arxiv:2006.10532 §5]. The equation card is not fitted to any data [arxiv:2005.01385 §II]. The network card reports single runs with no variance [arxiv:2609.27903 §4] |

## Implementation sketch

The core of a compartmental model is a state vector and a transition step. The
agent-based card gives the states and the timing of transitions per person. The
equation-based card gives a rate form for the aggregate counts. The network card
adds a per-node risk value to the same rate form. The three sketches below show
each one.

```pseudocode
# One Euler step of the awareness SIR  [arxiv:2005.01385 §II, eq. 1, eq. 3]
# Input:  S, I, R (counts), N, beta, delta, k, dt
# The text's a(I, R) is not used; eq. 1 as printed uses a(I, N)  [§II]

def step_sir(S, I, R, N, beta, delta, k, dt):
    # Awareness factor, short-term form  [eq. 3]
    a = (1 - I / N) ** k
    # Rates of eq. 1  [§II]
    dS = -beta * S * (I / N) * a
    dI = -delta * I + beta * I * (I / N) * a
    dR = delta * I
    # Explicit Euler step; the paper does not state a solver  [§II]
    return S + dS * dt, I + dI * dt, R + dR * dt
```

```pseudocode
# One Euler step of the SIRD-R network form  [arxiv:2609.27903 §3.1, eq. 3]
# Input:  node counts S, I, R, D; risk value f in [0, 1] (range assumed)
# Output: updated S, I, R, D

def step_sird_r(S, I, R, D, f, beta0, mu0, lam0, dt):
    # Infection flow S -> I, scaled by risk  [arxiv:2609.27903 eq. 3]
    infected_flow = f * beta0 * S * dt
    # Recovery flow I -> R; Fig. 4 gives (1 - f) mu0, eq. 3 prints mu0 * I
    # (the printed form does not conserve the total)  [arxiv:2609.27903 fig. 4]
    recovered_flow = (1 - f) * mu0 * I * dt
    # Collapse flow I -> D  [arxiv:2609.27903 eq. 3, fig. 4]
    dead_flow = f * lam0 * I * dt
    S = S - infected_flow
    I = I + infected_flow - recovered_flow - dead_flow
    R = R + recovered_flow
    D = D + dead_flow
    return S, I, R, D
```

```pseudocode
# One step of a per-person state update  [arxiv:2006.10532 §3.3.2]
# States: susceptible, immune, infected. The state after recovery is not
# named in the paper, so "recovered" below is our label.
# Input:  people (each with a state and a timer), P (parameters)

def step_states(people, P):
    for person in people:
        if person.state != "infected":
            continue
        # Incubation, transmission and recovery are timed periods  [tab. 2]
        person.timer += 1
        # Severity is drawn at infection; the paper gives no further rule  [§3.3.2]
        # How death is decided is not stated, so this is our choice  [§3.3.2]
        if person.timer >= P.recovery:
            person.state = "recovered" if person.survives else "dead"
```

Notes for implementers:
- The equation card gives no solver, time step or parameter values for its
  own use. The Euler step above is our choice, not the paper's
  [arxiv:2005.01385 §II].
- The agent card gives incubation of 5 to 6 days, transmission of 8 to 10 days
  and recovery of 20 days [arxiv:2006.10532 tab. 2]. The paper treats these as
  periods inside the infected state. It does not say how a range should be
  sampled per person, so that choice is ours.
- The agent card does not say whether a severe case moves to a separate
  compartment or stays infected. Its severity labels are the paper's, and no
  transition rule for them is given beyond their probabilities
  [arxiv:2006.10532 §3.3.2].
- Dead people are moved to a fixed position. Whether they still count in the
  summaries is not stated [arxiv:2006.10532 §3.3.1].
- The network card's SIRD-R equations do not conserve the node total as
  printed. Its eq. 3 gives dR/dt = μ0·I, but dI/dt subtracts only (1 − f)·μ0·I.
  The pseudocode above follows its Figure 4 instead [arxiv:2609.27903 §3.1]
  [fig. 4]. Which form the authors simulated is not stated, so check the Euler
  step against the paper before use.
- The network card gives no time step, risk-value range or real-time window.
  The SIRD-R step assumes f in [0, 1] and a step dt chosen by the implementer
  [arxiv:2609.27903 §3.1] [arxiv:2609.27903 tab. 3].

## Contradictions

No cross-paper disagreement is reported: the two cards describe different
models and do not give competing numbers for the same quantity. The papers
themselves have issues that matter for compartments:

- The network paper's Table 1 gives E = 0.7474, but the largest E in its Table
  2 is 0.7427 (T = 400). Its no-intervention E_withstand also differs across
  Tables 1, 6, 7 and 8 (0.4014, 0.4241, 0.3996, 0.4094) [arxiv:2609.27903
  tab. 1] [arxiv:2609.27903 tab. 2] [arxiv:2609.27903 tab. 6]. The paper gives
  no seed or risk-value detail that explains the gap.
- The equation paper writes the awareness factor as a(I, N) in eq. 1 and as
  a(I, R) in its text [arxiv:2005.01385 §II].
- The agent paper gives a healthcare critical limit of 0.05 of the population
  [arxiv:2006.10532 tab. 2]. Its conditional lockdown switches on and off at
  the same infection level of 0.05 [arxiv:2006.10532 §5.4]. The paper does not
  say whether the state can flip back and forth near the threshold.
- The agent paper gives the age distribution as β(2, 4) in its parameter table
  and β(2, 5) in its text [arxiv:2006.10532 tab. 2] [arxiv:2006.10532 §3.2]. It
  does not resolve which one an implementation should use.

## Papers

- [Monitoring COVID-19 social distancing](/papers/2005.01385): a camera-based person monitor. Its SIR-type equations with an awareness factor are background only; the monitor does not use them and they are not fitted to data.
- [COVID-ABS](/papers/2006.10532): an hourly agent-based SEIR model with households, businesses, a government and a health system, with seven social-distancing scenarios. Author-reported and not validated against data.
- [A Resilience Recovery Method for Complex Traffic Network Security Based on Trend Forecasting](/papers/2609.27903): an SIRD model with a per-node risk value for failure spread on a traffic network, with an LSTM forecast that drives protection and recovery. Author-reported on one simulated network; no official code.
