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

save_positions not working with callbacks #327

Open
isaacsas opened this issue Jul 10, 2023 · 0 comments
Open

save_positions not working with callbacks #327

isaacsas opened this issue Jul 10, 2023 · 0 comments

Comments

@isaacsas
Copy link
Member

isaacsas commented Jul 10, 2023

using JumpProcesses

rate(u, p, t; debug=true) = 5.0
function affect!(integrator)
    integrator.u[1] += 1
    nothing
end
jump = VariableRateJump(rate, affect!; urate=(u,p,t)->10.0, rateinterval=(u,p,t)->0.1)
prob = DiscreteProblem([0.0], (0.0, 2.0), [1.0])
jump_prob_c = JumpProblem(prob, Coevolve(), jump; dep_graph=[[1]])

function terminate_condition(u, t, integrator)
    return u[1] >= 1
end

function terminate_affect!(integrator)
    terminate!(integrator)
end

terminate_cb = DiscreteCallback(terminate_condition, terminate_affect!; save_positions = (false,true))
solve(jump_prob_c, SSAStepper(); callback=terminate_cb, save_end = false)

gives

retcode: Terminated
Interpolation: Piecewise constant interpolation
t: 3-element Vector{Float64}:
 0.0
 0.04406872147816556
 0.04406872147816556
u: 3-element Vector{Vector{Float64}}:
 [0.0]
 [1.0]
 [1.0]

ignoring the callback's save_positions.

@isaacsas isaacsas changed the title Too many saves with callbacks save_positions not working with callbacks Jul 10, 2023
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

1 participant