@@ -56,11 +56,17 @@ struct GetIndepvar <: AbstractStateGetIndexer end
5656(:: GetIndepvar )(:: IsTimeseriesTrait , prob) = current_time (prob)
5757(:: GetIndepvar )(:: Timeseries , prob, i) = current_time (prob, i)
5858
59- struct TimeDependentObservedFunction{I, F} <: AbstractStateGetIndexer
59+ struct TimeDependentObservedFunction{I, F, H } <: AbstractStateGetIndexer
6060 ts_idxs:: I
6161 obsfn:: F
6262end
6363
64+ function TimeDependentObservedFunction {H} (ts_idxs, obsfn) where {H}
65+ return TimeDependentObservedFunction {typeof(ts_idxs), typeof(obsfn), H} (ts_idxs, obsfn)
66+ end
67+
68+ const NonMarkovianObservedFunction = TimeDependentObservedFunction{I, F, false } where {I, F}
69+
6470indexer_timeseries_index (t:: TimeDependentObservedFunction ) = t. ts_idxs
6571function is_indexer_timeseries (:: Type{G} ) where {G < :
6672 TimeDependentObservedFunction{ContinuousTimeseries}}
@@ -74,15 +80,26 @@ function (o::TimeDependentObservedFunction)(ts::IsTimeseriesTrait, prob, args...
7480 return o (ts, is_indexer_timeseries (o), prob, args... )
7581end
7682
77- function (o:: TimeDependentObservedFunction )(ts:: Timeseries , :: IndexerBoth , prob)
83+ function (o:: TimeDependentObservedFunction )(:: Timeseries , :: IndexerBoth , prob)
84+ return o. obsfn .(state_values (prob),
85+ (parameter_values (prob),),
86+ current_time (prob))
87+ end
88+ function (o:: NonMarkovianObservedFunction )(:: Timeseries , :: IndexerBoth , prob)
7889 return o. obsfn .(state_values (prob),
90+ (get_history_function (prob),),
7991 (parameter_values (prob),),
8092 current_time (prob))
8193end
8294function (o:: TimeDependentObservedFunction )(
8395 :: Timeseries , :: IndexerBoth , prob, i:: Union{Int, CartesianIndex} )
8496 return o. obsfn (state_values (prob, i), parameter_values (prob), current_time (prob, i))
8597end
98+ function (o:: NonMarkovianObservedFunction )(
99+ :: Timeseries , :: IndexerBoth , prob, i:: Union{Int, CartesianIndex} )
100+ return o. obsfn (state_values (prob, i), get_history_function (prob),
101+ parameter_values (prob), current_time (prob, i))
102+ end
86103function (o:: TimeDependentObservedFunction )(ts:: Timeseries , :: IndexerBoth , prob, :: Colon )
87104 return o (ts, prob)
88105end
98115function (o:: TimeDependentObservedFunction )(:: NotTimeseries , :: IndexerBoth , prob)
99116 return o. obsfn (state_values (prob), parameter_values (prob), current_time (prob))
100117end
118+ function (o:: NonMarkovianObservedFunction )(:: NotTimeseries , :: IndexerBoth , prob)
119+ return o. obsfn (state_values (prob), get_history_function (prob),
120+ parameter_values (prob), current_time (prob))
121+ end
101122
102123function (o:: TimeDependentObservedFunction )(
103124 :: Timeseries , :: IndexerMixedTimeseries , prob, args... )
@@ -107,6 +128,11 @@ function (o::TimeDependentObservedFunction)(
107128 :: NotTimeseries , :: IndexerMixedTimeseries , prob, args... )
108129 return o. obsfn (state_values (prob), parameter_values (prob), current_time (prob))
109130end
131+ function (o:: NonMarkovianObservedFunction )(
132+ :: NotTimeseries , :: IndexerMixedTimeseries , prob, args... )
133+ return o. obsfn (state_values (prob), get_history_function (prob),
134+ parameter_values (prob), current_time (prob))
135+ end
110136
111137struct TimeIndependentObservedFunction{F} <: AbstractStateGetIndexer
112138 obsfn:: F
@@ -137,7 +163,7 @@ function _getu(sys, ::ScalarSymbolic, ::SymbolicTypeTrait, sym)
137163 ts_idxs = collect (ts_idxs)
138164 end
139165 fn = observed (sys, sym)
140- return TimeDependentObservedFunction (ts_idxs, fn)
166+ return TimeDependentObservedFunction {is_markovian(sys)} (ts_idxs, fn)
141167 else
142168 return getp (sys, sym)
143169 end
@@ -256,7 +282,7 @@ for (t1, t2) in [
256282 else
257283 obs = observed (sys, sym_arr)
258284 getter = if is_time_dependent (sys)
259- TimeDependentObservedFunction (ts_idxs, obs)
285+ TimeDependentObservedFunction {is_markovian(sys)} (ts_idxs, obs)
260286 else
261287 TimeIndependentObservedFunction (obs)
262288 end
0 commit comments