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

Cannot change parameter and pass parameters to model #93

Open
TS-CUBED opened this issue Sep 1, 2022 · 6 comments
Open

Cannot change parameter and pass parameters to model #93

TS-CUBED opened this issue Sep 1, 2022 · 6 comments

Comments

@TS-CUBED
Copy link

TS-CUBED commented Sep 1, 2022

I am trying to change the parameter in a cellML model, but the method in the Readme/Tutorial does not work anymore.

Steps to reproduce:

  1. Download beeler_reuter_1977.cellml.xml.
  2. Setup as in tutorial and try to change the parameter:
ml = CellModel("models/beeler_reuter_1977.cellml.xml")

p = list_params(ml)
update_list!(p, :stimulus_protocol₊IstimPeriod, 250.0)
prob = ODEProblem(ml, (0, 10000); p=p)

Error occurs:

ERROR: MethodError: no method matching float(::Type{Any})
Closest candidates are:
  float(::Type{Union{Missing, T}}) where T at missing.jl:112
  float(::Any) at float.jl:269
  float(::Union{StatsBase.PValue, StatsBase.TestStat}) at ~/.julia/packages/StatsBase/XgjIN/src/statmodels.jl:86
  ...
Stacktrace:
 [1] float(#unused#::Type{Any})
   @ Base ./missing.jl:113
 [2] promote_to_concrete(vs::Vector{Any}; tofloat::Bool, use_union::Bool)
   @ ModelingToolkit ~/.julia/packages/ModelingToolkit/5qzZn/src/utils.jl:601
 [3] varmap_to_vars(varmap::Vector{Any}, varlist::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}; defaults::Dict{Any, Any}, check::Bool, toterm::Function, promotetoconcrete::Nothing, tofloat::Bool, use_union::Bool)
   @ ModelingToolkit ~/.julia/packages/ModelingToolkit/5qzZn/src/variables.jl:69
 [4] process_DEProblem(constructor::Type, sys::ODESystem, u0map::Vector{Float64}, parammap::Vector{Any}; implicit_dae::Bool, du0map::Nothing, version::Nothing, tgrad::Bool, jac::Bool, checkbounds::Bool, sparse::Bool, simplify::Bool, linenumbers::Bool, parallel::Symbolics.SerialForm, eval_expression::Bool, use_union::Bool, kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol, Symbol}, NamedTuple{(:has_difference, :check_length), Tuple{Bool, Bool}}})
   @ ModelingToolkit ~/.julia/packages/ModelingToolkit/5qzZn/src/systems/diffeqs/abstractodesystem.jl:544
 [5] (ODEProblem{true})(sys::ODESystem, u0map::Vector{Float64}, tspan::Tuple{Int64, Float64}, parammap::Vector{Any}; callback::Nothing, check_length::Bool, kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:jac,), Tuple{Bool}}})
   @ ModelingToolkit ~/.julia/packages/ModelingToolkit/5qzZn/src/systems/diffeqs/abstractodesystem.jl:637
 [6] #ODEProblem#487
   @ ~/.julia/packages/ModelingToolkit/5qzZn/src/systems/diffeqs/abstractodesystem.jl:629 [inlined]
 [7] ODEProblem(ml::CellModel, tspan::Tuple{Int64, Float64}; jac::Bool, level::Int64, p::Vector{Any}, u0::Vector{Float64})
   @ CellMLToolkit ~/.julia/packages/CellMLToolkit/Pnsff/src/CellMLToolkit.jl:49
 [8] top-level scope
   @ ~/.julia/dev/CirculationModels/cases/ShiModel/Shi.jl:147

Note: That top-level scope is just the actual model I am working on. But the error occurs on the model from the tutorial as well.

Versions:
Julia 1.8.0
[03cb29e0] CellMLToolkit v2.7.1

@ChrisRackauckas
Copy link
Member

p = list_params(ml)
update_list!(p, :stimulus_protocol₊IstimPeriod, 250.0)

What are these? I think it should just use the normal MTK way of doing these things.

@TS-CUBED
Copy link
Author

TS-CUBED commented Sep 6, 2022

That code snippet is from the example in the Readme.md on this repo (CellMLToolkit). It's a bit further down on the page in the Beeler et al. case.

This issue is kind of linked to: SciML/ModelingToolkit.jl#1810

@ChrisRackauckas
Copy link
Member

Ahh yeah, we should finish the remake dispatch improvements and just delete that weird stuff from the README

@TS-CUBED
Copy link
Author

TS-CUBED commented Sep 7, 2022

A CellML model is a good example for the problem I mean in that. Since all the parameters are set in the model already, it would be a major pain to have to create the whole parameter map (which in some of them can be 1000s) if I only want to change 10.

A remake that takes a partial parameter map would be a(nother) killer feature in that application.

@ChrisRackauckas
Copy link
Member

Definitely agreed. It's in the plan, just needs hands.

@termi-official
Copy link

Sorry to bother here, but ODEProblem with CellModel expects a vector with the parameters and not the vector with the maps: prob = ODEProblem(ml, (0, 10000); p=last.(p)) "solves" this.

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

3 participants