Shift VCC test u0[4] off saveat-coincident event time#1448
Merged
ChrisRackauckas merged 1 commit intoMay 21, 2026
Merged
Conversation
The "callback with linear affect" testset uses condition `u[3] - 10` which, combined with u[3](t) = u0[4]*t, puts the event at τ = 10/u0[4]. With the original u0[4] = 2.0, τ = 5.0 exactly — landing on the saveat=0.5 grid. At a saveat-coincident event time the cost is jump-discontinuous in u0[3] and u0[4]: the post-event state propagates to that saveat sample, and the Float64 rootfinder versus ForwardDiff's Dual rootfinder converge to opposite ULP sides of the saveat. Both compute valid one-sided derivatives of a discontinuous cost; rtol comparisons between them fail by design at that point. Verified via central finite differences (1/h blow-up on components 3 and 4 at u0[4]=2.0; clean 5+ digit agreement among FD, BS, GA at u0[4]=2.01 with τ ≈ 4.975). Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ignore until reviewed by @ChrisRackauckas.
Summary
In
test_vector_continuous_callback(test/callbacks/vector_continuous_callbacks.jl), shiftu0[4]from2.0to2.01so the "callback with linear affect" event (conditionu[3] = 10) lands at τ ≈ 4.975 instead of exactly 5.0 — off thesaveat = 0.5grid.At τ = saveat, the cost has a true jump discontinuity in
u0[3]andu0[4]: the post-affect state (u[4] ← -p[2]·u[4] = -1.8) propagates to the saveat-5.0 sample on one side of the corner and the pre-affect state (u[4] = 2.0) on the other. The Float64 forward rootfinder converges 1 ULP below 5.0; ForwardDiff's Dual rootfinder converges ~6 ULPs above. Both compute valid one-sided derivatives, butBS ≈ FD rtol=1e-5then compares opposite-side derivatives and fails by design — not an algorithmic bug.Verification
Central finite differences (
(L(+h) − L(−h)) / 2h) atu0 = [50, 0, 0, 2.0]:1/h— classic jump signature ([323, 1.70e5, 1.70e7]for h ∈ {1e-3, 1e-5, 1e-7})At
u0[4] = 2.01(τ ≈ 4.975, off-grid): FD ≈ BS ≈ GA ≈ CFD to 5–6 digits across all components.Full FD writeup in closed issue #1447.
Relationship to #1446
#1446 fixes a
MethodErrorin the VCC tracking constructor that masked these tests entirely. Once #1446 lands, the constructor works but this testset numerically fails at the corner. This PR is the right resolution for the numerical failure.The two PRs can land in either order — this one is a pure test-data tweak with no functional impact; #1446 is an
src/fix that's still correct without this change.Refs
Test plan
test/callbacks/vector_continuous_callbacks.jlpass on Julia 1.12.6 locally with this change applied on top of Use single-affect VCC constructor in _track_callback #1446