Skip to content

Commit ae335e1

Browse files
test/simulate_jumps: use setp instead of integrator.ps for callback param updates
JumpProcesses.SSAIntegrator does not expose a `ps` accessor (only `derivative_discontinuity` is in its property list under SciMLBase v3), so `integrator.ps[:k] = value` fails with FieldError. The four affected callbacks were the actual cause of the 4 errors in `Tests (*, Simulation)` jobs: Higher-order MAJ parameter updates (combinatoric=true) — line 451 Higher-order MAJ parameter updates (combinatoric=false) — line 500 Mixed-order MAJ parameter updates (combinatoric=true) — line 545 Combinatoric true/false equivalence (3X→Y) — line ~645 Migration: capture the parameter setter via SymbolicIndexingInterface.setp once at problem-construction time, then call it inside the callback. SII is implemented on the integrator interface (not via getproperty), so it flows through SSAIntegrator correctly: setk! = setp(jprob_cb, :k) function affect_cb!(integrator) setk!(integrator, 24.0) reset_aggregated_jumps!(integrator) end This is the v3-canonical pattern for symbolically-indexed parameter updates inside callbacks; same shape works on ODEIntegrator, SDEIntegrator, and SSAIntegrator alike. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent 190a7f9 commit ae335e1

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

test/simulation_and_solving/simulate_jumps.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Fetch packages.
44
using Catalyst, JumpProcesses, ModelingToolkitBase, OrdinaryDiffEqTsit5, Statistics, Test
5+
using SymbolicIndexingInterface: setp
56

67
# Sets stable rng number.
78
using StableRNGs
@@ -447,8 +448,9 @@ end
447448
jprob_cb = JumpProblem(rn, u0, (0.0, 200.0), ps;
448449
aggregator = Direct(), save_positions = (false, false))
449450
condit(u, t, integrator) = t == 100.0
451+
setk! = setp(jprob_cb, :k)
450452
function affect_cb!(integrator)
451-
integrator.ps[:k] = 24.0
453+
setk!(integrator, 24.0)
452454
reset_aggregated_jumps!(integrator)
453455
end
454456
cb = DiscreteCallback(condit, affect_cb!)
@@ -496,8 +498,9 @@ end
496498
jprob_cb = JumpProblem(rn, u0, (0.0, 200.0), ps;
497499
aggregator = Direct(), save_positions = (false, false))
498500
condit(u, t, integrator) = t == 100.0
501+
setk! = setp(jprob_cb, :k)
499502
function affect_cb!(integrator)
500-
integrator.ps[:k] = 24.0
503+
setk!(integrator, 24.0)
501504
reset_aggregated_jumps!(integrator)
502505
end
503506
cb = DiscreteCallback(condit, affect_cb!)
@@ -541,8 +544,9 @@ end
541544
jprob_cb = JumpProblem(rn, u0, (0.0, 200.0), ps;
542545
aggregator = Direct(), save_positions = (false, false))
543546
condit(u, t, integrator) = t == 100.0
547+
setk1! = setp(jprob_cb, :k1)
544548
function affect_cb!(integrator)
545-
integrator.ps[:k1] = 24.0
549+
setk1!(integrator, 24.0)
546550
reset_aggregated_jumps!(integrator)
547551
end
548552
cb = DiscreteCallback(condit, affect_cb!)
@@ -641,8 +645,10 @@ end
641645
aggregator = Direct(), save_positions = (false, false))
642646
condit(u, t, integrator) = t == 100.0
643647
new_k_true = 24.0
648+
new_k_val = rn === rn_true ? new_k_true : new_k_true / factorial(3)
649+
setk! = setp(jp, :k)
644650
function affect_equiv!(integrator)
645-
integrator.ps[:k] = rn === rn_true ? new_k_true : new_k_true / factorial(3)
651+
setk!(integrator, new_k_val)
646652
reset_aggregated_jumps!(integrator)
647653
end
648654
cb = DiscreteCallback(condit, affect_equiv!)

0 commit comments

Comments
 (0)