Tutorial 1: Run your first simulation
This tutorial introduces the core building blocks of every emodpy-malaria script by running a simple malaria simulation with no interventions. You will see how to configure simulation parameters, define a human population, and run an experiment on the Container platform.
If you have not already read EMOD input files, do that first — it introduces the configuration, demographics, campaign, and report concepts used in every tutorial.
File: tutorials/tutorial_1_intro.py
EMOD executable and schema
The if __name__ == "__main__" block calls emod_malaria.bootstrap.setup() before running the
experiment. This extracts the EMOD executable and schema from the emod_malaria package into
the tutorials/download/ directory.
Paths used throughout the tutorials are defined in manifest.py.
Config callback: build_config
build_config is passed to EMODTask and called when building config.json. It receives a
config object and returns it after making changes.
set_team_defaults() applies the malaria team's standard parameter set — a large collection of
validated defaults that gives a working malaria simulation without needing to set every parameter
individually.
add_species() adds pre-configured species parameters for three Anopheles vector species
present at most African sites.
Simulation_Duration is in days, so sim_years * 365 converts years to days.
Demographics callback: build_demog
build_demog builds the demographics file that describes the simulated human population.
from_template_node() creates a single-node population of 1000 people.
SetEquilibriumVitalDynamics() sets birth and death rates equal so the population size stays
roughly stable over the simulation.
SetAgeDistribution() initializes the population with a realistic age structure for
sub-Saharan Africa rather than starting everyone at the same age.
Platform
The Platform specifies where simulations run. The tutorial includes commented-out blocks for
all three supported platforms — uncomment the one that matches your environment:
|
EMODTask
EMODTask.from_default2() assembles the simulation task from the callbacks and the paths to
the EMOD executable and schema:
campaign_builder=None means no interventions are added — the population runs under baseline
transmission only. Campaigns are introduced in Tutorial 3.
Running the experiment
SimulationBuilder manages parameter sweeps across simulations. Tutorial 1 runs a single
simulation by sweeping Run_Number over just one value:
wait_until_done=True pauses Python here until all simulations finish. Tutorial 5 covers
sweeping over multiple values to run parameter studies.
When using the Container platform, simulations run inside tutorial_output/. Inside that
directory you will find an experiment folder named after the experiment and its unique ID:
tutorial_output/
e_tutorial_1_intro_949f773e-d09e-4212-80b3-3e7c10a4e16c/
551dfe56-f2f8-4831-9f15-b7c0ac529557/ ← simulation 1
Each folder under the e_tutorial_1_intro* directory is one simulation run with its inputs
and outputs. If a simulation fails, check stderr.txt and stdout.txt in that folder to
diagnose the problem. The output report files are also in that folder — Tutorial 2 introduces
a more convenient way to retrieve them.
Next
Tutorial 2 adds output reports, downloads them, and plots the results.