Skip to content

Fix MIRK constrained interpolation without controls#534

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-mirk-constrained-interpolation-533
Jul 8, 2026
Merged

Fix MIRK constrained interpolation without controls#534
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-mirk-constrained-interpolation-533

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

This PR should be ignored until reviewed by @ChrisRackauckas.

Summary

  • Distinguish true control-variable BVPs from constrained pure-state BVPs in MIRK interpolation.
  • Keep linear interpolation only for solution entries beyond f_prototype, instead of treating every non-nothing f_prototype as controls.
  • Add a regression test for the issue Interpolation bug in MIRK4 solutions to constrained BVP #533 constrained MIRK4 + Ipopt interpolation case with no cost function.

Verification

  • Reproduced issue Interpolation bug in MIRK4 solutions to constrained BVP #533 locally on current master: solve returned Success, then sol(0.5) threw ArgumentError: range must be non-empty from BoundaryValueDiffEqMIRK/src/interpolation.jl:116.
  • Ran the patched MRE in a temporary Julia environment developing this checkout: solve returned Success; sol(0.5) = [0.4434094419864602, -0.9595173756818917].
  • Ran Runic.jl formatting on the two touched files via a temporary local environment.
  • Ran git diff --check: passed.
  • Ran timeout 3600 julia --project=lib/BoundaryValueDiffEqMIRK -e 'using Pkg; Pkg.test()': failed/timed out after one hour. Before timeout, existing MIRK basic tests reported MethodError: no method matching Float64(::ForwardDiff.Dual...) in Swirling Flow III, Test interpolant evaluation with big defect, and Test maxsol and minsol; then the suite continued through many Ipopt solves until timeout. A separate agent is investigating whether that reproduces on clean master.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas ChrisRackauckas marked this pull request as ready for review July 8, 2026 12:21
@ChrisRackauckas ChrisRackauckas merged commit 36e9daa into SciML:master Jul 8, 2026
24 of 33 checks passed
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1.11)

Time benchmarks
master 867eaa8... master / 867eaa8...
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK2() 0.581 ± 0.0098 s 0.573 ± 0.01 s 1.01 ± 0.025
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK3() 12.1 ± 0.15 ms 12 ± 0.19 ms 1.01 ± 0.021
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK4() 2.66 ± 0.063 ms 2.63 ± 0.078 ms 1.01 ± 0.038
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK5() 3.23 ± 0.11 ms 3.16 ± 0.098 ms 1.02 ± 0.046
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK6() 1.55 ± 0.044 ms 1.54 ± 0.047 ms 1.01 ± 0.042
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = false) 1.49 ± 0.071 ms 1.49 ± 0.062 ms 1 ± 0.064
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = true) 3.2 ± 0.15 ms 3.14 ± 0.21 ms 1.02 ± 0.083
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.0405 ± 0.0032 s 0.0387 ± 0.0028 s 1.05 ± 0.11
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.0611 ± 0.0017 s 0.0587 ± 0.0015 s 1.04 ± 0.04
Simple Pendulum/IIP/Shooting(Tsit5()) 0.173 ± 0.072 ms 0.174 ± 0.072 ms 0.996 ± 0.58
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK2() 2.23 ± 0.013 s 0.715 ± 0.0046 s 3.12 ± 0.027
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK3() 31.3 ± 5.1 ms 15.4 ± 4.8 ms 2.03 ± 0.71
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK4() 4.79 ± 0.14 ms 3.19 ± 0.12 ms 1.5 ± 0.069
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK5() 5.74 ± 0.21 ms 3.79 ± 0.18 ms 1.52 ± 0.09
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK6() 2.46 ± 0.1 ms 1.83 ± 0.093 ms 1.34 ± 0.089
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = false) 3.28 ± 0.78 ms 3.2 ± 0.33 ms 1.02 ± 0.27
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = true) 6.44 ± 5.4 ms 6.51 ± 5.4 ms 0.988 ± 1.2
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.091 ± 0.0039 s 0.0813 ± 0.0027 s 1.12 ± 0.061
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.135 ± 0.0054 s 0.125 ± 0.0027 s 1.08 ± 0.049
Simple Pendulum/OOP/Shooting(Tsit5()) 0.596 ± 0.032 ms 0.597 ± 0.039 ms 0.998 ± 0.085
time_to_load 7.07 ± 0.038 s 7.04 ± 0.013 s 1 ± 0.0056
Memory benchmarks
master 867eaa8... master / 867eaa8...
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK2() 0.389 M allocs: 0.0443 GB 0.389 M allocs: 0.0443 GB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK3() 0.0436 M allocs: 4.88 MB 0.0436 M allocs: 4.88 MB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK4() 15.7 k allocs: 1.65 MB 15.7 k allocs: 1.65 MB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK5() 22.1 k allocs: 2.03 MB 22.1 k allocs: 2.03 MB 1
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK6() 12.8 k allocs: 1.05 MB 12.8 k allocs: 1.05 MB 1
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = false) 25.5 k allocs: 1.82 MB 25.5 k allocs: 1.82 MB 1
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = true) 0.0491 M allocs: 3.39 MB 0.0491 M allocs: 3.39 MB 1
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.553 M allocs: 0.0535 GB 0.553 M allocs: 0.0535 GB 1
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.833 M allocs: 0.0778 GB 0.833 M allocs: 0.0778 GB 1
Simple Pendulum/IIP/Shooting(Tsit5()) 4.63 k allocs: 0.224 MB 4.63 k allocs: 0.224 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK2() 0.89 M allocs: 0.984 GB 0.89 M allocs: 0.984 GB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK3() 0.0932 M allocs: 24.8 MB 0.0932 M allocs: 24.8 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK4() 0.0324 M allocs: 3.96 MB 0.0324 M allocs: 3.96 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK5() 0.045 M allocs: 4.99 MB 0.045 M allocs: 4.99 MB 1
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK6() 25.3 k allocs: 2.17 MB 25.3 k allocs: 2.17 MB 1
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = false) 0.142 M allocs: 10.2 MB 0.142 M allocs: 10.2 MB 1
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = true) 0.266 M allocs: 18.7 MB 0.266 M allocs: 18.7 MB 1
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = false) 2.52 M allocs: 0.279 GB 2.52 M allocs: 0.279 GB 1
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = true) 3.82 M allocs: 0.404 GB 3.82 M allocs: 0.404 GB 1
Simple Pendulum/OOP/Shooting(Tsit5()) 0.0373 M allocs: 1.69 MB 0.0373 M allocs: 1.69 MB 1
time_to_load 0.159 k allocs: 11.2 kB 0.159 k allocs: 11.2 kB 1

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

Successfully merging this pull request may close these issues.

2 participants