epiverse-trace / epidemics

A library of published compartmental epidemic models, and classes to represent demographic structure, non-pharmaceutical interventions, and vaccination regimes, to compose epidemic scenarios.
https://epiverse-trace.github.io/epidemics/
Other
8 stars 2 forks source link

Export internal model functions #168

Open pratikunterwegs opened 6 months ago

pratikunterwegs commented 6 months ago

This issue proposes that the internal ODE model functions be exposed to the user as 'unsafe' scalar versions of the updated, vectorised model functions, as detailed in #160.

For Rcpp implementations, this would involve exposing .model_*_cpp(). R-only implementations may be removed as part of this project (see #162), and if not, would require a thin wrapper accepting only scalars around .ode_model_*(), while model_*_r() would be vectorised.

This issue is planned to be taken up if a specific need for exposing these internal functions to users becomes evident.

sdwfrost commented 2 months ago

Hi @pratikunterwegs

Just checking whether this is the right place for this; I'm trying to demonstrate interop with Julia SciML, and all I need for this is a function that returns either the RHS of the ODE (as odin can do) or the next step for discrete models. The idea here is that if you can step through a model, you can link different models together more easily. Is it possible to return this information?

pratikunterwegs commented 2 months ago

Hi @sdwfrost thanks, this seems really interesting!

The deterministic model ODE systems are defined as RHS in the package headers inst/include/model_*.h - one header per model. They're FunctionObjects suitable for the Boost odeint paradigm, so might work for your use case?

We only have one discrete model for Ebola in R/model_ebola.R, but the 'next step' function is combined with a loop in model_ebola_internal().

Happy to hear any feedback on the model functions for better interoperability/more efficiency! Also, I've got Epidemics.jl as an unregistered package that mirrors this one, and would be happy to include an interop demo there.

sdwfrost commented 2 months ago

Thanks @pratikunterwegs! I've added an issue to my repo here as it'll take me a little while to get the boilerplate code working.

Thanks for the pointer to Epidemics.jl - I took a quick look. Have you thought about generating ModelingToolkit code rather than low level stuff?

pratikunterwegs commented 2 months ago

Thanks @sdwfrost - I've seen the repo before - looks interesting!

With Epidemics.jl it's mostly just a way for me to learn and keep engaged with Julia programming; I haven't looked into ModelingToolkit at all before.