Fix lcons/ucons length in __extract_lcons_ucons for optimize path#473
Merged
Conversation
The per-dispatch reconstruction of the constraint length from (M, N, bcresid_prototype, f_prototype) was wrong for several discretizations: - MIRK with prob.lcons set padded to N*M (decision-var length) instead of L_bc + M*(N-1) - FIRK Expanded was off by a factor of stage+1 - The ::Nothing f_prototype fallback used N*M everywhere The authoritative value is length(resid_prototype), which every caller already has. Replace the 3 dispatches with a single one that takes constraint_length::Int directly, and update callers. Incidentally fixes two multiple-shooting dispatches that referenced out-of-scope bcresid_prototype / f_prototype variables. Adds: - Unit test in BoundaryValueDiffEqCore for both fallback and user-provided lcons/ucons paths - Integration regression test in BoundaryValueDiffEqMIRK for the StandardBVProblem + optimize path that previously threw BoundsError Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Benchmark ResultsClick to check benchmark results
|
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/BoundaryValueDiffEq.jl
that referenced
this pull request
May 1, 2026
PR SciML#473 already landed the equivalent fixes for MIRK and FIRK (`copy(vec(cache.y₀))` in `__perform_*_iteration`, plus mesh-selection and resize fixes), but missed the same `vec(::VectorOfArray)` inference cliff in MIRKN's `__perform_mirkn_iteration`. Under RecursiveArrayTools v4, `vec(::VectorOfArray)` returns a `Base.ReshapedArray{T, 1, VectorOfArray{...}, …}` instead of a plain `Vector`. NonlinearSolve's polyalg cannot infer `T, N, uType, R` of the resulting `NonlinearSolution` when `u0` has that shape, so `@inferred solve(::SecondOrderBVProblem, ::MIRKN, …)` would widen the result type the same way it did for MIRK before SciML#473. Mirror PR SciML#473's fix: nlprob = __construct_nlproblem(cache, vec(cache.y₀), copy(cache.y₀)) → nlprob = __construct_nlproblem(cache, copy(vec(cache.y₀)), copy(cache.y₀)) Bumps `BoundaryValueDiffEqMIRKN` patch to 1.15.1. Also adds a regression `@testitem` for issue SciML#484 (the original adaptive-mesh-refinement `UndefRefError`) using the torus-geodesic BVP from the issue. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
This was referenced May 1, 2026
4 tasks
ErikQQY
pushed a commit
to ChrisRackauckas-Claude/BoundaryValueDiffEq.jl
that referenced
this pull request
May 3, 2026
- BoundaryValueDiffEqCore: 2.5.0 → 2.6.0 - BoundaryValueDiffEqMIRK: 1.16.0 → 1.17.0 - BoundaryValueDiffEqMIRKN: 1.15.1 → 1.16.0 - BoundaryValueDiffEqFIRK: 1.16.0 → 1.17.0 - BoundaryValueDiffEqShooting: 1.16.0 → 1.17.0 Bundles fixes accumulated since the last bump (b651399): - Core: lcons/ucons length fix in __extract_lcons_ucons (SciML#473) - MIRK: RAT mesh selection / global error control / view fix / initial guess fix / resize fix / type stability / Mooncake 0.5 - MIRKN: nlprob u0 inference fix (SciML#484/SciML#485) - FIRK: Enzyme compat fix / RAT mesh selection / resize fix / Mooncake 0.5 - Shooting: initial guess fix Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The per-dispatch reconstruction of the constraint length from (M, N, bcresid_prototype, f_prototype) was wrong for several discretizations:
The authoritative value is length(resid_prototype), which every caller already has. Replace the 3 dispatches with a single one that takes constraint_length::Int directly, and update callers.
Incidentally fixes two multiple-shooting dispatches that referenced out-of-scope bcresid_prototype / f_prototype variables.
Adds:
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.