Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking compiled {odin} code with {epidemics} #223

Closed
pratikunterwegs opened this issue Apr 25, 2024 · 2 comments
Closed

Linking compiled {odin} code with {epidemics} #223

pratikunterwegs opened this issue Apr 25, 2024 · 2 comments
Labels
Discussion Issues kept open for discussions in the comments

Comments

@pratikunterwegs
Copy link
Collaborator

Questions come from @LloydChapman:

  • IIRC, nothing about the package constrains the models used to being deterministic ODE models, but are there any constraints on the format of the models in terms of the model C++ code? It sounded like it’s currently set up mainly to handle deterministic ODE models in terms of the BOOST ODE integration?
  • I’m wondering how easily {epidemics} could handle e.g. a stochastic discrete-time model written in odin and compiled to work with dust using odin.dust, with some wrapping? Here’s an example of what the compiled C++ code for an SIR model looks like: https://github.com/LloydChapman/seir/blob/main/src/sir.cpp

Obviously I’m not cognisant of all the details, but it sounded like it might be possible for {epidemics} to take odin models as an input, especially if they’re planning to completely decouple odin and mcstate.

@pratikunterwegs
Copy link
Collaborator Author

Thanks @LloydChapman for the questions, I've tried to answer them here, but happy to have another go if something isn't clear. Also cc-ing @adamkucharski.

IIRC, nothing about the package constrains the models used to being deterministic ODE models

Indeed - we have a stochastic Ebola model that's in R, and we did have R versions of the ODE models as well (the ODE systems in R are still available in the repo).

but are there any constraints on the format of the models in terms of the model C++ code? It sounded like it’s currently set up mainly to handle deterministic ODE models in terms of the BOOST ODE integration?

Our ODE models use Boost odeint, but that doesn't restrict what other types of C++ models could be included, if I've understood the question correctly. Each model stands alone - so the ODE integration happens within each model function. The model functions also have two levels, a user-facing top level, and an internal lower level, so we can swap out the internals while (making sure that) the output of the user-facing functions doesn't change.

I’m wondering how easily {epidemics} could handle e.g. a stochastic discrete-time model written in odin and compiled to work with dust using odin.dust, with some wrapping? Here’s an example of what the compiled C++ code for an SIR model looks like: https://github.com/LloydChapman/seir/blob/main/src/sir.cpp

I think it should definitely be possible to include it in the package itself, but did you mean how well Boost would handle it? I'm not actually sure! Here's a minimal example from Epirecipes of how the underlying C++ code is structured. I think the first argument to integrate is required to be a function with requirements on arguments, so potentially any C++ function would do.

...it might be possible for {epidemics} to take odin models as an input, especially if they’re planning to completely decouple odin and mcstate.

The {epidemics} models have pretty tight vertical integration (which makes them standalone), so there isn't a general integrator function per se to pass any compiled code (i.e., not a replacement for deSolve::lsoda()).

@pratikunterwegs pratikunterwegs added the Discussion Issues kept open for discussions in the comments label Apr 30, 2024
@adamkucharski
Copy link
Member

Closing this issue as current discussion is in #254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Issues kept open for discussions in the comments
Projects
None yet
Development

No branches or pull requests

2 participants