Examples¶
Runnable microsimulation and agent-based models, ranging from a minimal single-step model to full parallel population dynamics. Each card links to a walkthrough of that example's implementation; the source for all of them lives under examples/ in the repository.
Examples Source Code
The code for all the examples can be obtained by either:
-
Hello World
The minimal model: framework structure, workflow and execution, start to finish.
-
Parallel Execution
Exchanging and synchronising data between MPI processes (and multithreaded execution).
-
Markov Chain
Probabilistic transitions between discrete states, and fast dataframe-based sampling.
-
Chapter 1
A basic cohort model of mortality with a constant hazard rate, from Microsimulation and Population Dynamics.
-
Mortality
The Life Table example, implemented two ways - discrete case-based vs. continuous sampling - to compare performance.
-
Membership
An open population with members joining and churning, showcasing a hash-based random stream stable under sub-sampling and reordering.
-
Competing Risks
Case-based simulation of competing fertility and mortality events as nonhomogeneous Poisson processes.
-
RiskPaths
A well-known MODGEN teaching model of fertility as a function of time and union state.
-
Population Microsimulation
A full demographic model: fertility, mortality and migration acting on a real population pyramid.
-
Derivative Pricing
Parallel runs with identical random streams but perturbed inputs, to compute pricing sensitivities.
-
Conway's Game of Life
The classic cellular automaton.
-
Schelling's Segregation Model
A classic agent-based model of residential segregation from simple neighbour preferences.
-
Wolf-Sheep Predation
Another classic agent-based model, of predator-prey population dynamics.
-
Boids
Collective flocking behaviour emerging from simple local interaction rules.
-
Infection Model
Individuals moving and interacting - and transmitting infection - on a geospatial network.