Skip to content

BFGS

Classical

Broyden-Fletcher-Goldfarb-Shanno (BFGS) quasi-Newton optimization algorithm.

Algorithm Overview

This module implements the BFGS (Broyden-Fletcher-Goldfarb-Shanno) optimization algorithm. BFGS is a quasi-Newton method that approximates Newton's method by using an approximation to the inverse Hessian matrix. It's particularly effective for smooth optimization problems and typically converges faster than first-order methods.

BFGS builds up an approximation to the inverse Hessian matrix using gradient information from previous iterations. This makes it more efficient than computing the actual Hessian while still providing second-order convergence properties.

This implementation uses scipy's BFGS optimizer with multiple random restarts to improve global optimization performance.

Usage

python
from opt.classical.bfgs import BFGS
from opt.benchmark.functions import sphere

optimizer = BFGS(
    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 NameBroyden-Fletcher-Goldfarb-Shanno
AcronymBFGS
Year Introduced1970
AuthorsBroyden, Charles; Fletcher, Roger; Goldfarb, Donald; Shanno, David
Algorithm ClassClassical
ComplexityO(n²) per iteration
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=Bk1f(xk) is the search direction
  • Bk is the approximation to the Hessian matrix

Hessian approximation update (BFGS formula):

Bk+1=Bk+ykykTykTskBkskskTBkskTBksk

where sk=xk+1xk and yk=f(xk+1)f(xk)

Constraint handling:

  • Boundary conditions: Penalty-based (large value for out-of-bounds)
  • Feasibility enforcement: Post-optimization clamping to bounds

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(n2) for Hessian approximation update
  • Space complexity: O(n2) for storing inverse Hessian approximation
  • BBOB budget usage: Typically uses 10-30% of dim×10000 budget for smooth functions

BBOB Performance Characteristics:

  • Best function classes: Unimodal, Smooth, Moderate conditioning
  • Weak function classes: Non-smooth, Highly multimodal, Discontinuous
  • Typical success rate at 1e-8 precision: 70-90% (dim=5, smooth functions)
  • Expected Running Time (ERT): Excellent on quadratic and near-quadratic functions

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: Penalty-based during optimization, clamping post-optimization
  • Numerical stability: Relies on SciPy's numerically stable BFGS implementation

Known Limitations:

  • Requires gradient computation (finite differences if not provided)
  • Memory scales as O(n²), impractical for very high dimensions (>1000)
  • 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] Broyden, C. G. (1970). "The Convergence of a Class of Double-rank Minimization Algorithms." IMA Journal of Applied Mathematics, 6(1), 76-90. https://doi.org/10.1093/imamat/6.1.76

[2] Fletcher, R. (1970). "A new approach to variable metric algorithms." The Computer Journal, 13(3), 317-322. https://doi.org/10.1093/comjnl/13.3.317

[3] Goldfarb, D. (1970). "A family of variable-metric methods derived by variational means." Mathematics of Computation, 24(109), 23-26. https://doi.org/10.1090/S0025-5718-1970-0258249-6

[4] Shanno, D. F. (1970). "Conditioning of quasi-Newton methods for function minimization." Mathematics of Computation, 24(111), 647-656. https://doi.org/10.1090/S0025-5718-1970-0274029-X

[5] 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: Multiple independent implementations
  • This implementation: Based on SciPy's BFGS with multistart for BBOB compliance

See Also

LBFGS: Limited-memory variant with O(n) memory vs O(n²) for BFGS BBOB Comparison: Similar convergence rate, better scaling for high dimensions

ConjugateGradient: First-order method without Hessian approximation BBOB Comparison: Faster per iteration, slower convergence on ill-conditioned problems

AbstractOptimizer: Base class for all optimizers opt.benchmark.functions: BBOB-compatible test functions

Related BBOB Algorithm Classes:

  • Classical: NelderMead, TrustRegion, Powell
  • Gradient: AdamW, SGDMomentum
  • Quasi-Newton: LBFGS

Benchmark Performance

Interactive fitness landscape of a representative multimodal benchmark function (drag to rotate, scroll to zoom):

Run-based charts

Convergence, distribution and ECDF charts appear here once this optimizer is included in the benchmark suite.


Source Code

View the implementation: bfgs.py

Released under the MIT License.