Skip to content

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:

  • downloading and extracting the examples archive from the neworder releases page, or
  • pulling the docker image virgesmith/neworder:latest (more here
  • Hello World


    The minimal model: framework structure, workflow and execution, start to finish.

    Walkthrough

  • Parallel Execution


    Exchanging and synchronising data between MPI processes (and multithreaded execution).

    Walkthrough

  • Markov Chain


    Probabilistic transitions between discrete states, and fast dataframe-based sampling.

    Walkthrough

  • Chapter 1


    A basic cohort model of mortality with a constant hazard rate, from Microsimulation and Population Dynamics.

    Walkthrough

  • Mortality


    The Life Table example, implemented two ways - discrete case-based vs. continuous sampling - to compare performance.

    Walkthrough

  • Membership


    An open population with members joining and churning, showcasing a hash-based random stream stable under sub-sampling and reordering.

    Walkthrough

  • Competing Risks


    Case-based simulation of competing fertility and mortality events as nonhomogeneous Poisson processes.

    Walkthrough

  • RiskPaths


    A well-known MODGEN teaching model of fertility as a function of time and union state.

    Walkthrough

  • Population Microsimulation


    A full demographic model: fertility, mortality and migration acting on a real population pyramid.

    Walkthrough

  • Derivative Pricing


    Parallel runs with identical random streams but perturbed inputs, to compute pricing sensitivities.

    Walkthrough

  • Conway's Game of Life


    The classic cellular automaton.

    Walkthrough

  • Schelling's Segregation Model


    A classic agent-based model of residential segregation from simple neighbour preferences.

    Walkthrough

  • Wolf-Sheep Predation


    Another classic agent-based model, of predator-prey population dynamics.

    Walkthrough

  • Boids


    Collective flocking behaviour emerging from simple local interaction rules.

    Walkthrough

  • Infection Model


    Individuals moving and interacting - and transmitting infection - on a geospatial network.

    Walkthrough