-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
remake
doesn't evaluate interdependencies between u0
and p
#672
Comments
Could you give an MWE? We have tests specifically for interdependent |
I'm not sure if this would work on MTK@v8. |
Yes it's only v9 |
Interdependent initialization should work even on v8, but thanks for pointing out that it won't respect defaults on MTKv8 |
Yes, I initially tried |
Try updating your SymbolicIndexingInterface version. It won't start using defaults for MTKv8, but it'll at least not error the same way 😅 |
Here is a simple example that fails, which I think is related to this issue: using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
using DifferentialEquations
@parameters P
@variables x(t) y(t)
sys = complete(ODESystem([D(x) ~ P, D(y) ~ P], t, [x, y], [P]; defaults = [x => P + 1.0], name = :sys))
prob1 = ODEProblem(sys, unknowns(sys) .=> NaN, (0.0, 1.0), parameters(sys) .=> NaN)
prob2 = remake(prob1; u0 = [y => 2.0], p = [P => 1.0], use_defaults = true) # fails It errors with ERROR: MethodError: no method matching getindex(::Nothing, ::Int64)
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/SymbolicUtils/qyMYa/src/code.jl:375 [inlined]
[2] macro expansion
@ ~/.julia/packages/RuntimeGeneratedFunctions/M9ZX8/src/RuntimeGeneratedFunctions.jl:163 [inlined]
[3] macro expansion
@ ./none:0 [inlined]
[4] generated_callfunc
@ ./none:0 [inlined]
[5] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{…})(::Nothing, ::Vector{…}, ::Nothing)
@ RuntimeGeneratedFunctions ~/.julia/packages/RuntimeGeneratedFunctions/M9ZX8/src/RuntimeGeneratedFunctions.jl:150
[6] (::ModelingToolkit.var"#709#722"{…})(u::Nothing, p::ModelingToolkit.MTKParameters{…}, t::Nothing)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/cAhZr/src/systems/diffeqs/abstractodesystem.jl:464
[7] (::SymbolicIndexingInterface.TimeDependentObservedFunction{…})(::SymbolicIndexingInterface.NotTimeseries, prob::SymbolicIndexingInterface.ProblemState{…})
@ SymbolicIndexingInterface ~/.julia/packages/SymbolicIndexingInterface/SzZz3/src/state_indexing.jl:88
[8] (::SymbolicIndexingInterface.TimeDependentObservedFunction{…})(prob::SymbolicIndexingInterface.ProblemState{…})
@ SymbolicIndexingInterface ~/.julia/packages/SymbolicIndexingInterface/SzZz3/src/value_provider_interface.jl:144
[9] (::SciMLBase.var"#667#671"{ODEProblem{…}, SymbolicIndexingInterface.ProblemState{…}})(::Pair{Any, Any})
@ SciMLBase ./none:0
[10] iterate
@ ./generator.jl:47 [inlined]
[11] Dict{Any, Any}(kv::Base.Generator{Dict{…}, SciMLBase.var"#667#671"{…}})
@ Base ./dict.jl:83
[12] anydict(d::Base.Generator{Dict{…}, SciMLBase.var"#667#671"{…}})
@ SciMLBase ~/.julia/packages/SciMLBase/SDjaO/src/remake.jl:385
[13] _updated_u0_p_symmap(prob::ODEProblem{…}, u0::Dict{…}, ::Val{…}, p::ModelingToolkit.MTKParameters{…}, ::Val{…})
@ SciMLBase ~/.julia/packages/SciMLBase/SDjaO/src/remake.jl:479
[14] _updated_u0_p_symmap(prob::ODEProblem{…}, u0::Dict{…}, ::Val{…}, p::Dict{…}, ::Val{…})
@ SciMLBase ~/.julia/packages/SciMLBase/SDjaO/src/remake.jl:517
[15] _updated_u0_p_internal(prob::ODEProblem{…}, u0::Vector{…}, p::Vector{…}; interpret_symbolicmap::Bool, use_defaults::Bool)
@ SciMLBase ~/.julia/packages/SciMLBase/SDjaO/src/remake.jl:427
[16] _updated_u0_p_internal
@ ~/.julia/packages/SciMLBase/SDjaO/src/remake.jl:412 [inlined]
[17] #updated_u0_p#688
@ ~/.julia/packages/SciMLBase/SDjaO/src/remake.jl:548 [inlined]
[18] updated_u0_p
@ ~/.julia/packages/SciMLBase/SDjaO/src/remake.jl:529 [inlined]
[19] remake(prob::ODEProblem{…}; f::Missing, u0::Vector{…}, tspan::Missing, p::Vector{…}, kwargs::Missing, interpret_symbolicmap::Bool, use_defaults::Bool, _kwargs::@Kwargs{})
@ SciMLBase ~/.julia/packages/SciMLBase/SDjaO/src/remake.jl:95 It seems to me like This is with the latest
|
Made a comment about this in
Catalyst.jl
:"Was just about to make an issue related to this, it's a particular problem when using
remake
to update the initial conditions of anODEProblem(rs, ...; remove_conserved = true)
.SciMLBase.remake
function here:ispdep
check doesn't find that Γ in the parameters is a symbolic type, because it is evaluated to numerical values in the ODEProblem. The only place where the symbolic expressions for Γ are exposed are indefaults
field of theODESystem
.varmap = merge(u0, p)
line.symbolic_evaluate
prior to callingremake
using the symbolic expressions from the defaults map:I can make a separate issue for this in this repo (not sure if it pertains most here, or
ModelingToolkit.jl
orSciMLBase.jl
) if this is truly a problem and I'm not missing anything."Originally posted by @jonathanfischer97 in SciML/Catalyst.jl#806 (comment)
I should mention that I'm using
ModelingToolkit.jl
version 8.75 rather than 9.0, due to compat withCatalyst.jl
, if that makes a difference.The text was updated successfully, but these errors were encountered: