SciML / SciML/JumpProcesses.jl

`save_positions` not working with callbacks

Open
#327 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
150
Forks
41
Avg merge
1d 9h
Merged PRs (30d)
28

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied Julia reproducer with JumpProcesses, focusing on DiscreteCallback, save_positions, solve, and SSAStepper. Trace how the callback is handled during termination and compare the returned t and u values with the requested (false, true) setting. Done means callback save_positions is respected in this case and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.