Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

One-dimensional minimisation and line searches

ProblemMinimise a function of one variable on an interval; or, inside a multidimensional method, choose how far to move along a search direction
Devised byGolden section search: Jack Kiefer (1953, as the limit of his Fibonacci search). Line search conditions: Larry Armijo (1966), Philip Wolfe (1969)
AccuracyGolden section: the interval shrinks by per evaluation, down to a limit of about relative. Line search: a step satisfying the strong Wolfe conditions, which is enough for the global convergence of descent methods
CostGolden section: one evaluation per iteration, in all. Line search: typically one to three evaluations of and
Read firstBackground: what a minimum looks like, Bracketing methods: bisection, false position, Ridders and Brent
APIGoldenSectionSearch, strong_wolfe

Overview

Minimising a function of one variable is the simplest optimisation problem, and the most often solved: every gradient-based method in this chapter reduces each iteration to a one-dimensional problem, choosing the step length along a search direction by approximately minimising .

Two kinds of method are described here. Golden section search finds the minimum of a unimodal function on an interval to any accuracy, using only comparisons of function values. It is the optimisation analogue of bisection: slow but certain. A line search inside a larger method does not need the exact minimum along the line, only a step that makes enough progress; the Wolfe conditions say what “enough” means, and a good line search finds such a step in one or two evaluations.

Where it is used

One-dimensional minimisation shows up as a subproblem everywhere.

  • Line searches. Every multidimensional method must choose how far to move along its search direction; the Wolfe conditions of this entry do so.
  • Single-parameter tuning. Finding the best bias point, learning rate or operating frequency on an interval.
  • Bracketing and unimodal functions. Golden-section search finds an optimum without derivatives, as in a one-knob experiment.

History

Jack Kiefer (1953) asked how to locate the maximum of a unimodal function with a fixed number of evaluations, and found the optimal strategy, Fibonacci search, whose interval reductions are ratios of Fibonacci numbers. When the number of evaluations is not fixed in advance, the limit of these ratios, the golden ratio, gives golden section search, almost as good and simpler. Richard Brent (1973) combined it with parabolic interpolation, as his root finder combines bisection with interpolation.

Inexact line searches arose with the gradient methods of the 1960s. Larry Armijo (1966) proposed accepting any step with a sufficient decrease in , found by backtracking. Philip Wolfe (1969, 1971) added a condition on the slope that rules out steps too short to make progress, and proved that the two together guarantee convergence of a wide class of methods; Guus Zoutendijk proved a similar theorem. Jorge Moré and David Thuente (1994) designed the line search used in most modern software, and Nocedal and Wright’s textbook version of it is the one used here.

The idea

Suppose is unimodal on : it decreases to a single minimum and then increases. Golden section search is to minimisation what bisection is to root finding: it traps the minimum in an interval and shrinks the interval at a fixed rate.

Why two interior points are needed. For a root, one interior value is enough, because its sign tells us which half contains the root. For a minimum it is not: knowing at , and one point between says nothing about which side of that point the minimum is on. So evaluate at two interior points .

  • If , the function is already rising at , so the minimum cannot lie in . The interval shrinks to .
  • Otherwise the minimum cannot lie in , and the interval shrinks to .

Why the golden ratio. After shrinking, one of the two interior points is still inside the new interval, with its function value already known. If it happens to sit where the next step wants one of its two points, each iteration needs only one new evaluation. This fixes where the points must go. Place them symmetrically, at fractions and of the way along an interval of length . If the interval shrinks to , its new length is , and the surviving point sits at distance from . For to be the upper interior point of the new interval it must be at fraction of the new length:

where is the golden ratio. Every iteration after the first then costs a single evaluation and reduces the interval by the factor . This is linear convergence, a little slower per evaluation than bisection’s factor of .

No smoothness needed. The method uses only comparisons of function values, so it works as well for , which has a corner at its minimum, as for .

The accuracy limit. There is a limit to how accurately any method that compares function values can locate a smooth minimum. Near the minimum the slope is zero, so

The function is very flat there: moving a little changes only by the square of the displacement. A computed function value has a rounding error of about . Once the difference is smaller than that, the computed values cannot tell which of two points is lower. Solving gives

The minimum can be located only to about relative accuracy in double precision, not . (A root, by contrast, can be found to full precision, because changes sign there.)

Table 5.3. Golden-section search: evaluations and accuracy.

function on toleranceevaluationserror in
236.0e-7
428.7e-10
611.8e-13
236.0e-7
428.7e-10
611.8e-13
232.0e-5
423.9e-11
614.0e-10

The first two functions have , so no rounding hides the minimum and the tolerance can be met. For (minimum at ), asking for gives a worse answer than asking for : below the limit the comparisons are decided by rounding. The same limit applies to every minimiser, and is why optimisation tolerances on are usually not set below about .

Line searches and the Wolfe conditions

Most methods for minimising a function of several variables work in two stages: choose a direction in which to move from the current point , then decide how far to go. The second stage is a one-dimensional problem. Define

the value of and its slope along the line, as functions of the step length . We assume is a descent direction, meaning : the function initially decreases along it.

Finding the exact minimiser of would waste evaluations, since will be replaced at the next iteration anyway. A line search looks instead for a step that is merely good enough. The standard definition of good enough is the pair of strong Wolfe conditions

with constants .

  • The first is the sufficient decrease (or Armijo) condition. The tangent line at predicts a decrease of ; the condition asks for at least the fraction of that. Steps so long that has climbed back up are ruled out.
  • The second is the curvature condition. It asks that the slope along the line has flattened to at most the fraction of its initial steepness. If the slope at is still strongly negative, there is more decrease to be had by going further, so the condition rules out steps that are too short.

Usual values are and for Newton and quasi-Newton methods, whose natural step is usually acceptable. Conjugate gradients need a more nearly exact minimum along the line and use .

Figure 5.2. A line search along steepest descent.

The figure shows along the steepest descent direction from on the Rosenbrock function. With the first trial step, , is already acceptable; with the search continues to a step near the minimum along the line.

Why these conditions in particular? Because they are enough to prove convergence. Zoutendijk’s theorem states that if every step satisfies the Wolfe conditions and the directions do not become orthogonal to the gradient, then , whatever the starting point. The iteration cannot stall at a point that is not stationary.

Algorithm

Golden section search. Input: , an interval containing the minimum, and a tolerance . Let .

  1. Place the two interior points, and , and evaluate and .
  2. While :
    • if , the minimum lies in : set , then reuse the old as the new (with its stored value), and compute a new and ;
    • otherwise it lies in : set , reuse the old as the new , and compute a new and .
  3. Return the midpoint of .

Each pass of the loop costs one evaluation and multiplies the width by , so reaching takes about evaluations: 39 for a reduction of , plus the few spent on the first interior points and the final value (42 in the table above).

Strong Wolfe line search (Nocedal and Wright, algorithms 3.5 and 3.6). Input: the point, a descent direction, the constants and an initial trial step. It has two phases.

  1. Bracketing. Try the initial step. Then repeat:
    • if the step satisfies both conditions, return it;
    • if it violates sufficient decrease, or is no lower than at the previous trial, the function has started to rise: an acceptable step lies between the previous trial and this one, so go to phase 2 with that interval;
    • if the slope at the step is positive, the minimum along the line has been passed: again go to phase 2;
    • otherwise is still falling steeply: double the step and try again.
  2. Zoom. Given an interval known to contain acceptable steps, choose a trial step inside it by fitting a cubic to and at the two ends and taking its minimiser, kept away from the ends (safeguarded interpolation, falling back to bisection). Test the trial: if it satisfies both conditions, return it; otherwise it replaces one end of the interval, chosen so that the interval still contains acceptable steps, and the zoom repeats.

Each trial costs one evaluation of and one of its gradient.

Implementation

        let inv_phi = (5.0_f64.sqrt() - 1.0) / 2.0; // 1/φ ≈ 0.618
        let mut c = b - inv_phi * (b - a);
        let mut d = a + inv_phi * (b - a);
        let (mut fc, mut fd) = (objective_function.evaluate(&[c]), objective_function.evaluate(&[d]));
        let mut evaluations = 2;
        while b - a > tolerance && evaluations < max_iterations {
            if fc < fd {
                // The minimum is in [a, d]; the old c becomes the new d.
                (b, d, fd) = (d, c, fc);
                c = b - inv_phi * (b - a);
                fc = objective_function.evaluate(&[c]);
            } else {
                // The minimum is in [c, b]; the old d becomes the new c.
                (a, c, fc) = (c, d, fd);
                d = a + inv_phi * (b - a);
                fd = objective_function.evaluate(&[d]);
            }
            evaluations += 1;
        }

The bracketing phase of the line search:

    let start = LineSearchPoint { alpha: 0.0, x: x0.to_vec(), value: f0, gradient: g0.to_vec() };
    let mut prev = (start, slope0);
    let mut alpha = initial_step;
    for i in 0..60 {
        let (p, slope) = eval(alpha);
        if !p.value.is_finite() {
            // Stepped outside the domain: shrink towards the last good point.
            alpha = 0.5 * (prev.0.alpha + alpha);
            continue;
        }
        if !sufficient(&p) || (i > 0 && p.value >= prev.0.value) {
            return zoom(prev, (p, slope));
        }
        if curvature(slope) {
            return Some(p);
        }
        if slope >= 0.0 {
            return zoom((p, slope), prev);
        }
        alpha *= 2.0;
        prev = (p, slope);
    }
    (prev.0.value < f0).then_some(prev.0)
  • GoldenSectionSearch takes its interval from bounds, which are required; the initial parameters only fix the dimension, which must be 1. Its iterations counts evaluations.
  • strong_wolfe returns None if is not a descent direction. If it cannot meet the conditions to rounding precision it returns the best decreasing point found, so the calling method can still make progress.

In practice

//! Golden section search, and a strong Wolfe line search along a direction.
//!
//! Run with `cargo run -p lib_jsl_optimization --example optimization_one_dimensional`.

use lib_jsl_optimization::golden_section_search::GoldenSectionSearch;
use lib_jsl_optimization::line_search::strong_wolfe;
use lib_jsl_optimization::optimization_traits::{GradientFreeMinimizationEngine, GradientFunction, MinimizationControls, ObjectiveFunction};

/// The cost of a cylindrical can of volume 1 as a function of its radius: area 2πr² + 2/r.
struct CanArea;
impl ObjectiveFunction for CanArea {
    fn evaluate(&self, p: &[f64]) -> f64 {
        2.0 * std::f64::consts::PI * p[0] * p[0] + 2.0 / p[0]
    }
}

/// f(x, y) = (x − 1)⁴ + (y + 2)² for the line search.
struct Bowl;
impl ObjectiveFunction for Bowl {
    fn evaluate(&self, p: &[f64]) -> f64 {
        (p[0] - 1.0).powi(4) + (p[1] + 2.0).powi(2)
    }
}
impl GradientFunction for Bowl {
    fn evaluate(&self, p: &[f64]) -> Vec<f64> {
        vec![4.0 * (p[0] - 1.0).powi(3), 2.0 * (p[1] + 2.0)]
    }
}

fn main() {
    // Golden section needs only an interval containing the minimum (given as bounds).
    let mut search = GoldenSectionSearch::new();
    search.set_bounds(Some(vec![(0.1, 2.0)]));
    search.set_tolerance(Some(1e-8));
    let r = search.gradient_free_minimize(&CanArea, vec![1.0]).unwrap();
    let exact = (1.0 / (2.0 * std::f64::consts::PI)).cbrt();
    println!("best radius {:.8} (exact {exact:.8}) after {} evaluations", r.parameters[0], r.iterations);

    // A line search along the steepest-descent direction from (0, 0).
    let x0 = [0.0, 0.0];
    let f0 = ObjectiveFunction::evaluate(&Bowl, &x0);
    let g0 = GradientFunction::evaluate(&Bowl, &x0);
    let d: Vec<f64> = g0.iter().map(|g| -g).collect();
    let point = strong_wolfe(&Bowl, &Bowl, &x0, f0, &g0, &d, 1.0, 1e-4, 0.9).unwrap();
    println!("step {:.4} to {:?}: f falls from {f0} to {:.4}", point.alpha, point.x, point.value);
}

Strengths

  • Golden section search needs no derivatives or smoothness, and its cost is known in advance.
  • The Wolfe line search makes gradient methods globally convergent at a cost of about one evaluation per iteration.

Weaknesses

  • Golden section search converges only linearly, and finds a local minimum if is not unimodal.
  • No method can locate a smooth minimum more precisely than about relative.

Exercises

  1. Show that the golden section points satisfy , and that this is what lets one point be reused.
  2. How many evaluations does golden section search need to reduce to ? Compare with bisection for a root.
  3. Fit a parabola through three points , , and find its minimum. Under what condition does this step make progress, and why does Brent’s method safeguard it?
  4. Show that for and smooth and bounded below along the ray, there is an interval of steps satisfying the strong Wolfe conditions.
  5. Run gradient descent on the Rosenbrock function with exact line searches (golden section on each line). Compare the number of evaluations with the Wolfe line search.
Hints and answers
  1. With , , so is , i.e. , true. This says the new interior point of the shrunken interval coincides with the old interior point on the other side, so one evaluation can be reused.
  2. , so about 29 reductions (plus the two initial evaluations). Bisection for a root needs evaluations: it uses the sign of and halves the interval each time, while golden section shrinks it only by per evaluation.
  3. The minimum of the parabola is . It makes progress when the parabola opens upwards and the minimum lies inside the bracket; Brent’s method falls back to a golden-section step when it does not, or when the step is too small.
  4. Let . Since is bounded below it must cross the line again after ; at the first crossing the mean value theorem gives a step with , and the strong Wolfe conditions hold in an interval around such points.
  5. Exact line searches use many more evaluations per iteration (about 30 for each golden-section search), so expect far more total evaluations than with a Wolfe search, for similar numbers of iterations.

Further reading

  • J. Kiefer, “Sequential minimax search for a maximum”, Proceedings of the American Mathematical Society 4 (1953) 502–506.
  • P. Wolfe, “Convergence conditions for ascent methods”, SIAM Review 11 (1969) 226–235.
  • J. J. Moré and D. J. Thuente, “Line search algorithms with guaranteed sufficient decrease”, ACM Transactions on Mathematical Software 20 (1994) 286–307.
  • J. Nocedal and S. J. Wright, Numerical Optimization, 2nd ed., Springer, 2006, chapter 3.
  • R. P. Brent, Algorithms for Minimization without Derivatives, Prentice-Hall, 1973, chapter 5.