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

EnsembleProblem of JumpProblem - All solutions are identical #184

Open
TorkelE opened this issue Jun 29, 2021 · 4 comments
Open

EnsembleProblem of JumpProblem - All solutions are identical #184

TorkelE opened this issue Jun 29, 2021 · 4 comments

Comments

@TorkelE
Copy link
Member

TorkelE commented Jun 29, 2021

Here's a minimal sample. I make a similar EnsembleProblem from both and an JumpProblem and an SDEProblem. When I solve them the SDE solutions turn out different, but the Jump ones are all identical.

using Catalyst, DifferentialEquations, Plots

rn = @reaction_network begin
    (k1,k2), X <--> Y
end k1 k2

dprob = DiscreteProblem(rn, [10,10], (0.,10.), [1.,2.])
jprob = JumpProblem(rn, dprob, Direct())    
ejprob = EnsembleProblem(jprob,prob_func=(p,i,r)->remake(p))
jsol = solve(ejprob,SSAStepper(),trajectories=4)

sprob = SDEProblem(rn, [10.,10.], (0.,10.), [1.,2.])
esprob = EnsembleProblem(sprob,prob_func=(p,i,r)->p)
ssol = solve(esprob,ImplicitEM(),trajectories=4)

plot(plot(jsol),plot(ssol),size=(900,250))

image

This is the output of Pkg.status()

  [479239e8] Catalyst v6.13.0
  [0c46a032] DifferentialEquations v6.17.1
  [91a5bcdd] Plots v1.16.6
@isaacsas
Copy link
Member

isaacsas commented Jun 29, 2021

If it helps in debugging this, the problem seems to go away if one doesn't use prob_func.

@isaacsas
Copy link
Member

@TorkelE this seems to fix it for me, does it work for you?

ejprob = EnsembleProblem(jprob,prob_func=(p,i,r)->remake(p), safetycopy=false)

Looks like the problem is JumpProblems shouldn't make a copy of the problem unless using threads to get a continual sequence of random numbers.

@isaacsas
Copy link
Member

I think this should be fixed by SciML/SciMLBase.jl#72, but I’ll leave this open till that propagates through the ecosystem.

@TorkelE
Copy link
Member Author

TorkelE commented Jun 30, 2021

Sounds good, in the meantime

ejprob = EnsembleProblem(jprob,prob_func=(p,i,r)->remake(p), safetycopy=false)

also worked

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