From dab25d5639d4ecfbf87a8bd1df201167a975dbb4 Mon Sep 17 00:00:00 2001 From: pogudingleb Date: Sun, 4 Feb 2024 23:51:38 +0100 Subject: [PATCH] fixing the tests --- src/known_ic.jl | 32 ++++++++++++++++---------------- src/util.jl | 17 ----------------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/src/known_ic.jl b/src/known_ic.jl index 7dbaca06f..c5874cd37 100644 --- a/src/known_ic.jl +++ b/src/known_ic.jl @@ -16,7 +16,7 @@ This functions takes the following optional arguments: - `:strong`: Strong simplification. This option is the slowest, but the output functions are nice and simple. - `:absent`: No simplification. -- `p`: A float in the range from 0 to 1, the probability of correctness. Default +- `prob_threshold`: A float in the range from 0 to 1, the probability of correctness. Default is `0.99`. - `seed`: The rng seed. Default value is `42`. - `loglevel` - the minimal level of log messages to display (`Logging.Info` by default) @@ -29,7 +29,7 @@ This functions takes the following optional arguments: function find_identifiable_functions_kic( ode::ODE{T}, known_ic::Vector{<:Union{T, Generic.Frac{T}}}; - p::Float64 = 0.99, + prob_threshold::Float64 = 0.99, seed = 42, simplify = :standard, rational_interpolator = :VanDerHoevenLecerf, @@ -41,7 +41,7 @@ function find_identifiable_functions_kic( return _find_identifiable_functions_kic( ode, known_ic, - p = p, + prob_threshold = prob_threshold, seed = seed, simplify = simplify, rational_interpolator = rational_interpolator, @@ -52,18 +52,18 @@ end function _find_identifiable_functions_kic( ode::ODE{T}, known_ic::Vector{<:Union{T, Generic.Frac{T}}}; - p::Float64 = 0.99, + prob_threshold::Float64 = 0.99, seed = 42, simplify = :standard, rational_interpolator = :VanDerHoevenLecerf, ) where {T <: MPolyElem{fmpq}} Random.seed!(seed) @assert simplify in (:standard, :weak, :strong, :absent) - half_p = 0.5 + p / 2 + half_p = 0.5 + prob_threshold / 2 runtime_start = time_ns() id_funcs_general = find_identifiable_functions( ode, - p = half_p, + prob_threshold = half_p, with_states = true, simplify = simplify, rational_interpolator = rational_interpolator, @@ -74,7 +74,7 @@ function _find_identifiable_functions_kic( RationalFunctionField( vcat(id_funcs_general, [f // one(parent(ode)) for f in known_ic]), ), - p = half_p, + prob_threshold = half_p, seed = seed, simplify = simplify, rational_interpolator = rational_interpolator, @@ -86,18 +86,18 @@ function _find_identifiable_functions_kic( end """ - assess_identifiability_kic(ode, known_ic; funcs_to_check = [], p=0.99, loglevel=Logging.Info) + assess_identifiability_kic(ode, known_ic; funcs_to_check = [], prob_threshold=0.99, loglevel=Logging.Info) Input: - `ode` - the ODE model - `known_ic` - a list of functions for which initial conditions are assumed to be known and generic - `funcs_to_check` - list of functions to check identifiability for; if empty, all parameters and states are taken -- `p` - probability of correctness. +- `prob_threshold` - probability of correctness. - `loglevel` - the minimal level of log messages to display (`Logging.Info` by default) Assesses identifiability of parameters and initial conditions of a given ODE model. -The result is guaranteed to be correct with the probability at least `p`. +The result is guaranteed to be correct with the probability at least `prob_threshold`. The function returns an (ordered) dictionary from the functions to check to their identifiability properties (one of `:nonidentifiable`, `:locally`, `:globally`). """ @@ -105,7 +105,7 @@ function assess_identifiability_kic( ode::ODE{P}, known_ic::Vector{<:Union{P, Generic.Frac{P}}}; funcs_to_check = Vector(), - p::Float64 = 0.99, + prob_threshold::Float64 = 0.99, loglevel = Logging.Info, ) where {P <: MPolyElem{fmpq}} restart_logging(loglevel = loglevel) @@ -114,7 +114,7 @@ function assess_identifiability_kic( return _assess_identifiability_kic( ode, known_ic, - p = p, + prob_threshold = prob_threshold, funcs_to_check = funcs_to_check, ) end @@ -124,18 +124,18 @@ function _assess_identifiability_kic( ode::ODE{P}, known_ic::Vector{<:Union{P, Generic.Frac{P}}}; funcs_to_check = Vector(), - p::Float64 = 0.99, + prob_threshold::Float64 = 0.99, ) where {P <: MPolyElem{fmpq}} runtime_start = time_ns() if length(funcs_to_check) == 0 funcs_to_check = vcat(ode.x_vars, ode.parameters) end - half_p = 0.5 + p / 2 - id_funcs = _find_identifiable_functions_kic(ode, known_ic, p = half_p) + half_p = 0.5 + prob_threshold / 2 + id_funcs = _find_identifiable_functions_kic(ode, known_ic, prob_threshold = half_p) funcs_to_check = replace_with_ic(ode, funcs_to_check) result = OrderedDict(f => :globally for f in funcs_to_check) - half_p = 0.5 + p / 2 + half_p = 0.5 + half_p / 2 local_result = check_algebraicity( RationalFunctionField([[denominator(f), numerator(f)] for f in id_funcs]), [f // one(parent(f)) for f in funcs_to_check], diff --git a/src/util.jl b/src/util.jl index c85533365..d68a59628 100644 --- a/src/util.jl +++ b/src/util.jl @@ -518,22 +518,6 @@ function difforder(diffpoly::MPolyRingElem, prefix::String) return max(orders...) end -function get_measured_quantities(ode::ModelingToolkit.ODESystem) - if any(ModelingToolkit.isoutput(eq.lhs) for eq in ModelingToolkit.equations(ode)) - @info "Measured quantities are not provided, trying to find the outputs in input ODE." - return filter( - eq -> (ModelingToolkit.isoutput(eq.lhs)), - ModelingToolkit.equations(ode), - ) - else - throw( - error( - "Measured quantities (output functions) were not provided and no outputs were found.", - ), - ) - end -end - # ----------------------------------------------------------------------------- """ @@ -557,4 +541,3 @@ function replace_with_ic(ode, funcs) Dict(str_to_var(p[1], ode.poly_ring) => str_to_var(p[2], R0) for p in varnames) return [eval_at_dict(f, eval_dict) for f in funcs] end -