Skip to content

Simulate demographic policies before they are enacted.

cohortix is an open-source, agent-based engine in Rust. It follows every person in space and time, a scenario is a TOML file, and every effect is designed to come with its uncertainty.

Early development: nothing is ready for use in a study yet, and interfaces will change. The source is on GitHub (opens another site).

Every person followed through place and time; above the policy plane her two futures fork

Every person, followed in space and time

Each agent is one person with a place on the map and a path through time. Births, unions, moves and deaths are designed as events on that path.

The kernel owns the population, the links between people, the territory, time and randomness, and holds no demographic behaviour of its own. Mortality, reproduction, contraception and union are to be plugins. Every state change is an event in one journal, the single source of every output.

  1. BornPlanned for 1.0A new path will leave her mother's.
  2. StaysAvailable in 0.1While she stays in one place, her path rises straight.
  3. UnionPlanned for 1.0Her path will lean to join her husband's courtyard.
  4. HouseholdsAvailable in 0.1People are linked, so a household is a bundle of paths. Each birth will start a new path beside hers.
  5. MovesWhen she moves to town, the path is designed to lean across the map.
  6. DeathPlanned for 1.0The path will end.

The same people, two futures

Planned for 1.0

cohortix compares a policy with its baseline on the same simulated people, drawing the same random numbers. Up to the moment the policy starts, the two runs are designed to be identical. After it, every difference is designed to come from the policy, not from chance.

This is the method of common random numbers. Every comparison will state whether it used them.

Two space-time cubes side by side, labelled baseline and policy, each cut by a horizontal plane where the policy starts. Below the plane the same woman's path is drawn identical in both. Above it, her path is drawn turning one way in the baseline and another in the policy.Two space-time cubes side by side, labelled baseline and policy, each cut by a horizontal plane where the policy starts. Below the plane the same woman's path is drawn identical in both. Above it, her path is drawn turning one way in the baseline and another in the policy.
One space-time cube where a woman's path splits at the policy plane into a grey baseline bundle and a blue policy bundle. Each faint path is one replication; a bar beside each bundle illustrates the timing of her union as an interval, never a single date.One space-time cube where a woman's path splits at the policy plane into a grey baseline bundle and a blue policy bundle. Each faint path is one replication; a bar beside each bundle illustrates the timing of her union as an interval, never a single date.

Uncertainty is always shown

Planned for 1.0

One run is one possible future. cohortix is designed to run an ensemble of replications: the same person, other draws. Each faint path in the figure is one replication, and the timing of her union will span an interval, never a single date.

Every effect will be reported with its interval, the interval's level and type, and the number of replications. A single run will say plainly that it has no interval.

An effect will read as estimate [low; high], never as a number alone.

Configured in TOML, refused before it runs

Available in 0.1

A scenario is a TOML file: no code is needed to describe a run. Every key has a type, a range or a set of allowed values, and a default. A wrong type, a value out of range or an unknown key stops the run before it starts, with the file, line and column, and a likely fix. Nothing is written.

The example scenario, in part

docs/scenario.toml
# Identity of the scenario: its name and the root of its random seeds.[scenario]name = "tracer"seed = 20180101# Simulated period and step length.[time]start = 2018-01-01end = 2019-01-01# Step length: "month" or "year". Default: "month".step = "month"# Initial population.[population]placeholder_size = 100[plugins."test/ticker"]

One misspelt key, and what the engine says

misspelt-key.toml
# Config-group fixture (story 4.2): a misspelt key.[scenario]name = "misspelt-key"seed = 1[time]start = 2018-01-01end = 2019-01-01stpe = "year"
$ cohortix run misspelt-key.tomlerror[E1022]: Unknown key `stpe` in [time]; did you mean `step`?  --> misspelt-key.toml:9:1  = fix: Rename `stpe` to `step`, or remove it; the accepted keys of [time] are "start", "end", "step".

The message is the engine's own output, checked by its test suite. Every problem in the file is reported at once.

Every run says what produced it

  • After a run, the output folder holds effective.toml: the scenario with every default made explicit. Running it again gives the same journal.
  • The version line names the commit, the compiler and the build target. The data pipeline records each source and its licence in a data manifest.
  • No survey data is stored in the repository. DHS microdata are restricted: each user obtains access from the DHS Program, and the files stay on their own machine.
The comparison report is designed as: key effects with their intervals, a chart with bands, the data table, and at the foot the provenance block. No value is drawn.
$ cohortix run docs/scenario.toml --output output/tracer$ cohortix run output/tracer/effective.toml --output output/again   # same journal$ cohortix --version --json   # version, commit, compiler, build target

Install

No release is published yet. Each release tag will build one archive per tier-1 target: Windows x86-64, Linux x86-64 and ARM64, macOS ARM64 and x86-64. Each holds cohortix, its short alias chx and the data pipeline cohortix-data, with a BLAKE3 checksum file.

Until then, build from a clone of the repository. The Rust toolchain is pinned, and the first cargo command downloads it.

Build from source

$ cargo build --workspace --locked$ cargo run -p cohortix-cli --bin cohortix -- --version

Check a release archive

$ b3sum --check cohortix-<version>-checksums.b3

Run the example

$ cohortix --version$ chx --version   # same as cohortix --version$ cohortix run docs/scenario.toml --output output/tracer