Skip to content

Use live parameters in sparse constraint Jacobians - #1289

Closed
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/fix-mirk-sparse-cons-j-live-parameters
Closed

Use live parameters in sparse constraint Jacobians#1289
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:agent/fix-mirk-sparse-cons-j-live-parameters

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Jul 29, 2026

Copy link
Copy Markdown
Member

Ignore this PR until it has been reviewed by @ChrisRackauckas.

Depends on #1288. After that PR merges, this branch should be rebased, bump OptimizationBase from 5.2.5 to 5.2.6, bump OptimizationIpopt from 1.3.0 to 1.3.1, and require OptimizationBase 5.2.6 from OptimizationIpopt. It intentionally does not compete for the 5.2.5 version number while both PRs are open.

Problem

OptimizationIpopt 1.3 switched to the shared OptimizationCache and now calls constraint Jacobians with the cache's live parameter value. The dense DifferentiationInterface path accepts (J, x, p), but the sparse wrappers capture the initialization parameter and only accept (J, x) (or x out of place).

That mismatch breaks BoundaryValueDiffEqMIRK's parameter-tuning solve with a three-argument MethodError. Auto-generated sparse Jacobians also silently keep using the initialization parameter after a cache parameter change.

Change

  • Let generated and supplied sparse constraint Jacobians accept an optional live p, in place and out of place.
  • Reuse prepared Jacobians only while both decision-variable and parameter types remain compatible; otherwise use the unprepared DI call.
  • Allocate generated in-place constraint outputs with an element type compatible with both x and p.
  • Add OptimizationBase tests for generated/supplied and in-place/out-of-place Jacobians with a changed parameter.
  • Add OptimizationIpopt end-to-end coverage for generated and supplied sparse Jacobians.

Local verification

  • GROUP=OptimizationBase_AD julia +1.10 --project=. -e 'using Pkg; Pkg.test()'
    • AD | 785 passed / 785 total
  • GROUP=OptimizationBase julia +1.10 --project=. -e 'using Pkg; Pkg.test()'
    • Core | 52 passed / 52 total
  • GROUP=OptimizationIpopt julia +1.10 --project=. -e 'using Pkg; Pkg.test()'
    • Core | 129 passed, 1 pre-existing broken / 130 total
  • BoundaryValueDiffEqMIRK reduced parameter-tuning solve with OptimizationIpopt 1.3.0 and the local patch:
    • successful retcode
    • optimized parameter 17.096586859834332
  • Runic 1.7.0: --check . passed.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>

Copy link
Copy Markdown
Member Author

Investigation scratchpad:

  1. Reproduced the exact BoundaryValueDiffEqMIRK MethodError locally on clean master with OptimizationIpopt 1.3.0.
  2. Re-ran the same parameter-tuning problem on OptimizationIpopt 1.2.2: it passed and found 17.096586859834332.
  3. Narrowed the transition to OptimizationIpopt commit be6fbd279a (Use the default OptimizationCache in OptimizationIpopt #1257), which began forwarding the shared cache's live p into derivatives.
  4. Compared sparse vs dense DI instantiation and found only the sparse constraint-Jacobian wrappers lacked the live-parameter argument.
  5. Added all four generated/supplied × in-place/out-of-place unit cases plus generated/supplied Ipopt integration cases in commit 140f9a4d.
  6. Ran OptimizationBase AD (785/785), OptimizationIpopt Core (129 pass + 1 pre-existing broken), the downstream reduced solve, and Runic locally.

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Additional local validation: GROUP=OptimizationBase julia +1.10 --project=. -e 'using Pkg; Pkg.test()' passed (52/52 Core tests; 257.7 s). This is in addition to OptimizationBase_AD (785/785) and OptimizationIpopt (129 pass, 1 pre-existing broken).

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

The patched end-to-end BoundaryValueDiffEqMIRK parameter-tuning solve also passes with the existing immutable SciMLStructures custom parameter wrapper (not only a vector): successful retcode and optimized parameter 17.096586859834332.

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Closing this as a duplicate of the existing draft #1270. The implementation and regressions are identical; I missed the older draft while revalidating the current clean-master failure. The fresh Core/AD/Ipopt and structured-parameter results will be carried onto #1270.

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