From 8d97f5f5cbad7ebcefbef5db196b9daef468153e Mon Sep 17 00:00:00 2001 From: pogudingleb Date: Tue, 14 Nov 2023 13:37:31 +0100 Subject: [PATCH] renaming preprocess_ode to mtk_to_si --- src/ODE.jl | 45 +++++++++++++++++++++++++------- src/StructuralIdentifiability.jl | 4 +-- src/discrete.jl | 2 +- src/identifiable_functions.jl | 2 +- src/local_identifiability.jl | 2 +- 5 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/ODE.jl b/src/ODE.jl index d677479b0..271dffac5 100644 --- a/src/ODE.jl +++ b/src/ODE.jl @@ -520,8 +520,8 @@ end #------------------------------------------------------------------------------ """ - function preprocess_ode(de::ModelingToolkit.AbstractTimeDependentSystem, measured_quantities::Array{ModelingToolkit.Equation}) - function preprocess_ode(de::ModelingToolkit.AbstractTimeDependentSystem, measured_quantities::Array{SymbolicUtils.BasicSymbolic}) + function mtk_to_si(de::ModelingToolkit.AbstractTimeDependentSystem, measured_quantities::Array{ModelingToolkit.Equation}) + function mtk_to_si(de::ModelingToolkit.AbstractTimeDependentSystem, measured_quantities::Array{SymbolicUtils.BasicSymbolic}) Input: - `de` - ModelingToolkit.AbstractTimeDependentSystem, a system for identifiability query @@ -532,36 +532,63 @@ Output: - `conversion` dictionary from the symbols in the input MTK model to the variable involved in the produced `ODE` object """ -function preprocess_ode( +function mtk_to_si( de::ModelingToolkit.AbstractTimeDependentSystem, measured_quantities::Array{ModelingToolkit.Equation}, ) - return __preprocess_ode( + return __mtk_to_si( de, [(replace(string(e.lhs), "(t)" => ""), e.rhs) for e in measured_quantities], ) end -function preprocess_ode( +function mtk_to_si( de::ModelingToolkit.AbstractTimeDependentSystem, measured_quantities::Array{<:Symbolics.Num}, ) - return __preprocess_ode( + return __mtk_to_si( de, [("y$i", Symbolics.value(e)) for (i, e) in enumerate(measured_quantities)], ) end +function mtk_to_si( + de::ModelingToolkit.AbstractTimeDependentSystem, + measured_quantities::Array{<:SymbolicUtils.BasicSymbolic}, +) + return __mtk_to_si(de, [("y$i", e) for (i, e) in enumerate(measured_quantities)]) +end + +#------------------------------------------------------------------------------ +# old name kept for compatibility purposes + +function preprocess_ode( + de::ModelingToolkit.AbstractTimeDependentSystem, + measured_quantities::Array{ModelingToolkit.Equation}, +) + @warn "Function `preprocess_ode` has been renamed to `mtk_to_si`. The old name can be still used but will disappear in the future releases." + return mtk_to_si(de, measured_quantities) +end + +function preprocess_ode( + de::ModelingToolkit.AbstractTimeDependentSystem, + measured_quantities::Array{<:Symbolics.Num}, +) + @warn "Function `preprocess_ode` has been renamed to `mtk_to_si`. The old name can be still used but will disappear in the future releases." + return mtk_to_si(de, measured_quantities) +end + function preprocess_ode( de::ModelingToolkit.AbstractTimeDependentSystem, measured_quantities::Array{<:SymbolicUtils.BasicSymbolic}, ) - return __preprocess_ode(de, [("y$i", e) for (i, e) in enumerate(measured_quantities)]) + @warn "Function `preprocess_ode` has been renamed to `mtk_to_si`. The old name can be still used but will disappear in the future releases." + return mtk_to_si(de, measured_quantities) end #------------------------------------------------------------------------------ """ - function __preprocess_ode(de::ModelingToolkit.AbstractTimeDependentSystem, measured_quantities::Array{Tuple{String, SymbolicUtils.BasicSymbolic}}) + function __mtk_to_si(de::ModelingToolkit.AbstractTimeDependentSystem, measured_quantities::Array{Tuple{String, SymbolicUtils.BasicSymbolic}}) Input: - `de` - ModelingToolkit.AbstractTimeDependentSystem, a system for identifiability query @@ -572,7 +599,7 @@ Output: - `conversion` dictionary from the symbols in the input MTK model to the variable involved in the produced `ODE` object """ -function __preprocess_ode( +function __mtk_to_si( de::ModelingToolkit.AbstractTimeDependentSystem, measured_quantities::Array{<:Tuple{String, <:SymbolicUtils.BasicSymbolic}}, ) diff --git a/src/StructuralIdentifiability.jl b/src/StructuralIdentifiability.jl index 227d12164..40fad56d4 100644 --- a/src/StructuralIdentifiability.jl +++ b/src/StructuralIdentifiability.jl @@ -23,7 +23,7 @@ ParamPunPam.enable_progressbar(false) using ModelingToolkit # defining a model -export ODE, @ODEmodel, preprocess_ode +export ODE, @ODEmodel, mtk_to_si # assessing identifiability export assess_local_identifiability, assess_identifiability @@ -207,7 +207,7 @@ function _assess_identifiability( measured_quantities = get_measured_quantities(ode) end - ode, conversion = preprocess_ode(ode, measured_quantities) + ode, conversion = mtk_to_si(ode, measured_quantities) conversion_back = Dict(v => k for (k, v) in conversion) if isempty(funcs_to_check) funcs_to_check = [conversion_back[x] for x in [ode.parameters..., ode.x_vars...]] diff --git a/src/discrete.jl b/src/discrete.jl index 628797e98..99f46f75f 100644 --- a/src/discrete.jl +++ b/src/discrete.jl @@ -328,7 +328,7 @@ function assess_local_identifiability( end end - dds_aux, conversion = preprocess_ode(dds, measured_quantities) + dds_aux, conversion = mtk_to_si(dds, measured_quantities) if length(funcs_to_check) == 0 funcs_to_check = vcat( parameters(dds), diff --git a/src/identifiable_functions.jl b/src/identifiable_functions.jl index 18cde16c6..4edb29b83 100644 --- a/src/identifiable_functions.jl +++ b/src/identifiable_functions.jl @@ -193,7 +193,7 @@ function _find_identifiable_functions( if isempty(measured_quantities) measured_quantities = get_measured_quantities(ode) end - ode, conversion = preprocess_ode(ode, measured_quantities) + ode, conversion = mtk_to_si(ode, measured_quantities) result = _find_identifiable_functions( ode, simplify = simplify, diff --git a/src/local_identifiability.jl b/src/local_identifiability.jl index df3ef4e04..45454ff88 100644 --- a/src/local_identifiability.jl +++ b/src/local_identifiability.jl @@ -212,7 +212,7 @@ end [e for e in ModelingToolkit.states(ode) if !ModelingToolkit.isoutput(e)], ) end - ode, conversion = preprocess_ode(ode, measured_quantities) + ode, conversion = mtk_to_si(ode, measured_quantities) funcs_to_check_ = [eval_at_nemo(x, conversion) for x in funcs_to_check] if isequal(type, :SE)