augustinas1 / MomentClosure.jl

Tools to generate and study moment equations for any chemical reaction network using various moment closure approximations
https://augustinas1.github.io/MomentClosure.jl/dev/
MIT License
44 stars 6 forks source link

Support SDESystem Input? #1

Closed ChrisRackauckas closed 2 years ago

ChrisRackauckas commented 3 years ago

First of all, this is really cool! @isaacss pointed me to this and I've been wanting this implementation since we started ModelingToolkit as a project. I'm glad you did this.

I am wondering if SDESystem could also be supported? Some people start with a stochastic description from a chemical reaction network, but others might just have an SDESystem. That requires a bit of different tweaks, but in theory it's... almost similar? It's something to think about at least.

augustinas1 commented 3 years ago

Thank you @ChrisRackauckas, really appreciate it!

I think adding support for SDEs is a nice idea and thanks for bringing it up, great to hear suggestions! This has crossed my mind before but I haven't really looked into it so far. Quite a nice example where closure is applied to moment equations obtained from a system of SDEs is https://ieeexplore.ieee.org/document/8263922. From what I gather it seems to be quite implementable in the simplest case of polynomial terms and additive noise, hopefully I'll manage to add at least that in the near future. However, I need to read/think more about how to deal with the general case of non-polynomial functions and different types of noise (if that changes things), will keep it in mind.

FHoltorf commented 2 years ago

Hey!

First of all, great package! I needed moment closures for SDEs and implemented a first step in making your package applicable to that use case. As the moment closure relations/approximations you implemented really only depend on the assumed distribution of the state of the underlying stochastic process, they can naturally be applied to any type of stochastic process with appropriate law. Since your list of closure approximations is already pretty exhaustive, I only added functions to automatically generate moment equations from SDESystems (both for polynomial and non-polynomial terms). Your code base should be essentially untouched, except that I added specific support for generating the moment equations for the chemical Langevin equation from a reaction network (not sure if and why anyone would want to do that but who knows). That can be easily changed back however, without really losing the functionality.

If you are interested in adding that feature to your package, please feel free to have a look at the pull request that I submitted (#37). I made an effort to make everything compatible with your environment but things are quite fragile with respect to the version of Symbolics (I am sure you can relate to that pain :)).

Cheers, Flemming

augustinas1 commented 2 years ago

Hi Flemming,

Thanks so much, that's a great addition! It's been a busy time but I hope to go through the code and update the compatibility next week.

augustinas1 commented 2 years ago

Hi @ChrisRackauckas, just to let you know that SDESystems are finally supported!