Skip to content

Commit

Permalink
Merge pull request #438 from isaacsas/fix_extending_problems
Browse files Browse the repository at this point in the history
preserve observed and sys when extending functions
  • Loading branch information
isaacsas authored Aug 10, 2024
2 parents e43f35a + 6ef0bbb commit ea5d154
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JumpProcesses"
uuid = "ccbc3e58-028d-4f4c-8cd5-9ae44345cda5"
authors = ["Chris Rackauckas <[email protected]>"]
version = "9.13.1"
version = "9.13.2"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DifferentialEquations = "7.11"
Distributions = "0.25"
Documenter = "1.1"
Graphs = "1.9"
JumpProcesses = "9.8"
JumpProcesses = "9.13.2"
OrdinaryDiffEq = "6.59"
Plots = "1.39"
PointProcesses = "0.5"
Expand Down
16 changes: 12 additions & 4 deletions src/problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ function extend_problem(prob::DiffEqBase.AbstractODEProblem, jumps; rng = DEFAUL
ttype = eltype(prob.tspan)
u0 = ExtendedJumpArray(prob.u0,
[-randexp(rng, ttype) for i in 1:length(jumps)])
remake(prob, f = ODEFunction{isinplace(prob)}(jump_f), u0 = u0)
f = ODEFunction{isinplace(prob)}(jump_f; sys = prob.f.sys,
observed = prob.f.observed)
remake(prob; f, u0)
end

function extend_problem(prob::DiffEqBase.AbstractSDEProblem, jumps; rng = DEFAULT_RNG)
Expand Down Expand Up @@ -334,7 +336,9 @@ function extend_problem(prob::DiffEqBase.AbstractSDEProblem, jumps; rng = DEFAUL

ttype = eltype(prob.tspan)
u0 = ExtendedJumpArray(prob.u0, [-randexp(rng, ttype) for i in 1:length(jumps)])
remake(prob, f = SDEFunction{isinplace(prob)}(jump_f, jump_g), g = jump_g, u0 = u0)
f = SDEFunction{isinplace(prob)}(jump_f, jump_g; sys = prob.f.sys,
observed = prob.f.observed)
remake(prob; f, g = jump_g, u0)
end

function extend_problem(prob::DiffEqBase.AbstractDDEProblem, jumps; rng = DEFAULT_RNG)
Expand All @@ -359,7 +363,9 @@ function extend_problem(prob::DiffEqBase.AbstractDDEProblem, jumps; rng = DEFAUL

ttype = eltype(prob.tspan)
u0 = ExtendedJumpArray(prob.u0, [-randexp(rng, ttype) for i in 1:length(jumps)])
remake(prob, f = DDEFunction{isinplace(prob)}(jump_f), u0 = u0)
f = DDEFunction{isinplace(prob)}(jump_f; sys = prob.f.sys,
observed = prob.f.observed)
remake(prob; f, u0)
end

# Not sure if the DAE one is correct: Should be a residual of sorts
Expand All @@ -386,7 +392,9 @@ function extend_problem(prob::DiffEqBase.AbstractDAEProblem, jumps; rng = DEFAUL
ttype = eltype(prob.tspan)
u0 = ExtendedJumpArray(prob.u0,
[-randexp(rng, ttype) for i in 1:length(jumps)])
remake(prob, f = DAEFunction{isinplace(prob)}(jump_f), u0 = u0)
f = DAEFunction{isinplace(prob)}(jump_f, sys = prob.f.sys,
observed = prob.f.observed)
remake(prob; f, u0)
end

function build_variable_callback(cb, idx, jump, jumps...; rng = DEFAULT_RNG)
Expand Down

0 comments on commit ea5d154

Please sign in to comment.