Skip to content

Commit b1ccc75

Browse files
Merge pull request #3581 from AayushSabharwal/as/jprob-remake
fix: fix `remake(::JumpProblem)`
2 parents 6d75b65 + 44bb9d5 commit b1ccc75

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/systems/nonlinear/initializesystem.jl

+4
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ function SciMLBase.remake_initialization_data(
484484

485485
oldinitdata = odefn.initialization_data
486486

487+
# We _always_ build initialization now. So if we didn't build it before, don't do
488+
# it now
489+
oldinitdata === nothing && return nothing
490+
487491
if !(eltype(u0) <: Pair) && !(eltype(p) <: Pair)
488492
oldinitdata === nothing && return nothing
489493

test/jumpsystem.jl

+15
Original file line numberDiff line numberDiff line change
@@ -551,3 +551,18 @@ end
551551
sol = solve(jprob, SSAStepper())
552552
@test eltype(sol[X]) === Int64
553553
end
554+
555+
@testset "Issue#3571: `remake(::JumpProblem)`" begin
556+
@variables X(t)
557+
@parameters a b
558+
eq = D(X) ~ a
559+
rate = b * X
560+
affect = [X ~ X - 1]
561+
crj = ConstantRateJump(rate, affect)
562+
@named jsys = JumpSystem([crj, eq], t, [X], [a, b])
563+
jsys = complete(jsys)
564+
oprob = ODEProblem(jsys, [:X => 1.0], (0.0, 10.0), [:a => 1.0, :b => 0.5])
565+
jprob = JumpProblem(jsys, oprob)
566+
jprob2 = remake(jprob; u0 = [:X => 10.0])
567+
@test jprob2[X] 10.0
568+
end

0 commit comments

Comments
 (0)