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

Dealing with deterministic parameter and stochastic parameter #42

Open
oameye opened this issue Mar 27, 2024 · 3 comments · May be fixed by #76
Open

Dealing with deterministic parameter and stochastic parameter #42

oameye opened this issue Mar 27, 2024 · 3 comments · May be fixed by #76
Labels
good first issue Good for newcomers question Further information is requested

Comments

@oameye
Copy link
Member

oameye commented Mar 27, 2024

Now the user is expected construct their deterministic function in a way that it takes in parameter of the form [dp, sp] with dp the deterministic vector of parameters and sp the stochastic vector of parameters. However, this makes it dificult to convert deterministic ODE of other packages from DynamicalSystems, OrdinaryDiffEq and HarmonicBalance. Instead, I propose we change handling of the parameters in such a way that the deterministic function f(u, p, t) takes in a Vector instead of Vector{Vector}.

function fitzhugh_nagumo(u,p,t)
u, v = u
ϵ, β, α, γ, κ, I = p[1]
du = (-α*u^3 + γ*u - κ*v + I)/ϵ
dv = -β*v + u
SA[du, dv]
end

@oameye oameye added question Further information is requested good first issue Good for newcomers labels Mar 27, 2024
@reykboerner
Copy link
Collaborator

Yes, we thought about this as well back then when writing the StochSystem struct. The reason why we did this is that the SDEProblem from DiffEq only has one parameter field p for both the deterministic function f and the noise function g. However, in the StochSystem struct, we wanted to have the deterministic and stochastic parameters separately because the idea is to e.g. take a deterministic system with a set of parameters and throw different noise terms at it which might have different numbers of parameters.

Ideally, f(u,p,t) would take in a Vector for p (and not Vector{Vector}) and behind the scenes the StochSystem would sort this together with the stochastic parameters pg to pass it to SDEProblem in a way that still works. Any ideas on how to best do this are very welcome :)

@oameye
Copy link
Member Author

oameye commented Apr 21, 2024

Ideally, f(u,p,t) would take in a Vector for p (and not Vector{Vector}) and behind the scenes the StochSystem would sort this together with the stochastic parameters pg to pass it to SDEProblem in a way that still works. Any ideas on how to best do this are very welcome :)

I think we can work this out. I will start a PR

@oameye
Copy link
Member Author

oameye commented Apr 21, 2024

I have been looking into how StochasticDiffEq does parameter handling and it seems to opt for one iterator (vector, tuple, etc.) where the functions f or g know which index to call for a specific param. I would try to mimic this framework such that we have a smooth interplay between ModelingToolkit and StochasticDiffEq. We should do this in parallel with #75.

@oameye oameye linked a pull request Apr 21, 2024 that will close this issue
@oameye oameye linked a pull request Apr 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants