You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling componentwise_vectors_timepoint on an Ensemble Solution of an ODEProblem, if the timepoints provided are given as a SVector, it raises a LoadError due to attempting to use setindex! on the SVector.
Expected behavior
componentwise_vectors_timepoint should return the interpolated solution, as an SVector. Note that this is the behavior that occurs if the Ensemble is from an SDEProblem.
Minimal Reproducible Example 👇
using StaticArrays
using DifferentialEquations
using DifferentialEquations.EnsembleAnalysis
SDEprob =SDEProblem((u, p, t) ->1.01u, (u, p, t) ->1.01u, 0.5, (0.0, 1.0))
SDEensemble_prob =EnsembleProblem(SDEprob)
prob =ODEProblem((u, p, t) ->1.01u, 0.5, (0.0, 1.0))
ensemble_prob =EnsembleProblem(prob)
SDEysim =solve(SDEensemble_prob, SOSRI(), trajectories =1)
ysim =solve(ensemble_prob, Tsit5(), trajectories =1)
t =SVector{11}(0:0.1:1) # t values we want to interpolate to, converted to SVectorcomponentwise_vectors_timepoint(SDEysim, t)[1] # Returns the interpolated u as an SVectorcomponentwise_vectors_timepoint(ysim, t)[1] # MethodError due to using setindex! on t
Error & Stacktrace ⚠️
The SDE timepoint interpolation returns the following:
t:11-element SVector{11, Float64} with indices SOneTo(11):0.00.10.20.30.40.50.60.70.80.91.0
u:11-element SVector{11, Float64} with indices SOneTo(11):0.50.55461095946983830.83215740723689570.69655336779642210.65592931243119550.49413145842801770.46580997364866560.323440109043938830.289644057207501470.314721257947733760.2209161971944798
The error that results from the ODE interpolation is the following:
ERROR: LoadError:setindex!(::SVector{11, Float64}, value, ::Int) is not defined.
Hint: Use `MArray` or `SizedArray` to create a mutable static array
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] setindex!(a::SVector{11, Float64}, value::Float64, i::Int64)
@ StaticArrays ~/.julia/packages/StaticArrays/9Yt0H/src/indexing.jl:3
[3] macro expansion
@ ~/.julia/packages/StaticArrays/9Yt0H/src/indexing.jl:199 [inlined]
[4] _setindex!
@ ~/.julia/packages/StaticArrays/9Yt0H/src/indexing.jl:192 [inlined]
[5] setindex!
@ ~/.julia/packages/StaticArrays/9Yt0H/src/indexing.jl:167 [inlined]
[6] invpermute!(v::SVector{11, Float64}, p::SVector{11, Int64})
@ Base ./combinatorics.jl:237
[7] ode_interpolation(tvals::SVector{…}, id::OrdinaryDiffEqCore.InterpolationData{…}, idxs::Nothing, deriv::Type{…}, p::SciMLBase.NullParameters, continuity::Symbol)
@ OrdinaryDiffEqCore ~/.julia/packages/OrdinaryDiffEqCore/NnA60/src/dense/generic_dense.jl:574
[8] (::OrdinaryDiffEqCore.InterpolationData{…})(tvals::SVector{…}, idxs::Nothing, deriv::Type, p::SciMLBase.NullParameters, continuity::Symbol)
@ OrdinaryDiffEqCore ~/.julia/packages/OrdinaryDiffEqCore/NnA60/src/interp_func.jl:46
[9] (::ODESolution{…})(t::SVector{…}, ::Type{…}, idxs::Nothing, continuity::Symbol)
@ SciMLBase ~/.julia/packages/SciMLBase/fqdZV/src/solutions/ode_solutions.jl:242
[10] (::ODESolution{…})(t::SVector{…}, ::Type{…}; idxs::Nothing, continuity::Symbol)
@ SciMLBase ~/.julia/packages/SciMLBase/fqdZV/src/solutions/ode_solutions.jl:224
[11] (::ODESolution{Float64, 1, Vector{…}, Nothing, Nothing, Vector{…}, Vector{…}, Nothing, ODEProblem{…}, Tsit5{…}, OrdinaryDiffEqCore.InterpolationData{…}, SciMLBase.DEStats, Nothing, Nothing, Nothing, Nothing})(t::SVector{11, Float64}, ::Type{Val{…}})
@ SciMLBase ~/.julia/packages/SciMLBase/fqdZV/src/solutions/ode_solutions.jl:219
[12] (::SciMLBase.EnsembleAnalysis.var"#3#4"{…})(sol::ODESolution{…})
@ SciMLBase.EnsembleAnalysis ./none:0
[13] iterate
@ ./generator.jl:48 [inlined]
[14] componentwise_vectors_timepoint(sim::EnsembleSolution{Float64, 2, Vector{ODESolution{…}}}, t::SVector{11, Float64})
@ SciMLBase.EnsembleAnalysis ~/.julia/packages/SciMLBase/fqdZV/src/ensemble/ensemble_analysis.jl:17
[15] top-level scope
@ ./toyensemble.jl:18
[16] include(fname::String)
@ Main ./sysimg.jl:38
[17] top-level scope
@ REPL[3]:1
in expression starting at ./toyensemble.jl:18
Some type information was truncated. Use `show(err)` to see complete types.
Environment (please complete the following information):
I ran this code in a temporary environment on julia 1.11.1.
Output of using Pkg; Pkg.status()
Status `/tmp/jl_Nz9Lu1/Project.toml`
[0c46a032] DifferentialEquations v7.14.0
[90137ffa] StaticArrays v1.9.8
Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Describe the bug 🐞
When calling
componentwise_vectors_timepoint
on an Ensemble Solution of an ODEProblem, if the timepoints provided are given as a SVector, it raises a LoadError due to attempting to usesetindex!
on the SVector.Expected behavior
componentwise_vectors_timepoint
should return the interpolated solution, as an SVector. Note that this is the behavior that occurs if the Ensemble is from an SDEProblem.Minimal Reproducible Example 👇
Error & Stacktrace⚠️
The SDE timepoint interpolation returns the following:
The error that results from the ODE interpolation is the following:
Environment (please complete the following information):
I ran this code in a temporary environment on julia 1.11.1.
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
I originally posted about this issue here, but the context isn't particularly important.
The text was updated successfully, but these errors were encountered: