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

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 classStandard formMain 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

$$ \|g(x_k)\|_2 \le \tau_g $$

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

$$ P(x)_i=\min\bigl(u_i,\max(l_i,x_i)\bigr). $$

First-order box stationarity is characterized by the unit-step gradient mapping

$$ G(x)=x-P\bigl(x-g(x)\bigr). $$

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

$$ \nabla f(x)-\nabla h(x)^\top\mu-\nabla g(x)^\top\lambda=0, $$
$$ h(x)=0,\qquad g(x)\ge 0,\qquad \lambda\ge 0,\qquad \lambda_i g_i(x)=0\ \ (i=1,\dots,m_i). $$

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}\):

$$ Hx+c-A_e^\top\mu-A_i^\top\lambda=0,\qquad \lambda\ge 0,\qquad \lambda_i(A_i x-b_i)=0. $$

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:

$$ \nabla^2_{xx}L(x,\mu,\lambda)=\nabla^2 f(x)-\sum_j \mu_j\nabla^2 h_j(x)-\sum_i \lambda_i\nabla^2 g_i(x). $$

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 familyReported convergence quantity
Unconstrained gradient/quasi-Newton/trust region\(|g|_2\)
Box-constrained projected gradient\(|x-P(x-g)|_2\)
Nonlinear constraintsLagrangian 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 checkpointNaN (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

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.