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

A tutorial for integrating ODEs multiple times #1450

Closed
A2P2 opened this issue Jul 12, 2022 · 12 comments
Closed

A tutorial for integrating ODEs multiple times #1450

A2P2 opened this issue Jul 12, 2022 · 12 comments

Comments

@A2P2
Copy link
Contributor

A2P2 commented Jul 12, 2022

Hi,
I'm wondering if there is a need to contribute with a tutorial for integrating ODEs multiple times based on different initial conditions. It's also possible to extend the current Lotka-Volterra example instead.

I oriented myself about the usage of jax.vmap for this purpose with the help of forums:
https://forum.pyro.ai/t/parallelization-plate-and-odes/2763
https://forum.pyro.ai/t/making-a-for-loop-more-efficient/3437/22

Is it of interest? Let me know what you think.

@fehiepsi
Copy link
Member

The contribution would be awesome! Currently, we only have an example for Lotka-Volterra. A tutorial with motivations for your usage case would be super helpful for users.

@zz100chan
Copy link

@A2P2 hi! I think this is a good contribution and I am also somewhat have similar issues now.
I wonder if you have a tutorial already? :)

@A2P2
Copy link
Contributor Author

A2P2 commented Oct 2, 2023

@zz100chan
My apologies for the late reply and for generally ignoring the thread.

I do have a draft written, see it attached. I tried to follow the style of the current Lotka-Volterra tutorial. Let me know if it works for you and if something is not clear. Once again, it's in a draft state at the moment. Attached as a zip file.
multiple_lotka_volterra
lotka_volterra_multiple.zip

I've tried to implement a few things: 1) integrate with different initial conditions, 2) allowed to have missing values in the data. I use regularly spaced time arrays, but it's not a must.

The MCMC is somewhat slow. I've turned on numpyro.enable_x64(), otherwise problems with convergence were observed. For my job, I actually used solvers from the https://github.com/patrick-kidger/diffrax package instead of ones from jax, due to some convergence problems as well.
ode_convergence

@fehiepsi I'm glad to finish the tutorial properly if you provide some feedback. Once again, my apologies for disappearing.

@fehiepsi
Copy link
Member

fehiepsi commented Oct 2, 2023

Could you make a version of it on https://gist.github.com/?

@A2P2
Copy link
Contributor Author

A2P2 commented Oct 2, 2023

@fehiepsi here you are https://gist.github.com/A2P2/5d2b3a15eafd5e0857ed1c49e4c1b1f4

@fehiepsi
Copy link
Member

fehiepsi commented Oct 2, 2023

Thank you! I'll take a look later of the week.

@fehiepsi
Copy link
Member

fehiepsi commented Oct 3, 2023

Hi @A2P2, the example looks great. In the tutorial, it would be nice to include some introduction to the model, how the dataset looks like, and motivation for integrating ODEs multiple times.

@A2P2
Copy link
Contributor Author

A2P2 commented Oct 3, 2023

@fehiepsi thanks for checking it quickly. I've added a short motivation to the gist, I'll add the dataset description later.
Shall I make a pull request with it?

@fehiepsi
Copy link
Member

fehiepsi commented Oct 4, 2023

Could you turn it into a (probably short?) tutorial, rather than an example? We have several tutorials here (those without Example: prefix).

@A2P2
Copy link
Contributor Author

A2P2 commented Oct 4, 2023

Will do!

@A2P2
Copy link
Contributor Author

A2P2 commented Dec 19, 2023

@fehiepsi here is the tutorial version on colab, let me know what you think.
https://gist.github.com/A2P2/ae09ed99f84372ff346b0d352ca7b4ed

@fehiepsi
Copy link
Member

super cool, @A2P2 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants