Skip to content

Examples

This section showcases runnable examples from the epiworld repository. Each example includes the full C++ source code and the corresponding output.

To build and run any example locally, clone the epiworld repository and use make:

git clone https://github.com/UofUEpiBio/epiworld.git
cd epiworld
make build/examples/<example-name>/<example-name>
./build/examples/<example-name>/<example-name>

Example Index

Example Description
Hello World Build a custom SEIR model from scratch using add_state()
SIR Run a built-in SIR model on a small-world network
SEIR Run a built-in SEIR model with 1 million agents
SIS Run a built-in SIS model showing endemic equilibrium
Multiple Runs Run 100 replicates of an SIR model and collect results
Simple SIR A hand-built SIR using add_state() with a vaccine tool
Advanced Usage Mutation, rewiring, and multiple tools in a single model
User Data Custom data collection with set_user_data() and post-recovery hooks
Surveillance The SURV model with vaccination, detection, and reporting
Likelihood-Free MCMC Parameter estimation using LFMCMC
Entities Population mixing with SEIR and contact matrices
Generation Interval Computing expected vs. observed generation intervals
Community–Hospital A two-population model with admission and discharge dynamics