In numerical optimization, the Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm is an iterative method for solving unconstrained nonlinear optimization problems.[1] Like the related Davidon–Fletcher–Powell method, BFGS determines the descent direction by preconditioning the gradient with curvature information. It does so by gradually improving an approximation to the Hessian matrix of the loss function, obtained only from gradient evaluations (or approximate gradient evaluations) via a generalized secant method.[2]
| This article needs additional citations for verification. (March 2016) |
Since the updates of the BFGS curvature matrix do not require matrix inversion, its computational complexity is only
, compared to
in Newton's method. Also in common use is L-BFGS, which is a limited-memory version of BFGS that is particularly suited to problems with very large numbers of variables (e.g., >1000). The BFGS-B variant handles simple box constraints.[3]
The algorithm is named after Charles George Broyden, Roger Fletcher, Donald Goldfarb and David Shanno.[4][5][6][7]
The optimization problem is to minimize
, where
is a vector in
, and
is a differentiable scalar function. There are no constraints on the values that
can take.
The algorithm begins at an initial estimate
for the optimal value and proceeds iteratively to get a better estimate at each stage.
The search direction pk at stage k is given by the solution of the analogue of the Newton equation:
![{\displaystyle B_{k}\mathbf {p} _{k}=-\nabla f(\mathbf {x} _{k}),}](//wikimedia.org/api/rest_v1/media/math/render/svg/15410742cd3764392420736b6659d914c16c8a9d)
where
is an approximation to the Hessian matrix at
, which is updated iteratively at each stage, and
is the gradient of the function evaluated at xk. A line search in the direction pk is then used to find the next point xk+1 by minimizing
over the scalar ![{\displaystyle \gamma >0.}](//wikimedia.org/api/rest_v1/media/math/render/svg/16690ba48007f8fdb0fa4d0a7f66a2edeb5bae8c)
The quasi-Newton condition imposed on the update of
is
![{\displaystyle B_{k+1}(\mathbf {x} _{k+1}-\mathbf {x} _{k})=\nabla f(\mathbf {x} _{k+1})-\nabla f(\mathbf {x} _{k}).}](//wikimedia.org/api/rest_v1/media/math/render/svg/189f46fe6b9f84565acf0d887814bdd038e26681)
Let
and
, then
satisfies
,
which is the secant equation.
The curvature condition
should be satisfied for
to be positive definite, which can be verified by pre-multiplying the secant equation with
. If the function is not strongly convex, then the condition has to be enforced explicitly e.g. by finding a point xk+1 satisfying the Wolfe conditions, which entail the curvature condition, using line search.
Instead of requiring the full Hessian matrix at the point
to be computed as
, the approximate Hessian at stage k is updated by the addition of two matrices:
![{\displaystyle B_{k+1}=B_{k}+U_{k}+V_{k}.}](//wikimedia.org/api/rest_v1/media/math/render/svg/8c696db4102846072a2b83c7773381d8389eb498)
Both
and
are symmetric rank-one matrices, but their sum is a rank-two update matrix. BFGS and DFP updating matrix both differ from its predecessor by a rank-two matrix. Another simpler rank-one method is known as symmetric rank-one method, which does not guarantee the positive definiteness. In order to maintain the symmetry and positive definiteness of
, the update form can be chosen as
. Imposing the secant condition,
. Choosing
and
, we can obtain:[8]
![{\displaystyle \alpha ={\frac {1}{\mathbf {y} _{k}^{T}\mathbf {s} _{k}}},}](//wikimedia.org/api/rest_v1/media/math/render/svg/9b3f5bf74f28a4aad022889c9a296d686a8e468b)
![{\displaystyle \beta =-{\frac {1}{\mathbf {s} _{k}^{T}B_{k}\mathbf {s} _{k}}}.}](//wikimedia.org/api/rest_v1/media/math/render/svg/6f57e9f766cb230dcbaf25b723b0aa18e9d7b5c7)
Finally, we substitute
and
into
and get the update equation of
:
![{\displaystyle B_{k+1}=B_{k}+{\frac {\mathbf {y} _{k}\mathbf {y} _{k}^{\mathrm {T} }}{\mathbf {y} _{k}^{\mathrm {T} }\mathbf {s} _{k}}}-{\frac {B_{k}\mathbf {s} _{k}\mathbf {s} _{k}^{\mathrm {T} }B_{k}^{\mathrm {T} }}{\mathbf {s} _{k}^{\mathrm {T} }B_{k}\mathbf {s} _{k}}}.}](//wikimedia.org/api/rest_v1/media/math/render/svg/a35a8af03a6dae3bf36ee782df712300c51dab00)
Consider the following unconstrained optimization problem
where
is a nonlinear objective function.
From an initial guess
and an initial guess of the Hessian matrix
the following steps are repeated as
converges to the solution:
- Obtain a direction
by solving
.
- Perform a one-dimensional optimization (line search) to find an acceptable stepsize
in the direction found in the first step. If an exact line search is performed, then
. In practice, an inexact line search usually suffices, with an acceptable
satisfying Wolfe conditions.
- Set
and update
.
.
.
Convergence can be determined by observing the norm of the gradient; given some
, one may stop the algorithm when
If
is initialized with
, the first step will be equivalent to a gradient descent, but further steps are more and more refined by
, the approximation to the Hessian.
The first step of the algorithm is carried out using the inverse of the matrix
, which can be obtained efficiently by applying the Sherman–Morrison formula to the step 5 of the algorithm, giving
![{\displaystyle B_{k+1}^{-1}=\left(I-{\frac {\mathbf {s} _{k}\mathbf {y} _{k}^{T}}{\mathbf {y} _{k}^{T}\mathbf {s} _{k}}}\right)B_{k}^{-1}\left(I-{\frac {\mathbf {y} _{k}\mathbf {s} _{k}^{T}}{\mathbf {y} _{k}^{T}\mathbf {s} _{k}}}\right)+{\frac {\mathbf {s} _{k}\mathbf {s} _{k}^{T}}{\mathbf {y} _{k}^{T}\mathbf {s} _{k}}}.}](//wikimedia.org/api/rest_v1/media/math/render/svg/33ab55440cb62db015b2e7ca69b6f3ffb8ae587f)
This can be computed efficiently without temporary matrices, recognizing that
is symmetric,
and that
and
are scalars, using an expansion such as
![{\displaystyle B_{k+1}^{-1}=B_{k}^{-1}+{\frac {(\mathbf {s} _{k}^{\mathrm {T} }\mathbf {y} _{k}+\mathbf {y} _{k}^{\mathrm {T} }B_{k}^{-1}\mathbf {y} _{k})(\mathbf {s} _{k}\mathbf {s} _{k}^{\mathrm {T} })}{(\mathbf {s} _{k}^{\mathrm {T} }\mathbf {y} _{k})^{2}}}-{\frac {B_{k}^{-1}\mathbf {y} _{k}\mathbf {s} _{k}^{\mathrm {T} }+\mathbf {s} _{k}\mathbf {y} _{k}^{\mathrm {T} }B_{k}^{-1}}{\mathbf {s} _{k}^{\mathrm {T} }\mathbf {y} _{k}}}.}](//wikimedia.org/api/rest_v1/media/math/render/svg/a69329f93f8e0c14b43d47cfff241160d4ab4c96)
Therefore, in order to avoid any matrix inversion, the inverse of the Hessian can be approximated instead of the Hessian itself:
[9]
From an initial guess
and an approximate inverted Hessian matrix
the following steps are repeated as
converges to the solution:
- Obtain a direction
by solving
.
- Perform a one-dimensional optimization (line search) to find an acceptable stepsize
in the direction found in the first step. If an exact line search is performed, then
. In practice, an inexact line search usually suffices, with an acceptable
satisfying Wolfe conditions.
- Set
and update
.
.
.
In statistical estimation problems (such as maximum likelihood or Bayesian inference), credible intervals or confidence intervals for the solution can be estimated from the inverse of the final Hessian matrix [citation needed]. However, these quantities are technically defined by the true Hessian matrix, and the BFGS approximation may not converge to the true Hessian matrix.[10]
The BFGS update formula heavily relies on the curvature
being strictly positive and bounded away from zero.
This condition is satisfied when we perform a line search with Wolfe conditions on a convex target.
However, some real-life applications (like Sequential Quadratic Programming methods) routinely produce negative or nearly-zero curvatures.
This can occur when optimizing a nonconvex target or when employing a trust-region approach instead of a line search.
It is also possible to produce spurious values due to noise in the target.
In such cases, one of the so-called damped BFGS updates can be used (see [11]) which modify
and/or
in order to obtain a more robust update.
Notable open source implementations are:
- ALGLIB implements BFGS and its limited-memory version in C++ and C#
- GNU Octave uses a form of BFGS in its
fsolve
function, with trust region extensions.
- The GSL implements BFGS as gsl_multimin_fdfminimizer_vector_bfgs2.[12]
- In R, the BFGS algorithm (and the L-BFGS-B version that allows box constraints) is implemented as an option of the base function optim().[13]
- In SciPy, the scipy.optimize.fmin_bfgs function implements BFGS.[14] It is also possible to run BFGS using any of the L-BFGS algorithms by setting the parameter L to a very large number.
- In Julia, the Optim.jl package implements BFGS and L-BFGS as a solver option to the optimize() function (among other options).[15]
Notable proprietary implementations include:
- The large scale nonlinear optimization software Artelys Knitro implements, among others, both BFGS and L-BFGS algorithms.
- In the MATLAB Optimization Toolbox, the fminunc function uses BFGS with cubic line search when the problem size is set to "medium scale."
- Mathematica includes BFGS.
- LS-DYNA also uses BFGS to solve implicit Problems.
Fletcher, R. (1970), "A New Approach to Variable Metric Algorithms", Computer Journal, 13 (3): 317–322, doi:10.1093/comjnl/13.3.317
Jorge Nocedal; Stephen J. Wright (2006), Numerical Optimization
- Avriel, Mordecai (2003), Nonlinear Programming: Analysis and Methods, Dover Publishing, ISBN 978-0-486-43227-4
- Bonnans, J. Frédéric; Gilbert, J. Charles; Lemaréchal, Claude; Sagastizábal, Claudia A. (2006), "Newtonian Methods", Numerical Optimization: Theoretical and Practical Aspects (Second ed.), Berlin: Springer, pp. 51–66, ISBN 3-540-35445-X
- Fletcher, Roger (1987), Practical Methods of Optimization (2nd ed.), New York: John Wiley & Sons, ISBN 978-0-471-91547-8
- Luenberger, David G.; Ye, Yinyu (2008), Linear and nonlinear programming, International Series in Operations Research & Management Science, vol. 116 (Third ed.), New York: Springer, pp. xiv+546, ISBN 978-0-387-74502-2, MR 2423726
- Kelley, C. T. (1999), Iterative Methods for Optimization, Philadelphia: Society for Industrial and Applied Mathematics, pp. 71–86, ISBN 0-89871-433-8