NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Hijacking Malaria Simulators with Probabilistic Programming

Bradley Gram-Hansen, Christian Schröder de Witt, Tom Rainforth, Philip H. S. Torr, Yee Whye Teh, Atilim Günes BaydinarXiv 2019

Abstract

Epidemiology simulations have become a fundamental tool in the fight against the epidemics of various infectious diseases like AIDS and malaria. However, the complicated and stochastic nature of these simulators can mean their output is difficult to interpret, which reduces their usefulness to policymakers. In this paper, we introduce an approach that allows one to treat a large class of population-based epidemiology simulators as probabilistic generative models. This is achieved by hijacking the internal random number generator calls, through the use of a universal probabilistic programming system (PPS). In contrast to other methods, our approach can be easily retrofitted to simulators written in popular industrial programming frameworks. We demonstrate that our method can be used for interpretable introspection and inference, thus shedding light on black-box simulators. This reinstates much-needed trust between policymakers and evidence-based methods.

Introduction

Public health policy relies heavily on epidemiology simulators to track and predict the spread of diseases like malaria. Platforms such as EMOD and OpenMalaria are highly sophisticated, often comprising millions of lines of legacy C++ code. These simulators are stochastic, incorporating randomness to model complex biological and environmental interactions, such as mosquito-host dynamics and individual immunity.

However, their complexity often renders them "black boxes." Policymakers may see the final output but lack visibility into the internal logic or the specific pathways that led to a result. Furthermore, the sheer scale of these codebases makes it practically impossible to rewrite them for integration with modern machine learning or probabilistic inference tools. There is a critical need for methods that provide transparency and "introspection" without requiring a total overhaul of established scientific software.

Methodology: The Hijacking Approach

The authors introduce a novel method to retrofit existing simulators using Universal Probabilistic Programming (UPP), specifically the pyprob framework. The core of this approach is "hijacking" the simulator's internal stochasticity.

Instead of a full rewrite, researchers perform "surgical incisions" in the source code, replacing standard random number generator (RNG) calls (e.g., from C++ or Boost libraries) with calls to an external controller. This controller, powered by a probabilistic programming system, does more than provide a value; it records the request context (the "address" in the code) and the resulting value.

System architecture for hijacking a simulator via a Probabilistic Programming System (PPS).

To bridge the gap between the C++ simulators and Python-based inference tools (like PyTorch), the system utilizes FlatBuffers and TCP/IPC for efficient cross-language communication. By tracking every random choice made during a simulation run, the system constructs a "trace graph"—a visual and mathematical map of the program's execution path and the associated probabilities at each decision point.

Experimental Setup and Trace Analysis

The method was evaluated using two prominent malaria simulators: EMOD (an individual-based multi-disease platform) and OpenMalaria (a microsimulation tool for Plasmodium falciparum). The researchers modeled a population of $n=100$ over a three-year period, using real-world environmental data from Ifakara, Tanzania.

A significant challenge identified was the volume of data; a standard 3-year OpenMalaria simulation can generate up to 4 terabytes of raw trace data. Consequently, trace analysis must be performed "on-the-fly" to remain computationally feasible.

Key Results

The hijacking method successfully integrated with both EMOD and OpenMalaria, proving its generalizability across different large-scale C++ frameworks. The resulting trace graphs provide a detailed map of the simulation's "life," allowing researchers to assign physical interpretations to specific code addresses. For instance, an address might correspond to "generating a human in the population" or "determining parasite density."

A trace graph showing execution paths and calculated probabilities for different biological processes.

By calculating the probabilities of different execution paths, the system reveals which biological processes are most influential in driving the final epidemiological outcomes. This enables a procedural comparison between simulators: researchers can identify functionally equivalent code segments across entirely different codebases (e.g., comparing how EMOD and OpenMalaria handle host immunity).

Discussion and Future Work

While the ability to track and map simulators is a major step forward, several challenges remain. Performing automated inference—such as conditioning simulations on observed real-world data to estimate hidden parameters—is computationally intensive and remains an area of active research. Additionally, the TCP-based communication between C++ and Python introduces some latency, though this is considered a necessary trade-off for the resulting transparency.

Future work will focus on implementing more sophisticated inference procedures and expanding the evaluation to diverse scenarios across Africa and Southeast Asia. This will further validate the similarities and differences between major epidemiological models, ultimately providing policymakers with more interpretable and trustworthy evidence.

Summary updated

BibTeX
@misc{gramhansen2019hijacking,
  author = {Bradley Gram-Hansen and Christian Schröder de Witt and Tom Rainforth and Philip H. S. Torr and Yee Whye Teh and Atilim Günes Baydin},
  title = {{Hijacking Malaria Simulators with Probabilistic Programming}},
  year = {2019},
  eprint = {1905.12432},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1905.12432},
}
Figure