The Wolfe Conditions
The Armijo condition stops steps from being too long. It does nothing about steps that are too short, and some methods need that protection: quasi-Newton updates learn curvature from the step, and a tiny step teaches them nothing. The Wolfe conditions add a curvature requirement.
The two conditions
For a descent direction and , a step satisfies the Wolfe conditions with if
The curvature condition says the slope at the new point must be less steep than times the starting slope: if the function is still dropping steeply, you should have gone further. The strong Wolfe conditions use , which also rules out points far past a minimum of . Typical values: , and for Newton and quasi-Newton or for nonlinear conjugate gradient.
Mapping the acceptable steps
import numpy as np
f = lambda p: (1 - p[0])**2 + 100 * (p[1] - p[0]**2)**2
grad = lambda p: np.array([-2 * (1 - p[0]) - 400 * p[0] * (p[1] - p[0]**2), 200 * (p[1] - p[0]**2)])
x = np.array([0.0, 0.0]); d = -grad(x) # steepest descent from the origin
phi = lambda t: f(x + t * d)
dphi = lambda t: grad(x + t * d) @ d
c1, c2 = 1e-4, 0.9
ts = np.linspace(0.0005, 0.6, 1200)
armijo = np.array([phi(t) <= phi(0) + c1 * t * dphi(0) for t in ts])
curv = np.array([dphi(t) >= c2 * dphi(0) for t in ts])
strong = np.array([abs(dphi(t)) <= c2 * abs(dphi(0)) for t in ts])
both = armijo & curv
print("Armijo holds up to t =", round(float(ts[armijo].max()), 4))
print("curvature holds from t =", round(float(ts[curv].min()), 4))
print("Wolfe interval:", round(float(ts[both].min()), 4), "to", round(float(ts[both].max()), 4))
print("strong Wolfe steps found:", int((armijo & strong).sum()), "of", len(ts))Armijo holds up to t = 0.1295
curvature holds from t = 0.0295
Wolfe interval: 0.0295 to 0.1295
strong Wolfe steps found: 145 of 1200
Why the curvature condition matters for BFGS
Quasi-Newton methods update a Hessian approximation from the pair and . The update keeps the approximation positive definite only if . The curvature condition gives exactly that:
since and . A Wolfe line search therefore keeps BFGS well defined on any function, convex or not.
Existence
If is smooth and bounded below along the ray, steps satisfying the (strong) Wolfe conditions always exist. Algorithms find one with a bracketing and zoom procedure: expand until an interval is known to contain acceptable steps, then shrink it by interpolation.
import numpy as np
from scipy.optimize import line_search
f = lambda p: (1 - p[0])**2 + 100 * (p[1] - p[0]**2)**2
grad = lambda p: np.array([-2 * (1 - p[0]) - 400 * p[0] * (p[1] - p[0]**2), 200 * (p[1] - p[0]**2)])
x = np.array([0.0, 0.0]); d = -grad(x)
t, fc, gc, new_f, old_f, _ = line_search(f, grad, x, d, c1=1e-4, c2=0.9)
print(f"SciPy strong-Wolfe step: t = {t:.4f}, f: {old_f:.4f} -> {new_f:.4f}, {fc} function evaluations")SciPy strong-Wolfe step: t = 0.0868, f: 1.0000 -> 0.7737, 6 function evaluations
Zoutendijk's theorem in one line
With Wolfe steps and directions not too close to perpendicular to the gradient (), the gradients must go to zero: . This is the global convergence guarantee behind every line-search method in this part.
In software
scipy.optimize.line_searchand the line searches insideminimize(method="BFGS")and"CG"enforce the strong Wolfe conditions.- L-BFGS in PyTorch (
torch.optim.LBFGS(line_search_fn="strong_wolfe")) offers the same option.
Exercises
Exercise 1: Check the conditions
For (so ), , , does satisfy Wolfe? ?
Answer
fails the curvature condition; satisfies both.
Solution
Curvature needs , i.e. . Armijo needs , i.e. , true for . So passes both, fails curvature.
Exercise 2: Why ?
What could go wrong if ?
Answer
There might be no step satisfying both conditions.
Solution
For a quadratic with minimum at , Armijo holds for and curvature for . The interval is non-empty when (and is enough to keep itself acceptable); with close to 1 and small, it can be empty.
Exercise 3: is positive (code)
Take the SciPy Wolfe step from the origin of Rosenbrock and compute .
Answer
It is positive.
Solution
import numpy as np
from scipy.optimize import line_search
f = lambda p: (1 - p[0])**2 + 100 * (p[1] - p[0]**2)**2
grad = lambda p: np.array([-2 * (1 - p[0]) - 400 * p[0] * (p[1] - p[0]**2), 200 * (p[1] - p[0]**2)])
x = np.zeros(2); d = -grad(x)
t = line_search(f, grad, x, d)[0]
s = t * d; y = grad(x + s) - grad(x)
print(f"s^T y = {s @ y:.6f} > 0: {s @ y > 0}")s^T y = 0.423083 > 0: True
Test yourself
The curvature condition prevents steps that are…
- too long
- too short
- negative
- exactly optimal
For quasi-Newton methods, the Wolfe conditions guarantee…
- , keeping the Hessian approximation positive definite
- a convex function
- an exact line search
- a step of length 1
Typical Wolfe parameters for BFGS are…
- ,
- ,
- ,