Limited-memory BFGS β
Classical
Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS) optimization algorithm.
Algorithm Overview β
This module implements the L-BFGS (Limited-memory BFGS) optimization algorithm. L-BFGS is a quasi-Newton method that approximates the BFGS algorithm using a limited amount of computer memory. It's particularly useful for large-scale optimization problems where storing the full inverse Hessian approximation would be prohibitive.
L-BFGS maintains only a few vectors that represent the approximation implicitly, making it much more memory-efficient than full BFGS while retaining similar convergence properties.
This implementation uses scipy's L-BFGS-B optimizer with multiple random restarts to improve global optimization performance.
Usage β
from opt.classical.lbfgs import LBFGS
from opt.benchmark.functions import sphere
optimizer = LBFGS(
func=sphere,
lower_bound=-5.12,
upper_bound=5.12,
dim=10,
max_iter=500,
)
best_solution, best_fitness = optimizer.search()
print(f"Best solution: {best_solution}")
print(f"Best fitness: {best_fitness:.6e}")Parameters β
| Parameter | Type | Default | Description |
|---|---|---|---|
func | Callable | Required | Objective function to minimize. |
lower_bound | float | Required | Lower bound of search space. |
upper_bound | float | Required | Upper bound of search space. |
dim | int | Required | Problem dimensionality. |
max_iter | int | 1000 | Maximum iterations per restart. |
num_restarts | int | 25 | Number of random restarts for multistart strategy. |
seed | int | None | None | Random seed for reproducibility. |
Algorithm Metadata β
| Property | Value |
|---|---|
| Algorithm Name | Limited-memory BFGS |
| Acronym | L-BFGS |
| Year Introduced | 1980 |
| Authors | Nocedal, Jorge |
| Algorithm Class | Classical |
| Complexity | O(mn) per iteration (m corrections) |
| Properties | Gradient-based, Deterministic |
| Implementation | Python 3.10+ |
| COCO Compatible | Yes |
Mathematical Formulation β
Core update equation:
where:
is the position at iteration is the step size from line search is the search direction is the limited-memory approximation to inverse Hessian
L-BFGS stores only
(position change) (gradient change)
Constraint handling:
- Boundary conditions: L-BFGS-B variant with box constraints
- Feasibility enforcement: Direct bound enforcement during line search
Hyperparameters β
| Parameter | Default | BBOB Recommended | Description |
|---|---|---|---|
| max_iter | 1000 | 10000 | Maximum iterations |
| num_restarts | 25 | 10-50 | Number of random restarts |
Sensitivity Analysis:
num_restarts: High impact on global optimization quality- Recommended tuning ranges:
COCO/BBOB Benchmark Settings β
Search Space:
- Dimensions tested:
2, 3, 5, 10, 20, 40 - Bounds: Function-specific (typically
[-5, 5]or[-100, 100]) - Instances: 15 per function (BBOB standard)
Evaluation Budget:
- Budget:
function evaluations - Independent runs: 15 (for statistical significance)
- Seeds:
0-14(reproducibility requirement)
Performance Metrics:
- Target precision:
1e-8(BBOB default) - Success rate at precision thresholds:
[1e-8, 1e-6, 1e-4, 1e-2] - Expected Running Time (ERT) tracking
Raises β
ValueError: If search space is invalid or function evaluation fails.
Notes β
- Modifies self.history if track_history=True
- Uses self.seed for all random number generation
- BBOB: Returns final best solution after max_iter or convergence
Computational Complexity:
- Time per iteration:
where is memory parameter (typically 5-20) - Space complexity:
for storing vector pairs - BBOB budget usage: Typically uses 10-30% of
budget for smooth functions
BBOB Performance Characteristics:
- Best function classes: Unimodal, Smooth, High-dimensional
- Weak function classes: Non-smooth, Highly multimodal, Discontinuous
- Typical success rate at 1e-8 precision: 75-95% (dim=5-40, smooth functions)
- Expected Running Time (ERT): Excellent on smooth functions, scales to high dimensions
Convergence Properties:
- Convergence rate: Superlinear (quadratic near minimum for well-conditioned problems)
- Local vs Global: Strong local optimizer, multistart improves global search
- Premature convergence risk: Low for smooth functions, High for multimodal
Reproducibility:
- Deterministic: Yes (given same seed) - Same seed guarantees same restart points
- BBOB compliance: seed parameter required for 15 independent runs
- Initialization: Uniform random sampling in
[lower_bound, upper_bound] - RNG usage:
numpy.random.default_rng(self.seed)for restart initialization
Implementation Details:
- Parallelization: Not supported (sequential restarts)
- Constraint handling: L-BFGS-B with box constraints (native bound support)
- Numerical stability: Relies on SciPy's numerically stable L-BFGS-B implementation
Known Limitations:
- Requires gradient computation (finite differences if not provided)
- Memory parameter
trades off memory vs approximation quality - Multistart strategy increases total function evaluations
- May converge to local minima without sufficient restarts
Version History:
- v0.1.0: Initial implementation with multistart strategy
- v0.1.2: Added COCO/BBOB compliance documentation
References β
[1] Nocedal, J. (1980). "Updating quasi-Newton matrices with limited storage." Mathematics of Computation, 35(151), 773-782. https://doi.org/10.1090/S0025-5718-1980-0572855-7
[2] Liu, D. C., & Nocedal, J. (1989). "On the limited memory BFGS method for large scale optimization." Mathematical Programming, 45(1-3), 503-528. https://doi.org/10.1007/BF01589116
[3] Hansen, N., Auger, A., Ros, R., Mersmann, O., TuΕ‘ar, T., Brockhoff, D. (2021). "COCO: A platform for comparing continuous optimizers in a black-box setting." Optimization Methods and Software, 36(1), 114-144. https://doi.org/10.1080/10556788.2020.1808977
COCO Data Archive:
- Benchmark results: https://coco-platform.org/testsuites/bbob/data-archive.html
- Algorithm data: SciPy L-BFGS-B implementation widely benchmarked
- Code repository: https://github.com/Anselmoo/useful-optimizer
Implementation:
- Original paper code: FORTRAN implementation by Nocedal
- This implementation: Based on SciPy's L-BFGS-B with multistart for BBOB compliance
See Also β
BFGS: Full-memory variant with O(nΒ²) storage vs O(mn) for L-BFGS BBOB Comparison: Similar convergence, L-BFGS scales better for high dimensions
ConjugateGradient: First-order method with O(n) memory BBOB Comparison: Simpler updates, may be slower on ill-conditioned problems
AbstractOptimizer: Base class for all optimizers opt.benchmark.functions: BBOB-compatible test functions
Related BBOB Algorithm Classes:
- Classical: BFGS, NelderMead, TrustRegion
- Gradient: AdamW, SGDMomentum
Benchmark Performance β
Results of the benchmark suite for this optimizer, on the same evaluation budget as every other optimizer and compared with a random search baseline. See the methodology for the protocol and statistics.
Related Pages β
Source Code
View the implementation: lbfgs.py