Skip to content

Commit eeaf39a

Browse files
test: test initialization of DiscreteProblem(::JumpSystem)
1 parent 691e9ff commit eeaf39a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/initializationsystem.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,3 +1282,24 @@ end
12821282

12831283
@test SciMLBase.successful_retcode(solve(newprob))
12841284
end
1285+
1286+
@testset "Issue#3297: `generate_initializesystem(::JumpSystem)`" begin
1287+
@parameters β γ S0
1288+
@variables S(t)=S0 I(t) R(t)
1289+
rate₁ = β * S * I
1290+
affect₁ = [S ~ S - 1, I ~ I + 1]
1291+
rate₂ = γ * I
1292+
affect₂ = [I ~ I - 1, R ~ R + 1]
1293+
j₁ = ConstantRateJump(rate₁, affect₁)
1294+
j₂ = ConstantRateJump(rate₂, affect₂)
1295+
j₃ = MassActionJump(2 * β + γ, [R => 1], [S => 1, R => -1])
1296+
@mtkbuild js = JumpSystem([j₁, j₂, j₃], t, [S, I, R], [β, γ, S0])
1297+
1298+
u0s = [I => 1, R => 0]
1299+
ps = [S0 => 999, β => 0.01, γ => 0.001]
1300+
dprob = DiscreteProblem(js, u0s, (0.0, 10.0), ps)
1301+
@test dprob.f.initialization_data !== nothing
1302+
sol = solve(dprob, FunctionMap())
1303+
@test sol[S, 1] 999
1304+
@test SciMLBase.successful_retcode(sol)
1305+
end

0 commit comments

Comments
 (0)