Skip to content

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 ​

python
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 ​

ParameterTypeDefaultDescription
funcCallableRequiredObjective function to minimize.
lower_boundfloatRequiredLower bound of search space.
upper_boundfloatRequiredUpper bound of search space.
dimintRequiredProblem dimensionality.
max_iterint1000Maximum iterations per restart.
num_restartsint25Number of random restarts for multistart strategy.
seedint | NoneNoneRandom seed for reproducibility.

Algorithm Metadata ​

PropertyValue
Algorithm NameLimited-memory BFGS
AcronymL-BFGS
Year Introduced1980
AuthorsNocedal, Jorge
Algorithm ClassClassical
ComplexityO(mn) per iteration (m corrections)
PropertiesGradient-based, Deterministic
ImplementationPython 3.10+
COCO CompatibleYes

Mathematical Formulation ​

Core update equation:

xk+1=xk+Ξ±kpk

where:

  • xk is the position at iteration k
  • Ξ±k is the step size from line search
  • pk=βˆ’Hkβˆ‡f(xk) is the search direction
  • Hk is the limited-memory approximation to inverse Hessian

L-BFGS stores only m recent vector pairs (si,yi) instead of full matrix:

  • si=xi+1βˆ’xi (position change)
  • yi=βˆ‡f(xi+1)βˆ’βˆ‡f(xi) (gradient change)

Constraint handling:

  • Boundary conditions: L-BFGS-B variant with box constraints
  • Feasibility enforcement: Direct bound enforcement during line search

Hyperparameters ​

ParameterDefaultBBOB RecommendedDescription
max_iter100010000Maximum iterations
num_restarts2510-50Number of random restarts

Sensitivity Analysis:

  • num_restarts: High impact on global optimization quality
  • Recommended tuning ranges: num_restarts∈[10,50]

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: dimΓ—10000 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: O(mn) where m is memory parameter (typically 5-20)
  • Space complexity: O(mn) for storing m vector pairs
  • BBOB budget usage: Typically uses 10-30% of dimΓ—10000 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 m 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:

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.


Source Code

View the implementation: lbfgs.py

Released under the MIT License.