From bb7918400039cb3e57a5b81c693bb0ca6f6b3683 Mon Sep 17 00:00:00 2001 From: Sam Isaacson Date: Fri, 9 Aug 2024 13:38:19 -0400 Subject: [PATCH 1/3] preserve observed and sys when extending functions --- src/problem.jl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/problem.jl b/src/problem.jl index 6af1f1e3..026fe544 100644 --- a/src/problem.jl +++ b/src/problem.jl @@ -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) @@ -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) @@ -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 @@ -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) From 23dfc2b006e8c116fd3dd2886dcac64d8319dc5f Mon Sep 17 00:00:00 2001 From: Sam Isaacson Date: Fri, 9 Aug 2024 14:20:08 -0400 Subject: [PATCH 2/3] format --- src/problem.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/problem.jl b/src/problem.jl index 026fe544..8e6f8247 100644 --- a/src/problem.jl +++ b/src/problem.jl @@ -300,7 +300,7 @@ function extend_problem(prob::DiffEqBase.AbstractODEProblem, jumps; rng = DEFAUL u0 = ExtendedJumpArray(prob.u0, [-randexp(rng, ttype) for i in 1:length(jumps)]) f = ODEFunction{isinplace(prob)}(jump_f; sys = prob.f.sys, - observed = prob.f.observed) + observed = prob.f.observed) remake(prob; f, u0) end @@ -337,7 +337,7 @@ 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)]) f = SDEFunction{isinplace(prob)}(jump_f, jump_g; sys = prob.f.sys, - observed = prob.f.observed) + observed = prob.f.observed) remake(prob; f, g = jump_g, u0) end @@ -364,7 +364,7 @@ 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)]) f = DDEFunction{isinplace(prob)}(jump_f; sys = prob.f.sys, - observed = prob.f.observed) + observed = prob.f.observed) remake(prob; f, u0) end @@ -393,7 +393,7 @@ function extend_problem(prob::DiffEqBase.AbstractDAEProblem, jumps; rng = DEFAUL u0 = ExtendedJumpArray(prob.u0, [-randexp(rng, ttype) for i in 1:length(jumps)]) f = DAEFunction{isinplace(prob)}(jump_f, sys = prob.f.sys, - observed = prob.f.observed) + observed = prob.f.observed) remake(prob; f, u0) end From 6ef0bbb5036effe1954a759497e6a8243be26ea0 Mon Sep 17 00:00:00 2001 From: Sam Isaacson Date: Fri, 9 Aug 2024 14:20:51 -0400 Subject: [PATCH 3/3] bump project --- Project.toml | 2 +- docs/Project.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index aaeececa..938c66d2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JumpProcesses" uuid = "ccbc3e58-028d-4f4c-8cd5-9ae44345cda5" authors = ["Chris Rackauckas "] -version = "9.13.1" +version = "9.13.2" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" diff --git a/docs/Project.toml b/docs/Project.toml index bfd045a7..6cc0c98d 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -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"