@@ -60,11 +60,13 @@ A[1, :] # all time periods for f(t)
60
60
A.t
61
61
```
62
62
"""
63
- mutable struct DiffEqArray{T, N, A, B, F, S} <: AbstractDiffEqArray{T, N, A}
63
+ mutable struct DiffEqArray{T, N, A, B, F, S, D <: Union{Nothing, ParameterTimeseriesCollection} } < :
64
+ AbstractDiffEqArray{T, N, A}
64
65
u:: A # A <: AbstractVector{<: AbstractArray{T, N - 1}}
65
66
t:: B
66
67
p:: F
67
68
sys:: S
69
+ discretes:: D
68
70
end
69
71
# ## Abstract Interface
70
72
struct AllObserved
@@ -174,29 +176,32 @@ function DiffEqArray(vec::AbstractVector{T},
174
176
ts:: AbstractVector ,
175
177
:: NTuple{N, Int} ,
176
178
p = nothing ,
177
- sys = nothing ) where {T, N}
178
- DiffEqArray {eltype(T), N, typeof(vec), typeof(ts), typeof(p), typeof(sys)} (vec,
179
+ sys = nothing ; discretes = nothing ) where {T, N}
180
+ DiffEqArray {eltype(T), N, typeof(vec), typeof(ts), typeof(p), typeof(sys), typeof(discretes) } (vec,
179
181
ts,
180
182
p,
181
- sys)
183
+ sys,
184
+ discretes)
182
185
end
183
186
184
187
# ambiguity resolution
185
188
function DiffEqArray (vec:: AbstractVector{VT} ,
186
189
ts:: AbstractVector ,
187
190
:: NTuple{N, Int} ) where {T, N, VT <: AbstractArray{T, N} }
188
- DiffEqArray {eltype(T), N, typeof(vec), typeof(ts), Nothing, Nothing} (vec,
191
+ DiffEqArray {eltype(T), N, typeof(vec), typeof(ts), Nothing, Nothing, Nothing } (vec,
189
192
ts,
190
193
nothing ,
194
+ nothing ,
191
195
nothing )
192
196
end
193
197
function DiffEqArray (vec:: AbstractVector{VT} ,
194
198
ts:: AbstractVector ,
195
- :: NTuple{N, Int} , p) where {T, N, VT <: AbstractArray{T, N} }
196
- DiffEqArray {eltype(T), N, typeof(vec), typeof(ts), typeof(p), Nothing} (vec,
199
+ :: NTuple{N, Int} , p; discretes = nothing ) where {T, N, VT <: AbstractArray{T, N} }
200
+ DiffEqArray {eltype(T), N, typeof(vec), typeof(ts), typeof(p), Nothing, typeof(discretes) } (vec,
197
201
ts,
198
202
p,
199
- nothing )
203
+ nothing ,
204
+ discretes)
200
205
end
201
206
# Assume that the first element is representative of all other elements
202
207
@@ -206,7 +211,8 @@ function DiffEqArray(vec::AbstractVector,
206
211
sys = nothing ;
207
212
variables = nothing ,
208
213
parameters = nothing ,
209
- independent_variables = nothing )
214
+ independent_variables = nothing ,
215
+ discretes = nothing )
210
216
sys = something (sys,
211
217
SymbolCache (something (variables, []),
212
218
something (parameters, []),
@@ -219,11 +225,13 @@ function DiffEqArray(vec::AbstractVector,
219
225
typeof (vec),
220
226
typeof (ts),
221
227
typeof (p),
222
- typeof (sys)
228
+ typeof (sys),
229
+ typeof (discretes)
223
230
}(vec,
224
231
ts,
225
232
p,
226
- sys)
233
+ sys,
234
+ discretes)
227
235
end
228
236
229
237
function DiffEqArray (vec:: AbstractVector{VT} ,
@@ -232,7 +240,8 @@ function DiffEqArray(vec::AbstractVector{VT},
232
240
sys = nothing ;
233
241
variables = nothing ,
234
242
parameters = nothing ,
235
- independent_variables = nothing ) where {T, N, VT <: AbstractArray{T, N} }
243
+ independent_variables = nothing ,
244
+ discretes = nothing ) where {T, N, VT <: AbstractArray{T, N} }
236
245
sys = something (sys,
237
246
SymbolCache (something (variables, []),
238
247
something (parameters, []),
@@ -243,18 +252,30 @@ function DiffEqArray(vec::AbstractVector{VT},
243
252
typeof (vec),
244
253
typeof (ts),
245
254
typeof (p),
246
- typeof (sys)
255
+ typeof (sys),
256
+ typeof (discretes),
247
257
}(vec,
248
258
ts,
249
259
p,
250
- sys)
260
+ sys,
261
+ discretes)
251
262
end
252
263
264
+ has_discretes (:: T ) where {T <: AbstractDiffEqArray } = hasfield (T, :discretes )
265
+ get_discretes (x) = getfield (x, :discretes )
266
+
253
267
SymbolicIndexingInterface. is_timeseries (:: Type{<:AbstractVectorOfArray} ) = Timeseries ()
268
+ function SymbolicIndexingInterface. is_parameter_timeseries (:: Type {DiffEqArray{T, N, A, B,
269
+ F, S, D}}) where {T, N, A, B, F, S, D <: ParameterIndexingProxy }
270
+ Timeseries ()
271
+ end
254
272
SymbolicIndexingInterface. state_values (A:: AbstractDiffEqArray ) = A. u
255
273
SymbolicIndexingInterface. current_time (A:: AbstractDiffEqArray ) = A. t
256
274
SymbolicIndexingInterface. parameter_values (A:: AbstractDiffEqArray ) = A. p
257
275
SymbolicIndexingInterface. symbolic_container (A:: AbstractDiffEqArray ) = A. sys
276
+ function SymbolicIndexingInterface. get_parameter_timeseries_collection (A:: AbstractDiffEqArray )
277
+ return get_discretes (A)
278
+ end
258
279
259
280
Base. IndexStyle (A:: AbstractVectorOfArray ) = Base. IndexStyle (typeof (A))
260
281
Base. IndexStyle (:: Type{<:AbstractVectorOfArray} ) = IndexCartesian ()
@@ -363,39 +384,18 @@ end
363
384
364
385
# Symbolic Indexing Methods
365
386
for (symtype, elsymtype, valtype, errcheck) in [
366
- (ScalarSymbolic, SymbolicIndexingInterface. SymbolicTypeTrait, Any, :(is_parameter (A, sym))),
367
- (ArraySymbolic, SymbolicIndexingInterface. SymbolicTypeTrait, Any, :(is_parameter (A, sym))),
387
+ (ScalarSymbolic, SymbolicIndexingInterface. SymbolicTypeTrait, Any, :(is_parameter (A, sym) && ! is_timeseries_parameter (A, sym) )),
388
+ (ArraySymbolic, SymbolicIndexingInterface. SymbolicTypeTrait, Any, :(is_parameter (A, sym) && ! is_timeseries_parameter (A, sym) )),
368
389
(NotSymbolic, SymbolicIndexingInterface. SymbolicTypeTrait, Union{<: Tuple , <: AbstractArray },
369
- :(all (x -> is_parameter (A, x), sym))),
390
+ :(all (x -> is_parameter (A, x) && ! is_timeseries_parameter (A, x) , sym))),
370
391
]
371
- @eval Base. @propagate_inbounds function _getindex (A:: AbstractDiffEqArray , :: $symtype ,
372
- :: $elsymtype , sym:: $valtype )
373
- if $ errcheck
374
- throw (ParameterIndexingError (sym))
375
- end
376
- getu (A, sym)(A)
377
- end
378
- @eval Base. @propagate_inbounds function _getindex (A:: AbstractDiffEqArray , :: $symtype ,
379
- :: $elsymtype , sym:: $valtype , arg)
380
- if $ errcheck
381
- throw (ParameterIndexingError (sym))
382
- end
383
- getu (A, sym)(A, arg)
384
- end
385
- @eval Base. @propagate_inbounds function _getindex (A:: AbstractDiffEqArray , :: $symtype ,
386
- :: $elsymtype , sym:: $valtype , arg:: Union{AbstractArray{Int}, AbstractArray{Bool}} )
387
- if $ errcheck
388
- throw (ParameterIndexingError (sym))
389
- end
390
- getu (A, sym).((A,), arg)
391
- end
392
- @eval Base. @propagate_inbounds function _getindex (A:: AbstractDiffEqArray , :: $symtype ,
393
- :: $elsymtype , sym:: $valtype , :: Colon )
394
- if $ errcheck
395
- throw (ParameterIndexingError (sym))
392
+ @eval Base. @propagate_inbounds function _getindex (A:: AbstractDiffEqArray , :: $symtype ,
393
+ :: $elsymtype , sym:: $valtype , arg... )
394
+ if $ errcheck
395
+ throw (ParameterIndexingError (sym))
396
+ end
397
+ getu (A, sym)(A, arg... )
396
398
end
397
- getu (A, sym)(A)
398
- end
399
399
end
400
400
401
401
Base. @propagate_inbounds function _getindex (A:: AbstractDiffEqArray , :: ScalarSymbolic ,
0 commit comments