Metadata-Version: 2.4
Name: leapex
Version: 0.2.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Chemistry
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Rust
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Dist: numpy>=2
Requires-Dist: pandas>=2
Requires-Dist: matplotlib>=3
Requires-Dist: seaborn>=0.13
Requires-Dist: natsort>=8
Requires-Dist: tqdm>=4
Requires-Dist: rebop>=0.9 ; extra == 'benchmark'
Requires-Dist: batss>=1.0 ; extra == 'benchmark'
Requires-Dist: scipy>=1.10 ; extra == 'benchmark'
Requires-Dist: jupyterlab>=4 ; extra == 'notebook'
Requires-Dist: ipywidgets>=8 ; extra == 'notebook'
Requires-Dist: scipy>=1.10 ; extra == 'test'
Provides-Extra: benchmark
Provides-Extra: notebook
Provides-Extra: test
License-File: LICENSE
Summary: Exact batched stochastic simulation of chemical reaction networks via propensity bounds, with a Rust core.
Keywords: chemical reaction networks,stochastic simulation,Gillespie,exact simulation,CRN
Author: David Doty
License: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Algorithm, https://github.com/UC-Davis-molecular-computing/leapex/blob/main/ALGORITHM.md
Project-URL: Homepage, https://github.com/UC-Davis-molecular-computing/leapex
Project-URL: Issues, https://github.com/UC-Davis-molecular-computing/leapex/issues

# leapex

`leapex` is a Python package implementing *leapex* (fast **ex**act **leap**ing algorithm), a very fast simulation algorithm (described in [ALGORITHM.md](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/ALGORITHM.md)) for chemical reaction networks. The algorithm was developed in a conversation with GPT, first starting with some older version of GPT, but the prompt producing the algorithm below was with Astra 6.2. I then pointed Claude Opus 5.5 at the conversation and asked it to implement the algorithm in a Rust-backed Python package similar to [`batss`](https://github.com/UC-Davis-molecular-computing/batss).

`leapex` simulates stochastic chemical reaction networks (CRNs) **exactly** — every run is a sample
from the same distribution as Gillespie's stochastic simulation algorithm — while simulating
$\Theta(\sqrt{n})$ reactions at a time instead of one, where $n$ is the scale of the molecular counts.
The time-critical parts are written in Rust; the Python interface is the same as that of
[batss](https://github.com/UC-Davis-molecular-computing/batss).

```python
from leapex import species, Simulation

r, f = species("R F")
lotka_volterra = [
    r >> 2 * r,
    r + f >> 2 * f,
    f >> None,
]
n = 10**9
sim = Simulation({r: n // 2, f: n // 2}, lotka_volterra, seed=0)
sim.run(10.0, 0.02)  # ~3*10^10 reactions, in well under a second
sim.history.plot()
```

## Performance

Run time to simulate the five benchmark CRNs of the batss paper (same reactions, rate constants,
initial conditions, end times and rate conventions as batss's own benchmark) from $n = 10^2$ to
$10^{12}$ molecules, compared with batss and with rebop (a fast Rust implementation of Gillespie's
direct method, timed at its simulation core). At each $n$ the three simulators are measured back to
back; each series stops once a run exceeds 30 seconds or is predicted (by extrapolation from the previous
$n$) to exceed 2 minutes.

![run time vs n](https://raw.githubusercontent.com/UC-Davis-molecular-computing/leapex/main/benchmark/data/runtimes.png)

<details>
<summary>The reactions of these five CRNs</summary>

Rate constants are written over the arrows; as everywhere in leapex, a reaction with $o$ reactants has its
rate constant divided by $n^{o-1}$ (the volume is $n$), and $\emptyset$ means no reactants or products.

**Dimerization**, from $n$ monomers $M$, until $t = 0.5$:
$M + M \xrightarrow{1} D$, $D \xrightarrow{1} M + M$.

**Lotka-Volterra**, from $n/2$ prey $R$ and $n/2$ predators $F$, until $t = 1$:
$R \xrightarrow{1} 2R$, $R + F \xrightarrow{1} 2F$, $F \xrightarrow{1} \emptyset$.

**Rössler-Willamowski**, from $n/3$ each of $X_1$, $X_2$ and $X_3$, until $t = 1$:
$X_1 \xrightarrow{30} 2X_1$, $2X_1 \xrightarrow{0.5} X_1$, $X_1 + X_2 \xrightarrow{1} 2X_2$, $X_2 \xrightarrow{10} \emptyset$,
$X_1 + X_3 \xrightarrow{1} \emptyset$, $X_3 \xrightarrow{16.5} 2X_3$, $2X_3 \xrightarrow{0.5} X_3$.

**Oregonator**, from $0.0029n$ $X_1$, $0.5358n$ $X_2$ and $0.0034n$ $X_3$, until $t = 1$:
$X_2 \xrightarrow{0.0871} X_1$, $X_1 + X_2 \xrightarrow{1000} \emptyset$, $X_1 \xrightarrow{520} 2X_1 + X_3$,
$2X_1 \xrightarrow{40} \emptyset$, $X_3 \xrightarrow{443.324} X_2$, $X_3 \xrightarrow{2.676} \emptyset$.

**Order-3 Brusselator**, from $n$ $A$, $3n$ $B$, $n$ $X$ and $n$ $Y$, until $t = 40$:
$A \xrightarrow{1} A + X$, $2X + Y \xrightarrow{1} 3X$, $B + X \xrightarrow{1} B + Y$, $X \xrightarrow{1} \emptyset$.

</details>

At the largest $n$ where all three were measured:

| CRN | $n$ | leapex | batss | rebop | leapex vs batss | leapex vs rebop |
|---|---:|---:|---:|---:|---:|---:|
| Dimerization | $10^{10}$ | 0.037 s | 7.3 s | 51 s | 195× | 1366× |
| Lotka-Volterra | $10^{9}$ | 0.039 s | 2.9 s | 22 s | 76× | 564× |
| Rössler-Willamowski | $10^{6}$ | 0.46 s | 7.4 s | 31 s | 16× | 67× |
| Oregonator | $10^{8}$ | 2.5 s | 94 s | 103 s | 37× | 41× |
| Brusselator | $10^{7}$ | 0.95 s | 90 s | 76 s | 94× | 80× |

leapex's run time grows like $\sqrt{n}$ on each of these CRNs, because each batch costs about the same and
contains $\Theta(\sqrt{n})$ reactions; this includes the Oregonator, with its disparate rate constants,
and the order-3 Brusselator, on which batss is no faster than Gillespie (see
[DIFFERENCES_FROM_BATSS.md](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/DIFFERENCES_FROM_BATSS.md)
for why). At small $n$ (up to about $10^3$, or $10^4$
for the Oregonator) everything takes milliseconds or less, leapex mostly takes Gillespie steps itself, and
rebop's highly optimized direct method is up to about 2-3 times faster; leapex overtakes it between $10^3$ and
$10^5$ depending on the CRN. Details are in [`benchmark/benchmark.ipynb`](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/benchmark/benchmark.ipynb);
measured on one core of an AMD Ryzen 9 7940HS (Zen 4) mini PC (Windows 11), batss 1.0.4, rebop 0.9.1.

### CRNs that are hard for other methods

Five more CRNs, each known to be hard for some other simulation method
([issue #1](https://github.com/UC-Davis-molecular-computing/leapex/issues/1)), measured the same way:

* **Stiff decaying dimerization** ([Rathinam, Petzold, Cao & Gillespie 2003](https://doi.org/10.1063/1.1627296)):
  a fast reversible dimerization in partial equilibrium beside slow reactions, a standard example of
  stiffness, which forces explicit tau-leaping to take tiny steps; at $n = 1198$ it is exactly their
  system. An exact method must simulate every fast reaction, about $260n$ reactions in 0.2 time units.
* **Telegraph gene expression** ([Peccoud & Ycart 1995](https://doi.org/10.1006/tpbi.1995.1027)) with a
  single gene copy, which switches on and off about once per unit time and, while on, makes mRNA with
  propensity $2n$, so that one molecule gates about half of all reactions. How long it happens to stay on
  sets the amount of work (from $0.63n$ to $3.4n$ reactions), so each point is the mean of 10 runs.
* **Lattice diffusion**: molecules hopping between neighboring voxels in a line of 100, the
  reaction-diffusion master equation without reactions (as simulated by the next-subvolume method of
  [Elf & Ehrenberg 2004](https://doi.org/10.1049/sb:20045021)): 100 species of about $n/100$ molecules
  each, and 198 reactions.
* **Colloidal aggregation** ([Ramaswamy, González-Segredo & Sbalzarini 2009](https://arxiv.org/abs/0906.1992)):
  clusters of up to 20 particles that merge and split, with 200 reactions, each sharing a species with
  many others.
* **Schlögl's bistable model** (Schlögl 1972) with its usual parameters: rare switches between two stable
  states, a test of accuracy for approximate methods, and trimolecular reactions.

![run time vs n on CRNs that are hard for other methods](https://raw.githubusercontent.com/UC-Davis-molecular-computing/leapex/main/benchmark/data/challenges/runtimes.png)

<details>
<summary>The reactions of these five CRNs</summary>

Same conventions as above.

**Stiff decaying dimerization**, from $400n/1198$ $S_1$ and the remaining molecules as $S_2$, until
$t = 0.2$ (the fast rate constants $5990$ and $1000$ correspond to stiffness $s = 1$):
$S_1 \xrightarrow{1} \emptyset$, $2S_1 \xrightarrow{5990} S_2$, $S_2 \xrightarrow{1000} 2S_1$, $S_2 \xrightarrow{0.1} S_3$.

**Telegraph gene expression**, from one gene copy, on ($G_\mathrm{on} = 1$), and $n$ mRNAs $M$, until $t = 1$:
$G_\mathrm{off} \xrightarrow{1} G_\mathrm{on}$, $G_\mathrm{on} \xrightarrow{1} G_\mathrm{off}$,
$G_\mathrm{on} \xrightarrow{2n} G_\mathrm{on} + M$, $M \xrightarrow{1} \emptyset$.

**Lattice diffusion**, from $n/100$ molecules in each of the voxels $X_0$ to $X_{99}$, until $t = 1$:
$X_i \xrightarrow{1} X_{i+1}$ and $X_{i+1} \xrightarrow{1} X_i$ for $0 \le i \le 98$.

**Colloidal aggregation**, from $n$ monomers $S_1$, until $t = 1$ ($S_k$ is a cluster of $k$ particles):
$S_i + S_j \xrightarrow{1} S_{i+j}$ for $1 \le i \le j$ with $i + j \le 20$, and
$S_p \xrightarrow{1} S_i + S_{p-i}$ for $2 \le p \le 20$ and $1 \le i \le p/2$.

**Schlögl**, from $n/3$ each of the catalysts $A$ and $B$ and of $X$, until $t = 1$:
$A + 2X \xrightarrow{33.75} A + 3X$, $3X \xrightarrow{9.375} 2X$, $B \xrightarrow{0.8} B + X$, $X \xrightarrow{3.5} \emptyset$.

</details>

At the largest $n$ where all three were measured:

| CRN | $n$ | leapex | batss | rebop | leapex vs batss | leapex vs rebop |
|---|---:|---:|---:|---:|---:|---:|
| Stiff dimerization | $10^{7}$ | 1.4 s | 79 s | 55 s | 54× | 38× |
| Telegraph | $10^{9}$ | 98 s | 55 s | 57 s | 0.56× | 0.58× |
| Lattice diffusion | $10^{8}$ | 5.8 s | 2.3 s | 75 s | 0.41× | 13× |
| Colloidal aggregation | $10^{8}$ | 0.85 s | 16 s | 41 s | 18× | 48× |
| Schlögl | $10^{9}$ | 0.17 s | 81 s | 79 s | 493× | 475× |

Except on the telegraph model, leapex's batches still grow like $\sqrt{n}$ (figure below), and on the
stiff dimerization, colloidal aggregation and the Schlögl model its lead over rebop grows like
$\sqrt{n}$, as on the five CRNs of the batss paper. Stiffness does not shorten the batches: at
$n = 10^6$, one run at each stiffness gives 171 to 176 reactions per batch whether the fast rate constants
are multiplied by 0.001 or by 10, so leapex simulates every fast reaction, as an exact method must, but
about $0.17\sqrt{n}$ of them at a time. Spreading the molecules over many species does shorten the
batches: leapex bounds each propensity over all the configurations that a batch can reach (see How it
works below), and the fewer molecules a reaction's reactants have, the looser its bounds. Batches hold
about $0.045\sqrt{n}$ reactions on the lattice, whose 100 voxels hold about $n/100$ molecules each, and
$0.04\sqrt{n}$ on colloidal aggregation, whose larger clusters are rare, against $0.17\sqrt{n}$ and
$0.21\sqrt{n}$ on the stiff dimerization and the Schlögl model.

![leapex's reactions per batch vs n on CRNs that are hard for other methods](https://raw.githubusercontent.com/UC-Davis-molecular-computing/leapex/main/benchmark/data/challenges/reactions_per_batch.png)

Two CRNs are harder for leapex:

* **Telegraph.** The gene copy could switch within any batch, so the bounds must allow it to be both on
  and off, and the transcription propensity, about half of the total, gets a lower bound of 0. Batches
  would hold only one or two reactions, so leapex takes Gillespie steps throughout, 1.4 to 2.6 times
  slower than rebop from $n = 10^4$ on. The batch-ending reactions of
  [ALGORITHM.md §9](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/ALGORITHM.md#9-possible-extensions-exact-not-implemented)
  would let leapex batch the reactions between switches.
* **Lattice diffusion.** Here a batch, which samples all 198 reactions, also costs more the longer it is:
  3.8 µs at $n = 10^5$ and 17 µs at $10^9$. Over that range leapex's run time therefore grows like
  $n^{2/3}$, and its lead over rebop only like $n^{1/3}$. batss, at about 12 ns per reaction at
  $n = 10^8$, is 1.6 to 3.5 times faster than leapex from $n = 10^5$ on.

rebop's cost per reaction grows with the number of reactions: about 380 ns on the lattice and 590 ns on
colloidal aggregation (even with its sparse representation of reactions, used on these two), against
26 ns on the Schlögl model. On the lattice, where a reaction changes only 3 or 4 of the 198 propensities,
an exact method that updates only those, such as the next-reaction method, would be a stronger baseline.
Colloidal aggregation is strongly coupled (a reaction changes 25 to 53 of the 200 propensities), the case
that the partial-propensity methods of Ramaswamy et al. were designed for. Neither was measured here.
The run times and leapex's reactions per batch are in
[`benchmark/data/challenges/summary.md`](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/benchmark/data/challenges/summary.md),
and its reaction counts in the JSON files beside it (same machine and versions as above).

## How it works

Each reaction's propensity is bounded above and below by constants $l_r \le a_r(x) \le u_r$ valid for
every configuration $x$ reachable within the next $L$ reactions. Think of a Poisson clock ringing at
rate $U = \sum_r u_r$. Each ring is, with constant probability $l_r/U$, a *guaranteed* occurrence of
reaction $r$, and otherwise an *exceptional* ring whose outcome (some reaction, or nothing) depends on
the current configuration. This is ordinary Poisson thinning, so it reproduces Gillespie kinetics
exactly. Because the guaranteed probabilities do not depend on the configuration:

* the number of guaranteed reactions before the first exceptional ring is **geometric**,
* their reaction counts are **one multinomial** sample (their order never matters),
* the elapsed time is **one Erlang** (gamma) sample,
* the single exceptional ring is then resolved in the configuration where it occurs.

A batch therefore costs $O(m)$ work for $m$ reaction channels however many reactions it contains, and
with $L = \Theta(\sqrt N)$ it contains $\Theta(\sqrt N)$ of them. Stopping at an exact time (e.g. to
record the history) needs no rejection sampling: given the time of the last ring, the earlier rings are
uniformly distributed, so the number before the stopping time is binomial. When the counts that matter
are small, batches get short; once a batch would yield fewer than about 5 reactions, leapex takes ordinary
Gillespie steps instead (also exact, and cheaper there), so it is never much slower than Gillespie.

leapex simulates the CRN as given, without transforming it, and needs no extended-precision arithmetic:
differences of propensities are computed by a telescoping sum with no subtractive cancellation, so plain
`f64` suffices and leapex builds on stable Rust. See [ALGORITHM.md](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/ALGORITHM.md)
for an informal overview with a worked example, the precise algorithm, the argument that it is exact,
the numerics, the complexity analysis, and a comparison with related exact algorithms (RSSA, ER-leap
and batss) and with approximate ones such as [tau-leaping](https://en.wikipedia.org/wiki/Tau-leaping).

## Usage

The interface is the same as 
[`batss`](https://github.com/UC-Davis-molecular-computing/batss#readme);
code written for batss typically runs unchanged with `from leapex import ...`
([DIFFERENCES_FROM_BATSS.md](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/DIFFERENCES_FROM_BATSS.md)
lists the differences).

* **Species and reactions.** `species('A B C')` returns one `Specie` per name. `>>` separates reactants
  from products, `+` combines species, `2*a` is a stoichiometric coefficient, `None` means no products
  (or no reactants), `|` makes a reaction reversible, `.k(...)` sets the (forward) rate constant (default 1)
  and `.r(...)` the reverse one. `print(sim.reactions)` shows how they were parsed.
* **Rate constants** use the mass-action convention with volume: a reaction with $o$ reactants has its
  rate constant divided by `volume ** (o-1)`, and `volume` defaults to the total initial count $n$, which
  keeps the time scale independent of $n$. The propensity of e.g. $2A + B \to \cdots$ with rate constant
  $k$ is $\frac{k}{V^2} x_A(x_A-1)x_B$, where $x_A$ and $x_B$ are the counts of $A$ and $B$ (the same
  convention as batss and rebop). For example, the Oregonator of the benchmarks above, with $n = 10^6$:

  ```python
  from leapex import species, Simulation

  x1, x2, x3 = species("X1 X2 X3")
  oregonator = [
      (x2 >> x1).k(0.0871),
      (x1 + x2 >> None).k(1000),  # bimolecular: propensity 1000 * x1 * x2 / n
      (x1 >> 2 * x1 + x3).k(520),
      (2 * x1 >> None).k(40),     # propensity 40 * x1 * (x1 - 1) / n
      (x3 >> x2).k(443.324),
      (x3 >> None).k(2.676),
  ]
  n = 10**6
  inits = {x1: int(0.0029 * n), x2: int(0.5358 * n), x3: int(0.0034 * n)}
  sim = Simulation(inits, oregonator, seed=0)  # volume defaults to n
  sim.run(5.0, 0.01)
  sim.history.plot(logy=True)
  ```
* **`Simulation(inits, rxns, seed=None, volume=None, time_units=None)`**, then
  **`sim.run(run_until, history_interval)`**. `run_until` is an amount of time, or a function of the
  configuration dict that returns `True` when the run should stop, or `None` to run until no reaction is
  possible. `history_interval` may be a function of the current time. `sim.run(t)` always advances
  exactly `t` time units, even if the configuration becomes silent (no reaction that changes it can
  occur; it then stays as it is); `sim.run()` stops at the time of the last reaction. With a seed, a run
  is exactly reproducible.
* **`sim.history`** is a pandas `DataFrame` of the recorded configurations, indexed by time.
  `sim.config_dict`, `sim.config_array`, `sim.time`, `sim.reset()`, `sim.set_config(...)`.
* **`sim.sample_future_configuration(time, num_samples)`** returns a `DataFrame` of independent samples
  of the configuration `time` units in the future (computed in Rust; the simulation itself is unchanged),
  and `sim.sample_silence_time()` samples, in a new trial from the initial configuration, the time until
  it becomes silent.
* **Snapshots** (`leapex.snapshot.StatePlotter`, `HistoryPlotter`, `TimeUpdate`) and `sim.snapshot_slider()`
  work as in batss.
* **`sim.stats`** reports the work done: batches, reactions, exceptional rings, and so on.
* Reactions with no net change (e.g. $A \to A$, $A + B \to A + B$) or with rate constant 0 cannot change
  the configuration, so they are not simulated or counted.
* Mass-action rate units (`.k(..., units=RateConstantUnits.mass_action)`) are converted for reactions of
  any order.
* Optional tuning parameters (none affects correctness): `target_exceptions` (default 1, the expected
  number of exceptional rings per batch that the batch-length controller aims for), `direct_threshold`
  (default 5: below this many expected reactions per batch, use Gillespie steps; 0 = batches only),
  `max_batch_length`, and `batch_length` (a fixed batch length, for testing); batch lengths are limited
  to $2^{40}$.

## Examples and benchmarks

* [`examples/crn_examples.ipynb`](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/examples/crn_examples.ipynb): the five benchmark CRNs of the batss
  paper (Lotka-Volterra, dimerization, Rössler-Willamowski, Oregonator, Brusselator), how the batch size
  grows with $n$, a check of the simulated distribution against the exact one, and three CRNs that mix large and
  small counts.
* [`examples/dsd_oscillator.ipynb`](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/examples/dsd_oscillator.ipynb): the full mechanistic model of the DNA strand
  displacement oscillator of Srinivas et al. (Science 2017), with leak and toehold occlusion (162 species, 495
  reactions): checked against the authors' ODE model and its fit to their data, simulated at small volumes, and timed.
  On one core, leapex simulates it in real time up to about 0.4 nL, and the simplified model of ppsim's example
  (which ppsim can also simulate) up to about 90 µL (`python benchmark/run_dsd_realtime.py` regenerates the timings).
* [`benchmark/benchmark.ipynb`](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/benchmark/benchmark.ipynb): run time of leapex vs batss vs rebop on those
  CRNs, from $n = 10^2$ to $10^{10}$ (`python benchmark/run_benchmarks.py` regenerates the data).
* [`benchmark/data/challenges/summary.md`](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/benchmark/data/challenges/summary.md):
  run times on the five CRNs that are hard for other methods, with leapex's reactions per batch
  (`python benchmark/run_challenges.py --suite n` regenerates the data and the figure, in about an hour).

## Installation

```
pip install leapex
```

Wheels are provided for Linux and macOS (x86_64 and arm64) and Windows (x86_64), for CPython 3.11 and
later. To build from source instead you need a stable [Rust toolchain](https://rustup.rs/) and [maturin](https://www.maturin.rs/):

```
pip install maturin
pip install .            # or, for development: maturin develop --release
```

See [CONTRIBUTING.md](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/CONTRIBUTING.md) for development notes (building, tests, benchmarks,
releasing).

## Testing

```
python -m pytest tests            # or: python -m unittest discover -s tests -t .
cargo test --no-default-features  # Rust unit tests (no Python needed)
```

`tests/test_exactness.py` checks that leapex samples from the exact distribution: for a dozen CRNs
(first- to third-order reactions, reversible reactions, catalysts, open and closed systems) it compares
the distribution of the configuration at a fixed time with the exact distribution (closed forms, or the
chemical master equation solved by a matrix exponential) using chi-square tests. Every CRN is run under
settings that force each branch of the algorithm (adaptive and fixed batch lengths from 2 to
$10^4$, many intermediate stops), and against an independent Gillespie implementation (rebop).
[`scripts/mutation_test.py`](https://github.com/UC-Davis-molecular-computing/leapex/blob/main/scripts/mutation_test.py) checks that these tests catch deliberately
introduced subtle bugs (e.g. a clock running 2% fast, bounds valid for one reaction too few, an
off-by-one in a ring count): every mutant is caught.

