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

Allow seeding SDEProblems with e.g. StableRNGs #569

Open
TorkelE opened this issue Mar 30, 2024 · 1 comment
Open

Allow seeding SDEProblems with e.g. StableRNGs #569

TorkelE opened this issue Mar 30, 2024 · 1 comment

Comments

@TorkelE
Copy link
Member

TorkelE commented Mar 30, 2024

For JumpProcesses's JumpProblems you can do

using JumpProcesses,  StableRNGs
rng = StableRNG(12345)
jprob = JumpProblem(no_param_network, dprob, Direct(); rng = rng)
sol1 = solve(jprob, SSAStepper())
sol2 = solve(jprob, SSAStepper())
sol3 = solve(jprob, SSAStepper())

and now, while sol1, sol2, and sol3 are different, they will yield reproducibly the same result each time I rerun the above snippet (useful to e.g. remove any randomness from tests). Note, this si different from setting a seed, where if I do:

using JumpProcesses,  StableRNGs
jprob = JumpProblem(no_param_network, dprob, Direct(); seed = 1234)
sol1 = solve(jprob, SSAStepper())
sol2 = solve(jprob, SSAStepper())
sol3 = solve(jprob, SSAStepper())

sol1, sol2, and sol3 will be identical.

StochasticDiffEq does not have a feature like this (and is only able to set seeds, however, it would be useful.

It is possible to partially circumvent this by setting different seeds for each sol (potentially depending on the StableRNG). However, long-term, being able to provide a stable rng to a SDEProblem directly would be ideal.

@isaacsas
Copy link
Member

I think the bigger issue here is providing a simple way for users to set the rng used internally, i.e. via the problem or solve call, which would also fix this issue.

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

No branches or pull requests

2 participants