1. Optimization Problems and Optimality Conditions
This chapter fixes the standard problem forms, first- and second-order optimality conditions, and the convergence quantities reported by each solver family in nlopt4r. Later chapters build the algorithms on these definitions.
1.1 Problem forms
Every entry point in nlopt4r minimizes. Maximization uses a negated objective and its derivatives.
| Problem class | Standard form | Main entry points |
|---|---|---|
| Unconstrained | \(\min f(x),\ x\in\mathbb R^n\) | minimize, local::lbfgs, local::newton_cg |
| Box-constrained | \(\min f(x),\ l\le x\le u\) | bounded::projected_gradient, derivative_free::* |
| Nonlinear constraints | \(\min f(x),\ h(x)=0,\ g(x)\ge 0\) | constrained::{sqp_with_restoration, augmented_lagrangian} |
| Least squares | \(\min \tfrac12|r(x)|^2\) | least_squares::* |
| Quadratic programming | \(\min \tfrac12 x^\top Hx+c^\top x,\ A_e x=b_e,\ A_i x\ge b_i\) | quadratic::* |
The book uses this notation throughout:
- \(f:\mathbb R^n\to\mathbb R\) is the objective, \(g=\nabla f(x)\), \(H=\nabla^2 f(x)\);
- \(h(x)\in\mathbb R^{m_e}\) holds the equalities and \(g(x)\in\mathbb R^{m_i}\) the inequalities;
- constraint Jacobians have shape “constraints × variables”, one row per constraint;
- the Lagrangian is \(L(x,\mu,\lambda)=f(x)-\mu^\top h(x)-\lambda^\top g(x)\) with \(\lambda\ge 0\).
1.2 Unconstrained first-order condition
A point \(x^\ast\) is stationary exactly when \(g(x^\ast)=0\). Gradient-based solvers in nlopt4r use
as the convergence test, where \(\tau_g\) comes from StopOptions::gradient_tolerance and defaults to \(10^{-6}\). The field Solution::gradient_norm carries this norm and termination_reason records the stopping criterion.
1.3 Box constraints and the gradient mapping
The feasible set of a box constraint is the closed box \(\mathcal B=\prod_i [l_i,u_i]\) with projection
First-order box stationarity is characterized by the unit-step gradient mapping
The equation \(G(x)=0\) is equivalent to the following coordinate conditions:
- interior coordinates: \(g_i(x)=0\);
- at the lower bound \(x_i=l_i\): \(g_i(x)\ge 0\);
- at the upper bound \(x_i=u_i\): \(g_i(x)\le 0\);
- fixed coordinates \(l_i=u_i\): the condition holds as stated.
bounded::projected_gradient reports \(|G(x)|_2\) in gradient_norm, and bounded::projected_gradient_norm computes this quantity separately. The mapping depends on variable units and box widths, which separates it from the unconstrained gradient norm.
1.4 Equality and inequality constraints
For the standard form \(\min f(x)\), \(h(x)=0\), \(g(x)\ge 0\), the Karush–Kuhn–Tucker (KKT) conditions read
nlopt4r reports three diagnostics separately:
- Lagrangian stationarity \(|\nabla_x L|_2\) in
ConstrainedSolution::solution.gradient_norm; - feasibility violation \(\max\bigl(\lVert h\rVert_\infty,\ \lVert(-g)_+\rVert_\infty\bigr)\) in
constraint_violation; - complementarity \(\bigl(\sum_i \min(g_i,\lambda_i)^2\bigr)^{1/2}\) in
complementarity.
Convergence requires all three within tolerance: stationarity uses gradient_tolerance; feasibility and complementarity use ConstrainedOptions::feasibility_tolerance with default \(10^{-6}\).
1.5 Least squares and quadratic programming
The least-squares objective \(f(x)=\tfrac12|r(x)|^2\) has gradient \(g(x)=J(x)^\top r(x)\), where \(J\) is the Jacobian of the residual vector. The stationarity condition \(J^\top r=0\) holds at nonzero residuals as well; the solver then reports convergence together with a positive residual norm.
The KKT system of a quadratic program uses the active inequality index set \(\mathcal A(x)={i: A_i x=b_i}\):
quadratic::QuadraticSolution reports equality multipliers, nonnegative inequality multipliers and the maximum constraint violation.
1.6 Second-order conditions
For the unconstrained case, a positive-definite \(H(x^\ast)\) at a stationary point is sufficient for a strict local minimum. With constraints, the sufficient condition tests the second-order term of the Lagrangian on the tangent space of the active constraints.
The two exact equality methods (NewtonLagrange, LagrangeSqp) read a caller-supplied Lagrangian Hessian:
The dense Newton methods (DampedNewton, ModifiedNewton) and the dense trust region use the objective Hessian. The remaining methods read first derivatives.
1.7 Meaning of the convergence report
Solution::gradient_norm changes meaning by solver family:
| Solver family | Reported convergence quantity |
|---|---|
| Unconstrained gradient/quasi-Newton/trust region | \(|g|_2\) |
| Box-constrained projected gradient | \(|x-P(x-g)|_2\) |
| Nonlinear constraints | Lagrangian stationarity \(|\nabla_x L|_2\) |
| Adaptive QR least squares | \(|D^{-1}J^\top r|_2\), with \(D\) the diagonal of Jacobian column norms |
| Scalar-search error checkpoint | NaN (scalar search reads objective values) |
The first-order test confirms a stationary point within the supplied tolerance; it does not certify global optimality. A global claim requires independent evidence, such as a complete exhaustive search over a finite candidate set, a mathematical lower bound, or an external certificate. Reaching a target value is a search outcome, not such a certificate. Chapter 9 documents the global-search report fields and chapter 13 the benchmark protocol.
Software interface
- Report structures
Solution,Status,TerminationReason: see chapter 20. - Box constraints and projection: see chapter 16 and chapter 21.
- Constraint diagnostics and multipliers: see chapter 19.
- API pages (docs.rs):
Objective,Evaluator,Bounds,Solution.
References
- J. Nocedal, S. J. Wright, Numerical Optimization, 2nd ed., Springer, 2006, Chapters 2, 12, 16.
- D. P. Bertsekas, Nonlinear Programming, 2nd ed., Athena Scientific, 1999, Chapter 3.