# Certain callback does not seem to have an effect when solving JumpProblem

I am trying to solve a jump problem. As a part of it, mid simulation, I change a parameter. This is basically an input being triggered into the system. This does not seem to have much effect though, and I am unsure why:

``````using DifferentialEquations, Catalyst

my_network = @reaction_network begin
v0 + hill(σ,v,K,n), ∅ → σ
deg, (σ,iσ) → ∅
(kB,kD), σ ↔ iσ
input, iσ → σ
end v0 v K n kB kD deg input;
v0 = 0.01; v = 0.25; K = 5.; n = 2.;
kB = 1.; kD = 1.;
deg = 0.01;
input = 0.;
p = [v0, v, K, n, kB, kD, deg, input]

cb_condition(u,t,integrator) = (t==1000.)
function cb_affect!(integrator)
integrator.p[8] = 10.
#println(integrator.p)    # This shows that p indeed gets modified correctly.
end
cb = DiscreteCallback(cb_condition,cb_affect!,save_positions = (false,false))

prob_disc = DiscreteProblem(my_network,[5,5],(0.,2000.),p)
prob_jump = JumpProblem(my_network,prob_disc,Direct())
sol = solve(prob_jump, SSAStepper(),callback=cb,tstops=[1000.])

using Plots
plot(sol)
``````

Here the input should break the symmetry, but in the plot, I can see that both variables are very similar. The callback seems to work though, removing the comment gives me a print confirming that the parameter value is changed. Also, making the callback work on the 2nd parameter (`v`), I can see a drastic change at time `1000`. Finally, by setting the initial value of the input to `10`, I can confirm that the system solution looks very different.

I have never really run much SSA stuff, is there possibly something I am missing where the callback is not registered properly, or is there something else going on?

When you change parameters in a jump simulation, you will need to do `reset_jumps!(integrator)` to re-evaluate the next step, otherwise it won’t re-initiate.

Sounds good.

When I try

``````function cb_affect!(integrator)
integrator.p[8] = 10.
reset_jumps!(integrator)
end
``````

I get an `UndefVarError: reset_jumps! not defined` error. This is an extract from my `Pkg.status()`

``````  [479239e8] Catalyst v5.0.4 `~/.julia/dev/Catalyst`
[cb7047e7] CatalystSupport v0.1.0 `~/.julia/dev/CatalystSupport`
[134e5e36] Catlab v0.7.4
[5ae59095] Colors v0.12.4
[34da2185] Compat v3.15.0
[a2441757] Coverage v1.1.1
[864edb3b] DataStructures v0.17.20
[31a5f54b] Debugger v0.6.6
[2b5f629d] DiffEqBase v6.44.3
[eb300fae] DiffEqBiological v4.2.0 `~/.julia/dev/DiffEqBiological`
[f3b72e0c] DiffEqDevTools v2.27.0
[c894b116] DiffEqJump v6.10.0
[77a26b50] DiffEqNoiseProcess v5.3.0
[c3c3384c] DiffEqParameters v0.2.0 `https://gitlab.com/slcu/teamHJ/niklas/DiffEqParameters.jl.git#master`
[0c46a032] DifferentialEquations v6.15.0
``````

I found a function `reset_aggregated_jumps!(integrator)`. No idea what it does. I can use it, the code runs, but there’s not change in behaviour:

``````function cb_affect!(integrator)
integrator.p[8] = 10.
reset_aggregated_jumps!(integrator)
end
``````