Commit 654f65f
Fix Lagrangian Hessian prototype dimensions in OptimizationZygoteExt
The Lagrangian Hessian prototype was incorrectly sized as (num_constraints × num_variables)
instead of (num_variables × num_variables). This caused a `BoundsError` when computing the
Lagrangian Hessian with more variables than constraints, as the prototype was used as a
buffer for the n×n Hessian matrix.
Changes:
- Fix lag_hess_prototype initialization to use zeros(Bool, length(x), length(x))
- Add comprehensive tests to verify prototype dimensions and usability as a buffer
This ensures the Lagrangian Hessian is always correctly sized as n×n regardless of the
number of constraints, matching the mathematical definition of the Lagrangian Hessian
as the second derivative with respect to the decision variables.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 764af82 commit 654f65f
File tree
2 files changed
+23
-1
lines changed- lib/OptimizationBase
- ext
- test
2 files changed
+23
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
| 211 | + | |
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
260 | 271 | | |
261 | 272 | | |
262 | 273 | | |
| |||
490 | 501 | | |
491 | 502 | | |
492 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
493 | 515 | | |
494 | 516 | | |
495 | 517 | | |
| |||
0 commit comments