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.
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.
- BornPlanned for 1.0A new path will leave her mother's.
- StaysAvailable in 0.1While she stays in one place, her path rises straight.
- UnionPlanned for 1.0Her path will lean to join her husband's courtyard.
- HouseholdsAvailable in 0.1People are linked, so a household is a bundle of paths. Each birth will start a new path beside hers.
- MovesWhen she moves to town, the path is designed to lean across the map.
- DeathPlanned for 1.0The path will end.
The same people, two futures
Planned for 1.0cohortix 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.
Uncertainty is always shown
Planned for 1.0One 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.1A 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
# 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
# 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".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.
$ 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 targetInstall
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 -- --versionCheck a release archive
$ b3sum --check cohortix-<version>-checksums.b3Run the example
$ cohortix --version$ chx --version # same as cohortix --version$ cohortix run docs/scenario.toml --output output/tracer