arXiv:2610.40343cs.SEOct 2026

Manuscript Offprint

arXiv:2610.40343

Manual binding and semi-automated interface generation for efficient simulation backends with user-friendly frontends: A~demonstration for epidemic use cases

Maximilian Betz, Daniel-Michel Richter, Daniel Abele, René Schmieding, Henrik Zunker, Martin J. Kühn

MAXIMILIAN BETZ*, ICE-1, Institute of Climate and Energy Systems, Forschungszentrum Jülich, Germany

DANIEL-MICHEL RICHTER*, Institute of Software Technology, German Aerospace Center, Germany

DANIEL ABELE, Institute of Software Technology, German Aerospace Center, Germany

RENÉ SCHMIEDING, Institute of Software Technology, German Aerospace Center, Germany

HENRIK ZUNKER, Institute of Software Technology, German Aerospace Center, Germany

MARTIN J. KÜHN, Institute of Software Technology, German Aerospace Center, Cologne and Bonn Center for Mathematical Life Sciences and Life and Medical Sciences Institute, University of Bonn, Bonn, Germany

Challenges and chances of mathematical software are directly entangled with the programming language used. Depending on the background of developers and users, conflicts between different goals may arise. While several, e.g., scripting languages allow a low barrier and user-friendly entry to mathematical modeling and simulation, corresponding implementations will most likely not allow timely outcomes for detailed simulations.

In infectious disease modeling, while several large-scale software frameworks rely on C or C++ implementations, most models are implemented in Python or R. While the latter allow for fast prototyping and more interactive development, it has been shown for several applications that C or C++ implementations outperform plain Python or R implementations by factors between one and three orders of magnitude. In particular, in times of pandemics, the urgent need for swift estimation of the system's dynamics makes the use of large-scale models in these noncompiled languages prohibitive.

In order to create synergies and close the gap between scientists from the application and the computational domain, binding libraries allow to execute entire, compiled software frameworks from languages such as Python. However, with iterative model development, extension, or addition of new models, implementing bindings can represent another relevant barrier to developers of the C or C++ backends. In this paper, we show how a large-scale software framework with a multitude of infectious disease models can be efficiently exposed to Python. In addition, we suggest a semi-automated way to generate interface code by analyzing generic C++ code through abstract syntax trees, enabling a modularized approach working with intermediate representations.

Keywords: Programming languages, interoperability, code generation, abstract syntax tree, epidemiological modeling, MEmilio framework

1 Introduction

With individual programming languages serving different purposes, different challenges and opportunities arise. In particular, developers and users need to gain substantially different levels of computational expertise for implementing and using mathematical methods. In epidemiological

∗^{*}Both authors contributed equally to this research.

Authors' Contact Information: Maximilian Betz, m.betz@fz-juelich.de, ICE-1, Institute of Climate and Energy Systems, Forschungszentrum Jülich, Jülich, Germany; Daniel-Michel Richter, daniel-michel.richter@dlr.de, Institute of Software Technology, German Aerospace Center, Cologne, Germany; Daniel Abele, Institute of Software Technology, German Aerospace Center, Cologne, Germany; René Schmieding, Institute of Software Technology, German Aerospace Center, Cologne, Germany; Henrik Zunker, Institute of Software Technology, German Aerospace Center, Cologne, Germany, henrik.zunker@dlr.de; Martin J. Kühn, Institute of Software Technology, German Aerospace Center, Cologne and Bonn Center for Mathematical Life Sciences and Life and Medical Sciences Institute, University of Bonn, Bonn, Germany, martin.kuehn@dlr.de.

Betz et al.

modeling, languages such as R and Python are most widely spread [6], as they offer a low-barrier access to mathematical-epidemiological modeling. However, it has been shown for different applications [27, 29] that compiled languages such as C or C++ outperform Python with respect to time to solution by factors around 50, 100, or more. This well-known fact has led to the development of C, C++, or Fortran compiled packages to, e.g., solve ordinary differential equation-based (ODEs) models in R or Python [19, 39] and for the well known pytorch library, it was recently stated, how non-Python environments such as C++ help to bridge the gap between research prototypes and production deployment [37]. However, addressing individual software components such as numerical ODE solvers for ODE-based problems might not be enough if other costly tasks are conducted in a scripting approach. In [6], it has recently been shown that ODE-based problem formulations with a modest number of spatially distributed subpopulations are simulated 1-2 orders of magnitude faster in fully-bound C++ than when only seeking Fortran or C compiled routines to solve the ODE system. With computation times at the order of seconds, individual simulations will rarely present a bottleneck. Nevertheless, with iterative model development or thousands of simulations necessary for parameter exploration and model calibration, execution will become incompatible with the high timely pressure that is imposed by unfolding or ongoing epidemics. In that direction, efficiently implemented models contribute substantially to timely outputs – an important use factor that increases modeling relevance for policy [32].

While several large-scale software models for infectious disease modeling like OpenABM [14], EpiHiper [8], FRED [13] are implemented in C and C++, primarily targeting users with background knowledge in these languages, others like Covasim [21] or MatSim-episim [25] provide optimized Python or Java implementations to increase the developer and user base. However, eventually, these optimized versions will stay behind the potential of software written in compiled languages. Even other frameworks such as Repast [9, 10] provide separated repositories with models implemented in either C++ or Python. BoostPython [1], pybind11 [16], and nanobind [17] are well established methods to provide Python bindings to C++ implementations. More recent developments based on the Cling C++ interpreter promise better Python binding performance than established solutions with pybind11 but are also less popularized yet [23]. The software frameworks EMOD [5], EpiABM [12], and MEmilio [6] provide Python frontends to their C/C++ backends where the latter both use pybind11. Through this approach, EMOD, EpiABM, and MEmilio are capable to offer low-barrier interfaces tailored to domain-specific users. It has to be noted that in the related domain of veterinary diseases, the provision of R, Python, or even Javascript frontends to compiled language implementations has an already longer history as, e.g., seen by SimInf [40] or BICI [38]. However, the provision of these interfaces comes at substantial cost for developers that need to implement a substantial number of additional lines of code. In these, additional difficulties arise as developers need to understand the particularities of different programming languages using objects through, e.g., pointers, references, or different types of copies. On the other hand, binding large code bases yields a lot of opportunities and, compared to fully new implementations, comes at substantially reduced cost.

To avoid or reduce the cost of manual binding implementations, (semi-)automated approaches have been proposed. AutoWIG [11] or CppInterOp [18] are two approaches that have been suggested for the automated binding generation of C++ libraries. For our application, we distinguish two complementary use cases where automation can come into play. In cases where a clearly separated software module (e.g., a new disease model) is added to the software, bindings can be directly generated with the backend code. Here, a unified description as in MEmilio [6] or a domain-specific language (DSL) as in EMULSION [28] is needed. A popular example of a DSL in biological applications is the Systems Biology Markup Language (SBML) standard [15] which facilitates the task of generating model backend and interface simultaneously from a description in xml.

or yaml formats. DSLs are also used in other domains, e.g., to generate stencil-based code for high-performance computing applications [2, 4, 34]. In cases where the backend code is already available in the compiled language, an analysis of the abstract syntax tree (AST) can enable the semi-automated generation of binding code. For our application, we furthermore distinguish the second use case by the settings where an existing but entire module might need a binding interface or where bindings should only be generated for small entities such as individual functions.

The paper is structured as follows. In Section 2, we first briefly revisit the descriptions of available models in the MEmilio software framework and discuss the advantages and necessity of modular and generic implementations before, in Section 3, explaining the goals, challenges, and essentials chosen in MEmilio to provide C++ implementations to Python. In Section 4, we explain more deeply the (semi-automated) development of Python bindings for existing and new models sharing the same or similar descriptions by analyzing ASTs and transforming them to intermediate representations before generating the target code. We present a modularized approach based on handlers and scanners for ASTs that are connected through an intermediate representation with a code generator for different applications. In Section 5, we show results of the semi-automated generation with respect to code completeness of a comparable MEmilio model and evaluate the performance achieved through Python before, eventually, drawing a conclusion in Section 6.

References (15)