Skip to content

Commit bcd0edb

Browse files
fix: fix timeseries detection for shifted variables in DDEs
1 parent 894c135 commit bcd0edb

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/systems/abstractsystem.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,10 @@ for traitT in [
766766
push!(ts_idxs, ContinuousTimeseries())
767767
elseif is_timeseries_parameter(sys, s)
768768
push!(ts_idxs, timeseries_parameter_index(sys, s).timeseries_idx)
769+
elseif is_time_dependent(sys) && iscall(s) && issym(operation(s)) &&
770+
is_variable(sys, operation(s)(get_iv(sys)))
771+
# DDEs case, to detect x(t - k)
772+
push!(ts_idxs, ContinuousTimeseries())
769773
elseif has_index_cache(sys) && (ic = get_index_cache(sys)) !== nothing
770774
if (ts = get(ic.observed_syms_to_timeseries, s, nothing)) !== nothing
771775
union!(ts_idxs, ts)

src/systems/index_cache.jl

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,11 @@ function IndexCache(sys::AbstractSystem)
262262
sym = eq.lhs
263263
vs = vars(eq.rhs)
264264
timeseries = TimeseriesSetType()
265-
for v in vs
266-
if (idx = get(disc_idxs, v, nothing)) !== nothing
267-
push!(timeseries, idx.clock_idx)
265+
if is_time_dependent(sys)
266+
for v in vs
267+
if (idx = get(disc_idxs, v, nothing)) !== nothing
268+
push!(timeseries, idx.clock_idx)
269+
end
268270
end
269271
end
270272
ttsym = default_toterm(sym)
@@ -284,11 +286,20 @@ function IndexCache(sys::AbstractSystem)
284286
sym = eq.lhs
285287
vs = vars(eq.rhs)
286288
timeseries = TimeseriesSetType()
287-
for v in vs
288-
if (idx = get(disc_idxs, v, nothing)) !== nothing
289-
push!(timeseries, idx.clock_idx)
290-
elseif haskey(unk_idxs, v) || haskey(observed_syms_to_timeseries, v)
291-
push!(timeseries, ContinuousTimeseries())
289+
if is_time_dependent(sys)
290+
for v in vs
291+
if (idx = get(disc_idxs, v, nothing)) !== nothing
292+
push!(timeseries, idx.clock_idx)
293+
elseif haskey(unk_idxs, v)
294+
push!(timeseries, ContinuousTimeseries())
295+
elseif haskey(observed_syms_to_timeseries, v)
296+
union!(timeseries, observed_syms_to_timeseries[v])
297+
elseif haskey(dependent_pars_to_timeseries, v)
298+
union!(timeseries, dependent_pars_to_timeseries[v])
299+
elseif iscall(v) && issym(operation(v)) &&
300+
is_variable(sys, operation(v)(get_iv(sys)))
301+
push!(timeseries, ContinuousTimeseries())
302+
end
292303
end
293304
end
294305
ttsym = default_toterm(sym)

0 commit comments

Comments
 (0)