2. Line Search and Scalar Search
Line search chooses a step length for a one-dimensional subproblem. nlopt4r provides two searches: Armijo backtracking along a supplied descent direction (line_search::armijo) and a strong-Wolfe search (local::wolfe::strong_wolfe). Scalar search minimizes a univariate function on a finite closed interval. This chapter lists the conditions, implementation parameters and report fields.
2.1 Descent directions and the Armijo condition
For a smooth objective \(f\), a direction \(d\) is a descent direction when
Armijo backtracking starts at \(\alpha_0=1\) and tries \(\alpha_k=\alpha_0\kappa^k\), accepting a step that satisfies
The defaults are \(c_1=0.2\), contraction \(\kappa=0.5\) and 60 trials.
Backtracking returns explicit errors in these cases:
- the direction satisfies \(g^\top d\ge 0\):
Error::InvalidInput; - the trial allowance runs out:
Error::LineSearchFailed { evaluations, last_step }, withevaluationsthe number of trials andlast_stepthe final step length; - a trial produces a non-finite value or the callback returns an error: that error propagates unchanged.
An accepted step returns Step { alpha, value, evaluations }, where value is the objective at the accepted point. armijo computes the origin gradient on entry; the caller supplies the direction and options.
Figure 2-1 Accepted interval of Armijo backtracking: \(\phi(\alpha)=1-3\alpha+3\alpha^2\), \(c_1=0.2\). The dashed line is the linear upper bound \(\phi(0)+c_1\alpha\phi^\prime(0)\) and the shaded band covers \(\alpha\in[0,0.8]\); the trial \(\alpha=0.5\) lies on the curve and the trial \(\alpha=1\) lies above the tangent. Section 2.2 of the textbook organizes inexact line search with the same inequality.
2.2 Strong Wolfe conditions
The strong-Wolfe search requires sufficient decrease and a curvature condition:
with \(0<c_1<c_2<1\); the defaults are \(c_1=10^{-4}\) and \(c_2=0.9\).
The implementation has two stages:
- from the initial step 1, trial steps expand by doubling until a bracket holds an acceptable point;
- within a bracket, midpoints are strictly interior to the interval.
Both stages share the trial allowance (default 80, with the origin evaluation counted separately). Each trial computes the value and gradient together; the accepted pair is stored in StrongWolfeStep { alpha, value, gradient, evaluations } for reuse by the outer solver. A bracket that reaches midpoint precision returns LineSearchFailed.
The strong-Wolfe search supplies the outer step for L-BFGS and Newton-CG; the curvature condition supports positive-definite BFGS updates.
2.3 Scalar search
Scalar search minimizes a continuous unimodal function on a finite closed interval \([a,b]\) with two methods:
- golden section (
ScalarMethod::GoldenSection), contracting the interval by \(\rho=(3-\sqrt5)/2\approx0.382\); - parabolic/Brent interpolation (
ScalarMethod::Parabolic), with safeguarded interpolation combined with golden-section protection.
Figure 2-2 Golden-section interval contraction: trial points sit at \(a+0.382(b-a)\) and \(a+0.618(b-a)\). Case (1) keeps \([a,q]\) and case (2) keeps \([p,b]\); both keep one trial point for the next round and multiply the interval length by \(t\approx0.618\). Section 2.1.1 of the textbook derives \(t\) from \(t^2=1-t\) (equation (2.6)) and gives the complete algorithm.
The stopping test uses the mixed interval tolerance
with defaults \(\tau_{\text{abs}}=10^{-8}\) and \(\tau_{\text{rel}}=\sqrt{\varepsilon_{\text{machine}}}\). ScalarOptions::interval_tolerance stores both parameters, and StopOptions provides iteration and objective-evaluation allowances.
minimize_scalar is the convenience entry with an absolute tolerance, an iteration cap and a method; minimize_scalar_with_options takes full ScalarOptions and supports a strict objective budget.
The mathematical assumption is continuity and unimodality on the interval. The interval test and global multimodal optimality are distinct conclusions.
2.4 Report fields
| Type | Field | Meaning |
|---|---|---|
Step | alpha | Accepted step length |
Step | value | Objective at the accepted point |
Step | evaluations | Number of trials |
StrongWolfeStep | alpha, value, gradient | Accepted step, objective, analytic gradient |
StrongWolfeStep | evaluations | Combined value/gradient callbacks (origin counted separately) |
ScalarSolution | x, value, bracket | Best point, objective, remaining interval |
ScalarSolution | status, termination_reason | Interval convergence or a budget/iteration stop |
ScalarSolution | evaluations | Objective calls, including endpoint evaluations |
2.5 Parameter defaults
| Option type | Field | Default | Valid range |
|---|---|---|---|
ArmijoOptions | initial_step | 1 | Positive finite |
ArmijoOptions | contraction | 0.5 | \((0,1)\) |
ArmijoOptions | sufficient_decrease | 0.2 | \((0,1)\) |
ArmijoOptions | max_iterations | 60 | Positive integer |
StrongWolfeOptions | sufficient_decrease | \(10^{-4}\) | \(0<c_1<c_2\) |
StrongWolfeOptions | curvature | 0.9 | \(c_1<c_2<1\) |
StrongWolfeOptions | initial_step / maximum_step | 1 / \(10^{20}\) | Positive finite, initial at most maximum |
StrongWolfeOptions | max_evaluations | 80 | Positive integer |
ScalarOptions | interval_tolerance | \(10^{-8}+\sqrt{\varepsilon},\vert x\vert\) | Nonnegative, at least one term positive |
Software interface
line_search::{armijo, minimize_scalar, minimize_scalar_with_options}: see chapter 16.Step,StrongWolfeStepand recovery from failures: see chapter 20.- API reference (docs.rs):
line_search.
References
- 马昌凤, 最优化方法及其 Matlab 程序设计 (in Chinese), 2010, chapter 2.
- J. Nocedal, S. J. Wright, Numerical Optimization, 2nd ed., 2006, Chapter 3.
- R. P. Brent, Algorithms for Minimization without Derivatives, Prentice-Hall, 1973.