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

With the default solver, deleteat! deletes too many elements #1056

Open
evan-wehi opened this issue Oct 10, 2024 · 1 comment
Open

With the default solver, deleteat! deletes too many elements #1056

evan-wehi opened this issue Oct 10, 2024 · 1 comment
Assignees
Labels

Comments

@evan-wehi
Copy link

Describe the bug 🐞

A clear and concise description of what the bug is.

delete!(integrator, indxs) should delete only entries at idxs. Instead, delete! is deleting several other entries as well.

A clear and concise description of what you expected to happen.

Only entries at idxs are deleted.

Minimal Reproducible Example 👇

using DifferentialEquations

u0 = collect(range(1.0, 5.0))
test(u, t, integrator) = u[1] - 0.5
function action!(integrator)
  @show integrator.u
  deleteat!(integrator, 2)
  @show integrator.u
end
cb = ContinuousCallback(test, action!)
rhs(du, u, p, t) = du .= -0.1 .* u
prob = ODEProblem(rhs, u0, (0, 100))
solve(prob, callback=cb)

Error & Stacktrace ⚠️

integrator.u = [0.5000000000000004, 1.0000000000000009, 1.5000000000000007, 2.0000000000000018, 2.500000000000002]
integrator.u = [0.5000000000000004]
ERROR: DimensionMismatch: Some axes are not equal, or feature a dynamic broadcast!
Stacktrace:
  [1] _fast_materialize!
    @ ~/.julia/packages/FastBroadcast/wfdTr/src/FastBroadcast.jl:193 [inlined]
  [2] fast_materialize!
    @ ~/.julia/packages/FastBroadcast/wfdTr/src/FastBroadcast.jl:277 [inlined]
  [3] _ode_addsteps!(k::Vector{…}, t::Float64, uprev::Vector{…}, u::Vector{…}, dt::Float64, f::ODEFunction{…}, p::SciMLBase.NullParameters, cache::OrdinaryDiffEqTsit5.Tsit5Cache{…}, always_calc_begin::Bool, allow_calc_end::Bool, force_calc_end::Bool)
    @ OrdinaryDiffEqTsit5 ~/.julia/packages/OrdinaryDiffEqTsit5/DHYtz/src/tsit_perform_step.jl:9
  [4] ode_addsteps!
    @ ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/dense/generic_dense.jl:87 [inlined]
  [5] ode_addsteps!
    @ ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/dense/generic_dense.jl:61 [inlined]
  [6] reeval_internals_due_to_modification!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…}, continuous_modification::Bool)
    @ OrdinaryDiffEqCore ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/integrators/integrator_interface.jl:51
  [7] reeval_internals_due_to_modification!
    @ ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/integrators/integrator_interface.jl:40 [inlined]
  [8] apply_callback!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…}, callback::ContinuousCallback{…}, cb_time::Float64, prev_sign::Float64, event_idx::Int64)
    @ DiffEqBase ~/.julia/packages/DiffEqBase/sCsah/src/callbacks.jl:591
  [9] macro expansion
    @ ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/integrators/integrator_utils.jl:319 [inlined]
 [10] apply_ith_callback!
    @ ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/integrators/integrator_utils.jl:305 [inlined]
 [11] handle_callbacks!
    @ ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/integrators/integrator_utils.jl:344 [inlined]
 [12] _loopfooter!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…})
    @ OrdinaryDiffEqCore ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/integrators/integrator_utils.jl:243
 [13] loopfooter!
    @ ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/integrators/integrator_utils.jl:207 [inlined]
 [14] solve!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…})
    @ OrdinaryDiffEqCore ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/solve.jl:552
 [15] #__solve#62
    @ ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/solve.jl:7 [inlined]
 [16] __solve
    @ ~/.julia/packages/OrdinaryDiffEqCore/3Y2Xj/src/solve.jl:1 [inlined]
 [17] solve_call(_prob::ODEProblem{…}, args::CompositeAlgorithm{…}; merge_callbacks::Bool, kwargshandle::Nothing, kwargs::@Kwargs{})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:612
 [18] solve_call
    @ ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:569 [inlined]
 [19] solve_up(prob::ODEProblem{…}, sensealg::Nothing, u0::Vector{…}, p::SciMLBase.NullParameters, args::CompositeAlgorithm{…}; kwargs::@Kwargs{})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:1080
 [20] solve_up
    @ ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:1066 [inlined]
 [21] #solve#51
    @ ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:1003 [inlined]
 [22] solve
    @ ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:993 [inlined]
 [23] #__solve#3
    @ ~/.julia/packages/OrdinaryDiffEqDefault/2qVWT/src/default_alg.jl:46 [inlined]
 [24] __solve
    @ ~/.julia/packages/OrdinaryDiffEqDefault/2qVWT/src/default_alg.jl:45 [inlined]
 [25] #__solve#72
    @ ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:1394 [inlined]
 [26] __solve
    @ ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:1386 [inlined]
 [27] solve_call(::ODEProblem{…}; merge_callbacks::Bool, kwargshandle::Nothing, kwargs::@Kwargs{})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:612
 [28] solve_up(::ODEProblem{…}, ::Nothing, ::Vector{…}, ::SciMLBase.NullParameters; kwargs::@Kwargs{})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:1072
 [29] solve_up
    @ ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:1066 [inlined]
 [30] solve(::ODEProblem{…}; sensealg::Nothing, u0::Nothing, p::Nothing, wrap::Val{…}, kwargs::@Kwargs{})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/sCsah/src/solve.jl:1003
 [31] top-level scope
    @ ~/PycharmProjects/Odetest/b.jl:13
Some type information was truncated. Use `show(err)` to see complete types.

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
julia> using Pkg; Pkg.status()
Project Odetest v0.1.0
Status `~/PycharmProjects/Odetest/Project.toml`
  [0c46a032] DifferentialEquations v7.14.0
  [961ee093] ModelingToolkit v9.36.0
  [91a5bcdd] Plots v1.40.8
  [d1185830] SymbolicUtils v3.5.0
  [0c5d862f] Symbolics v6.5.0
  • Output of versioninfo()
julia> versioninfo()
Julia Version 1.10.1
Commit 7790d6f0641 (2024-02-13 20:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
Environment:
  JULIA_EDITOR = code

Additional context

If I explicitly specifiy Tsit5() or Rosenbrock23() it works as expected.

Add any other context about the problem here.

@ChrisRackauckas
Copy link
Member

Oh the default solver probably recurses this on the caches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants