File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,20 @@ function clean_calls(funcs)
172172 return res
173173end
174174
175+ # ------------------------------------------------------------------------------
176+
177+ function scalarize (arr)
178+ result = []
179+ for a in arr
180+ if typeof (a) <: SymbolicUtils.BasicSymbolic{<:Vector}
181+ append! (result, collect (a))
182+ else
183+ push! (result, a)
184+ end
185+ end
186+ return result
187+ end
188+
175189# ------------------------------------------------------------------------------
176190"""
177191 function __mtk_to_si(de::ModelingToolkit.AbstractTimeDependentSystem, measured_quantities::Array{Tuple{String, SymbolicUtils.BasicSymbolic}})
@@ -209,7 +223,7 @@ function __mtk_to_si(
209223 filter (s -> ! ModelingToolkit. isoutput (s), clean_calls (map (e -> e. lhs, diff_eqs)))
210224 all_funcs = collect (Set (clean_calls (ModelingToolkit. unknowns (de))))
211225 inputs = filter (s -> ! ModelingToolkit. isoutput (s), setdiff (all_funcs, state_vars))
212- params = ModelingToolkit. parameters (de)
226+ params = scalarize ( ModelingToolkit. parameters (de) )
213227 t = ModelingToolkit. arguments (clean_calls ([diff_eqs[1 ]. lhs])[1 ])[1 ]
214228 # very long if in order to avoid duplication
215229 params_from_measured_quantities = union (
Original file line number Diff line number Diff line change @@ -427,6 +427,25 @@ if GROUP == "All" || GROUP == "ModelingToolkitSIExt"
427427 @test assess_local_identifiability (sys, measured_quantities = [x[1 ], x[2 ]]) ==
428428 correct
429429
430+ # Extension of https://github.com/SciML/StructuralIdentifiability.jl/issues/398
431+ @parameters k[1 : 2 ] a
432+ @variables (X (t))[1 : 2 ] (y (t))[1 : 2 ] [output = true ]
433+ eqs = [
434+ D (X[1 ]) ~ k[1 ] - k[2 ] * X[2 ],
435+ D (X[2 ]) ~ k[1 ] - k[2 ] * X[1 ],
436+ y[1 ] ~ X[1 ] * X[2 ] + a,
437+ y[2 ] ~ X[1 ] - X[2 ],
438+ ]
439+ @mtkbuild osys = ODESystem (eqs, t)
440+ correct = OrderedDict (
441+ X[1 ] => :locally ,
442+ X[2 ] => :locally ,
443+ k[1 ] => :locally ,
444+ k[2 ] => :globally ,
445+ a => :globally ,
446+ )
447+ @test assess_identifiability (osys) == correct
448+
430449 # ------------------------------------
431450 # system from the SciML tutorial
432451 # https://docs.sciml.ai/ModelingToolkit/stable/tutorials/parameter_identifiability/
You can’t perform that action at this time.
0 commit comments