Skip to content

Commit 3c36216

Browse files
feat: add specialized observed for solutions of DDEProblems
1 parent 012ff4e commit 3c36216

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/solutions/ode_solutions.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,35 @@ function (sol::AbstractODESolution)(t::AbstractVector{<:Number}, ::Type{deriv},
354354
return DiffEqArray(u, t, p, sol; discretes)
355355
end
356356

357+
struct DDESolutionHistoryWrapper{T}
358+
sol::T
359+
end
360+
361+
function (w::DDESolutionHistoryWrapper)(p, t; idxs = nothing)
362+
w.sol(t; idxs)
363+
end
364+
function (w::DDESolutionHistoryWrapper)(out, p, t; idxs = nothing)
365+
w.sol(out, t; idxs)
366+
end
367+
function (w::DDESolutionHistoryWrapper)(p, t, deriv::Type{Val{i}}; idxs = nothing) where {i}
368+
w.sol(t, deriv; idxs)
369+
end
370+
function (w::DDESolutionHistoryWrapper)(
371+
out, p, t, deriv::Type{Val{i}}; idxs = nothing) where {i}
372+
w.sol(out, t, deriv; idxs)
373+
end
374+
375+
function SymbolicIndexingInterface.observed(
376+
sol::ODESolution{T, N, uType,
377+
uType2, DType, tType, rateType, discType, P},
378+
sym) where {T, N, uType, uType2, DType, tType, rateType, discType, P <: DDEProblem}
379+
return let histfn = DDESolutionHistoryWrapper(sol),
380+
rawfn = SymbolicIndexingInterface.observed(symbolic_container(sol), sym)
381+
382+
fn(u, p, t) = rawfn(u, histfn, p, t)
383+
end
384+
end
385+
357386
# public API, used by MTK
358387
"""
359388
create_parameter_timeseries_collection(sys, ps, tspan)

0 commit comments

Comments
 (0)