Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output from preprocess_ode generates erro when given to e.g. assess_identifiability #231

Closed
TorkelE opened this issue Nov 6, 2023 · 2 comments

Comments

@TorkelE
Copy link
Member

TorkelE commented Nov 6, 2023

Minimal example:

# Fetch packages.
using ModelingToolkit, StructuralIdentifiability

# Create model
@parameters p1 p2
@variables t x1(t) x2(t) y(t)
D = Differential(t)
eqs = [D(x1) ~ p1* x2 - x1,
       D(x2) ~ p2 - p1* x2]
@named osys = ODESystem(eqs)

# Create StructuralIdentifiability ODE.
known_parameter = [p1]
measured_quantities = [y ~ x1]
si_ode_1 = preprocess_ode(osys, known_parameter)
si_ode_2 = preprocess_ode(osys, measured_quantities)

assess_identifiability(si_ode_1)
assess_identifiability(si_ode_2)
assess_local_identifiability(si_ode_1)
assess_local_identifiability(si_ode_2)

All the ones at the end give errors like:

ERROR: MethodError: no method matching assess_local_identifiability(::Tuple{ODE{Nemo.QQMPolyRingElem}, Dict{SymbolicUtils.BasicSymbolic{Real}, Nemo.QQMPolyRingElem}})

Closest candidates are:
  assess_local_identifiability(::ODE{P}; funcs_to_check, p, type, trbasis) where P<:AbstractAlgebra.MPolyRingElem{Nemo.QQFieldElem}
   @ StructuralIdentifiability ~/.julia/packages/StructuralIdentifiability/JIDUk/src/local_identifiability.jl:231
  assess_local_identifiability(::ODESystem; measured_quantities, funcs_to_check, p, type)
   @ StructuralIdentifiability ~/.julia/packages/StructuralIdentifiability/JIDUk/src/local_identifiability.jl:166
  assess_local_identifiability(::DiscreteSystem; measured_quantities, funcs_to_check, known_ic, p)
   @ StructuralIdentifiability ~/.julia/packages/StructuralIdentifiability/JIDUk/src/discrete.jl:308

Stacktrace:
 [1] top-level scope
   @ ~/Desktop/Julia Playground/StructuralIdentifiabiltiyExtension tests/playground.jl:21
@pogudingleb
Copy link
Collaborator

The reason is that preprocess_ode returns not only ODE object but also a dictionary to do conversion between the variables in the ODE object and the symbols from ModelingToolit (this is also mentioned in the docstring, perhaps I should have emphasized this).

So, to make this code work, one should just insert , _ at a couple of places:

# Fetch packages.
using ModelingToolkit, StructuralIdentifiability

# Create model
@parameters p1 p2
@variables t x1(t) x2(t) y(t)
D = Differential(t)
eqs = [D(x1) ~ p1* x2 - x1,
       D(x2) ~ p2 - p1* x2]
@named osys = ODESystem(eqs)

# Create StructuralIdentifiability ODE.
known_parameter = [p1]
measured_quantities = [y ~ x1]
si_ode_1, _ = preprocess_ode(osys, known_parameter)
si_ode_2, _ = preprocess_ode(osys, measured_quantities)

assess_identifiability(si_ode_1)
assess_identifiability(si_ode_2)
assess_local_identifiability(si_ode_1)
assess_local_identifiability(si_ode_2)

@TorkelE
Copy link
Member Author

TorkelE commented Nov 6, 2023

Thanks a lot! Yes, I should have checked the doc string properly, that's on me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants