-
-
Notifications
You must be signed in to change notification settings - Fork 209
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 is broken with Bool parameters #2866
Labels
bug
Something isn't working
Comments
Can you post a reproducer? |
I think I have the same issue? prob = ODEProblem(model2, [y_input => y_inputs_0], (0.0, 12.0), []);
prob2 = remake(prob; p=[y_input => y_inputs_0]) should work, right? But on the second line, I'm hitting the MWE: using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
using DifferentialEquations: solve, remake
using DataInterpolations
using Symbolics, Test
const ConstantFun = typeof(ConstantInterpolation([10.0, 12, 13], [0, 6, 12]))
y_inputs_0 = ConstantInterpolation([10.0, 12, 13], [0, 6, 12])
eval_interpolation(interp, t) = interp(t)
@register_symbolic eval_interpolation(interp::ConstantFun, t)
@variables y(t)
@parameters y_input::ConstantFun
eqs = [y ~ eval_interpolation(y_input, t)]
@named model = ODESystem(eqs, t)
model2 = structural_simplify(model)
prob = ODEProblem(model2, [y_input => y_inputs_0], (0.0, 12.0), []);
prob2 = remake(prob; p=[y_input => y_inputs_0]) yields MethodError: no method matching narrow_buffer_type_and_fallback_undefs(::StaticArraysCore.SizedVector{0, Float64, Vector{Float64}}, ::Vector{Any})
Closest candidates are:
narrow_buffer_type_and_fallback_undefs(!Matched::Vector, ::Vector)
@ ModelingToolkit C:\Users\a1058035\.julia\packages\ModelingToolkit\GJiqn\src\systems\parameter_buffer.jl:485
Stack trace
Here is what happened, the most recent locations are first:
macro expansion @ sugar.jl:197
remake_buffer(indp::SciMLBase.ODEProblem{Nothing, Tuple{Float64, Float64}, true, ModelingToolkit.MTKParameters{StaticArraysCore.SizedVector{0, Float64, Vector{Float64}}, StaticArraysCore.SizedVector{0, Any, Vector{Any}}, Tuple{}, Tuple{}, Tuple{Vector{DataInterpolations.ConstantInterpolation{ReadOnlyArrays.ReadOnlyVector{Float64, Vector{Float64}}, ReadOnlyArrays.ReadOnlyVector{Int64, Vector{Int64}}, Vector{Float64}, Float64}}}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x33b3bda3, 0xd089b82e, 0xfedcd84c, 0x4037599c, 0x2848c6f6), Nothing}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1,), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb8b89fef, 0x1b0590a0, 0x8801a652, 0xfeb6172b, 0xb8db857d), Nothing}}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, ModelingToolkit.var"#f#781"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xf484e4ce, 0x5b83a833, 0x33551c77, 0x7c352bb5, 0xdac54478), Nothing}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x3c38bd43, 0x235c9731, 0xcd5da351, 0xf995747b, 0x31daffa0), Nothing}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, ModelingToolkit.ObservedFunctionCache{ModelingToolkit.ODESystem}, Nothing, ModelingToolkit.ODESystem, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, oldbuf::ModelingToolkit.MTKParameters{StaticArraysCore.SizedVector{0, Float64, Vector{Float64}}, StaticArraysCore.SizedVector{0, Any, Vector{Any}}, Tuple{}, Tuple{}, Tuple{Vector{DataInterpolations.ConstantInterpolation{ReadOnlyArrays.ReadOnlyVector{Float64, Vector{Float64}}, ReadOnlyArrays.ReadOnlyVector{Int64, Vector{Int64}}, Vector{Float64}, Float64}}}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x33b3bda3, 0xd089b82e, 0xfedcd84c, 0x4037599c, 0x2848c6f6), Nothing}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1,), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb8b89fef, 0x1b0590a0, 0x8801a652, 0xfeb6172b, 0xb8db857d), Nothing}}, vals::Dict{Any, Any}) @ parameter_buffer.jl:602
_updated_u0_p_symmap(prob::SciMLBase.ODEProblem{Nothing, Tuple{Float64, Float64}, true, ModelingToolkit.MTKParameters{StaticArraysCore.SizedVector{0, Float64, Vector{Float64}}, StaticArraysCore.SizedVector{0, Any, Vector{Any}}, Tuple{}, Tuple{}, Tuple{Vector{DataInterpolations.ConstantInterpolation{ReadOnlyArrays.ReadOnlyVector{Float64, Vector{Float64}}, ReadOnlyArrays.ReadOnlyVector{Int64, Vector{Int64}}, Vector{Float64}, Float64}}}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x33b3bda3, 0xd089b82e, 0xfedcd84c, 0x4037599c, 0x2848c6f6), Nothing}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1,), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb8b89fef, 0x1b0590a0, 0x8801a652, 0xfeb6172b, 0xb8db857d), Nothing}}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, ModelingToolkit.var"#f#781"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xf484e4ce, 0x5b83a833, 0x33551c77, 0x7c352bb5, 0xdac54478), Nothing}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x3c38bd43, 0x235c9731, 0xcd5da351, 0xf995747b, 0x31daffa0), Nothing}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, ModelingToolkit.ObservedFunctionCache{ModelingToolkit.ODESystem}, Nothing, ModelingToolkit.ODESystem, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, u0::Nothing, ::Val{false}, p::Dict{Any, Any}, ::Val{true}) @ remake.jl:603
_updated_u0_p_internal(prob::SciMLBase.ODEProblem{Nothing, Tuple{Float64, Float64}, true, ModelingToolkit.MTKParameters{StaticArraysCore.SizedVector{0, Float64, Vector{Float64}}, StaticArraysCore.SizedVector{0, Any, Vector{Any}}, Tuple{}, Tuple{}, Tuple{Vector{DataInterpolations.ConstantInterpolation{ReadOnlyArrays.ReadOnlyVector{Float64, Vector{Float64}}, ReadOnlyArrays.ReadOnlyVector{Int64, Vector{Int64}}, Vector{Float64}, Float64}}}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x33b3bda3, 0xd089b82e, 0xfedcd84c, 0x4037599c, 0x2848c6f6), Nothing}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1,), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb8b89fef, 0x1b0590a0, 0x8801a652, 0xfeb6172b, 0xb8db857d), Nothing}}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, ModelingToolkit.var"#f#781"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xf484e4ce, 0x5b83a833, 0x33551c77, 0x7c352bb5, 0xdac54478), Nothing}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x3c38bd43, 0x235c9731, 0xcd5da351, 0xf995747b, 0x31daffa0), Nothing}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, ModelingToolkit.ObservedFunctionCache{ModelingToolkit.ODESystem}, Nothing, ModelingToolkit.ODESystem, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, ::Missing, p::Vector{Pair{SymbolicUtils.BasicSymbolic{DataInterpolations.ConstantInterpolation{ReadOnlyArrays.ReadOnlyVector{Float64, Vector{Float64}}, ReadOnlyArrays.ReadOnlyVector{Int64, Vector{Int64}}, Vector{Float64}, Float64}}, DataInterpolations.ConstantInterpolation{ReadOnlyArrays.ReadOnlyVector{Float64, Vector{Float64}}, ReadOnlyArrays.ReadOnlyVector{Int64, Vector{Int64}}, Vector{Float64}, Float64}}}; interpret_symbolicmap::Bool, use_defaults::Bool) @ remake.jl:513
_updated_u0_p_internal @ remake.jl:502
#updated_u0_p#713 @ remake.jl:665
updated_u0_p @ remake.jl:646
#remake#676 @ remake.jl:121
remake @ remake.jl:109 |
@cstjean your MWE works on the latest MTK/SciMLBase. @acertain since you didn't provide an MWE, I ran the following: julia> @variables x(t)
julia> @parameters p::Bool q::Bool r
julia> @mtkbuild sys = ODESystem(D(x) ~ x + r, t, [x], [p,q,r])
julia> prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [p => true, q => false, r => 1.0])
julia> prob.p # contains a `BitVector`
MTKParameters{Vector{Float64}, Tuple{}, Tuple{BitVector}, Tuple{}}([1.0], (), (Bool[1, 0],), ())
julia> prob2 = remake(prob, p = [q => true])
julia> prob2.p # still contains a `BitVector` and has updated values
MTKParameters{Vector{Float64}, Tuple{}, Tuple{Vector{Bool}}, Tuple{}}([1.0], (), (Bool[1, 1],), ()) Which also works. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this is just an issue with the type of narrow_buffer_type_and_fallback_undefs, replacing
oldbuf::Vector
witholdbuf
seems to fix itStacktrace:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: