-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
ODE-jump models with implicit solvers not working #459
Comments
For reference, the mean solution here is |
With this code:
I get the error:
However using |
Very strange. This is a really busy week for me, so I might not get to help investigate this till Friday or the weekend. If you wanted to play around you could try changing the linear solver to a matrix-free Krylov method and see if that helps: https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/#Using-Jacobian-Free-Newton-Krylov |
For both of you, are you on a Mac or Intel machine? The following should work for you for now: sol = solve(jump_prob, Rodas4(linsolve = LUFactorization()))
sol = solve(jump_prob, Rodas4(linsolve = RFLUFactorization())) Since I just moved I don't have all of my machines around, but I can see on my Mac that the issue is that we too readily default to AppleAccelerate overloads on a non-contiguous b vector. |
The other case that might be problematic which I cannot test right now is MKL, which is why I asked for if anyone has an Intel. Even if it's just an X86 though you can at least try and check: sol = solve(jump_prob, Rodas4(linsolve = MKLLUFactorization())) My guess is that it will likely have the same behavior as the Apple one. I'm trying to think though if there's a better solution than just not defaulting to the tuned BLAS in these cases. That might be the easiest robust solution though. |
I'm on a mac. |
@ChrisRackauckas do you have any idea about the issue with the simple birth-death example I posted? Is it degenerate for some reason due to |
(We actually use that one in the tests, so once it is working I will update the tests to check correctness against one or more implicit methods too.) |
I am also on a mac, using those above solvers does get rid of the error but I still hit MaxIters when run for a longer timespan. |
It's degenerate because the starting rate value ends up negative: julia> sol[1]
3-element ExtendedJumpArray{Float64, 1, Vector{Float64}, Vector{Float64}}:
1.0
-1.2064836293851149
-0.8345225253385252 so it never rootfinds. So @isaacsas your case is different from @hhindley 's. Why that starts negative is a bit of a mystery though |
The method relies on them being negative initially though? (i.e. we use the initial values |
Then the rate should be positive, but we somehow have a negative rate here. |
Could the nonlinear and/or linear solve be introducing small negative values even though |
But is this now consistent for both implicit and explicit solvers? If so, is it due to the frequency of jump firing? You can't "skip over" jumps with an implicit solver, so you'll still need to resolve each one. If you don't need / want to resolve each exact jump you'd need to use a tau-leaping approach instead. |
This is a bug. I haven't taken the time to figure out why it's going in the wrong direction, but it is. |
Yes that's possible due to LU factorization error growth. SciML/OrdinaryDiffEq.jl#1651 details exactly how that can happen. |
using JumpProcesses, OrdinaryDiffEq
p = [2.0, 1.0]
u0 = [1.0]
tspan = (0.0, 4.0)
function ode_fxn(du, u, p, t)
du .= 0
nothing
end
b_rate(u, p, t) = (u[1] * p[1])
function birth!(integrator)
integrator.u[1] += 1
nothing
end
b_jump = VariableRateJump(b_rate, birth!)
d_rate(u, p, t) = (u[1] * p[2])
function death!(integrator)
integrator.u[1] -= 1
nothing
end
d_jump = VariableRateJump(d_rate, death!)
ode_prob = ODEProblem(ode_fxn, u0, tspan, p)
sjm_prob = JumpProblem(ode_prob, b_jump, d_jump)
using LinearSolve
sol = solve(sjm_prob, Rodas5P(linsolve = QRFactorization()))
Correcting for the numerical error via QRFactorization fixes @isaacsas 's case as expected due to the issue linked above. |
Motivated by https://discourse.julialang.org/t/jumpprocesses-jl-solvers/121883 which seems to get an error instead, I am finding
gives
while
But this works fine with Tsit5().
The text was updated successfully, but these errors were encountered: