You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix MethodError when solving constrained problems with LBFGS without maxiters
This commit fixes issue #958 where using Optimization.LBFGS() with
constraints but without specifying maxiters would throw:
'MethodError: no method matching (::Colon)(::Int64, ::Nothing)'
The issue occurred because maxiters was nothing when not specified,
causing an error when creating the range 1:maxiters in the constrained
optimization path.
The fix adds a default value of 1000 iterations for constrained problems
when maxiters is not specified, matching the behavior of unconstrained
problems.
Also adds a test case to prevent regression.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Copy file name to clipboardExpand all lines: src/lbfgsb.jl
+18-9Lines changed: 18 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,9 @@ It is a quasi-Newton optimization algorithm that supports bounds.
8
8
9
9
References
10
10
11
-
- R. H. Byrd, P. Lu and J. Nocedal. A Limited Memory Algorithm for Bound Constrained Optimization, (1995), SIAM Journal on Scientific and Statistical Computing , 16, 5, pp. 1190-1208.
12
-
- C. Zhu, R. H. Byrd and J. Nocedal. L-BFGS-B: Algorithm 778: L-BFGS-B, FORTRAN routines for large scale bound constrained optimization (1997), ACM Transactions on Mathematical Software, Vol 23, Num. 4, pp. 550 - 560.
13
-
- J.L. Morales and J. Nocedal. L-BFGS-B: Remark on Algorithm 778: L-BFGS-B, FORTRAN routines for large scale bound constrained optimization (2011), to appear in ACM Transactions on Mathematical Software.
11
+
- R. H. Byrd, P. Lu and J. Nocedal. A Limited Memory Algorithm for Bound Constrained Optimization, (1995), SIAM Journal on Scientific and Statistical Computing , 16, 5, pp. 1190-1208.
12
+
- C. Zhu, R. H. Byrd and J. Nocedal. L-BFGS-B: Algorithm 778: L-BFGS-B, FORTRAN routines for large scale bound constrained optimization (1997), ACM Transactions on Mathematical Software, Vol 23, Num. 4, pp. 550 - 560.
13
+
- J.L. Morales and J. Nocedal. L-BFGS-B: Remark on Algorithm 778: L-BFGS-B, FORTRAN routines for large scale bound constrained optimization (2011), to appear in ACM Transactions on Mathematical Software.
14
14
"""
15
15
@kwdefstruct LBFGS
16
16
m::Int=10
@@ -92,6 +92,9 @@ function SciMLBase.__solve(cache::OptimizationCache{
0 commit comments