Convex optimization

On this page 8

Convex optimization is the branch of mathematical optimization that minimizes a convex objective function over a convex feasible set, a structure that guarantees every local minimum is also a global minimum. In artificial intelligence, it underpins classical models such as logistic regression, support vector machines and lasso, and it supplies the theory behind many solvers used in modern machine learning pipelines.

The practical value of convexity is predictability. A convex problem has no deceptive valleys, its optimality can be certified with a duality gap, and mature algorithms solve it in polynomial time for most standard problem classes. These guarantees explain why practitioners try to formulate problems as convex whenever the application allows it.

What makes a problem convex

A problem is convex when it has the form: minimize a convex function f(x) subject to convex inequality constraints g_i(x) ≤ 0 and affine equality constraints Ax = b. A function is convex when the line segment between any two points on its graph lies on or above the graph; for twice-differentiable functions this is equivalent to a positive semidefinite Hessian matrix everywhere in the domain.

A set is convex when it contains the whole segment between any two of its points. Intersections of convex sets remain convex, which is why adding convex constraints never breaks convexity. Equality constraints must be affine, because a nonlinear equality such as x² + y² = 1 describes a circle, which is not a convex set.

The table below lists the building blocks most often used to verify convexity in practice.

Building blockExampleWhy it is convex
Affine functiona·x + bBoth convex and concave
Norm‖x‖₂, ‖x‖₁Satisfies the triangle inequality
Quadratic formxᵀQx with Q ⪰ 0Positive semidefinite Hessian
Log-sum-explog Σ exp(x_i)Smooth upper bound of the maximum
Pointwise maximummax(f₁, f₂)Maximum of convex functions
Negative logarithm−log x on x > 0Second derivative 1/x² > 0
Common convex building blocks

Standard classes of convex problems

Convex problems form a hierarchy of standard classes, each one containing the previous. Recognizing the class matters because it determines which solver applies and how large a problem can be solved in reasonable time.

ClassObjective and constraintsTypical AI use
Linear programming (LP)Linear objective, linear constraintsResource allocation, optimal transport
Quadratic programming (QP)Convex quadratic objective, linear constraintsSupport vector machine training
Second-order cone programming (SOCP)Linear objective, norm-cone constraintsRobust regression, portfolio models
Semidefinite programming (SDP)Linear objective, matrix inequality constraintsRelaxations of combinatorial problems
Exponential cone programmingConstraints with exp and logLogistic regression, entropy models
Hierarchy of convex problem classes

Modeling tools based on disciplined convex programming, such as CVXPY and CVX, apply composition rules to verify convexity automatically and translate the model into one of these conic forms before passing it to a solver.

Optimality conditions and duality

For a convex problem, a point is optimal exactly when it satisfies the Karush-Kuhn-Tucker conditions, provided a mild constraint qualification such as Slater’s condition holds. These conditions combine primal feasibility, dual feasibility, complementary slackness and a stationarity condition on the Lagrangian.

Lagrangian duality gives every convex problem a companion dual problem whose optimal value bounds the primal value from below. Under Slater’s condition the bound is tight, a property called strong duality. Solvers report the duality gap between primal and dual objectives, so a gap of 10⁻⁸ is a mathematical certificate that the solution is within that tolerance of the true optimum. Non-convex methods offer no comparable certificate.

Algorithms for convex problems

Algorithm choice depends on problem size, smoothness and required accuracy. Second-order methods converge in few iterations but need expensive linear algebra; first-order methods scale to millions of variables but converge more slowly.

MethodBest suited forConvergence behavior
Interior-point methodSmall to medium LP, QP, SOCP, SDPHigh accuracy in 20 to 80 iterations
Gradient descentLarge smooth problemsO(1/k), or linear if strongly convex
Accelerated gradientLarge smooth problemsO(1/k²), optimal for first-order methods
Proximal gradient methodSmooth loss plus nonsmooth penaltyHandles lasso and group penalties
ADMMDistributed or separable problemsModerate accuracy, easy to parallelize
Subgradient methodNonsmooth objectivesSlow, O(1/√k)
Main algorithm families compared

Strong convexity, meaning the function curves upward at least as fast as a quadratic, improves gradient descent from sublinear to linear convergence. This is why L2 regularization both stabilizes models and speeds up training.

Convex and non-convex optimization in machine learning

Training a deep neural network is a non-convex optimization problem with many saddle points and local optima, yet convex theory still shapes it. Learning-rate schedules, momentum and adaptive methods were first analyzed for convex objectives, and their convergence proofs often rely on local convex approximations.

AspectConvex problemNon-convex problem
Local minimaAll are globalMany, of varying quality
InitializationDoes not affect the optimumStrongly affects the result
Optimality certificateDuality gapUsually none
Typical modelsLogistic regression, SVM, lassoDeep networks, matrix factorization
ReproducibilitySame optimum on every runResults vary with random seed
Convex versus non-convex training problems

Convex optimization also appears inside non-convex pipelines: convex relaxations of integer programs, convex layers embedded in networks, optimal transport between distributions and the final linear probe trained on frozen features.

Limitations and common mistakes

Convexity is a property of the formulation, not of the underlying task. Many real requirements, such as integer decisions, fixed costs or sparsity counted exactly, are inherently non-convex, and forcing them into a convex model can change the meaning of the problem.

  • Assuming convexity without proof: a single nonlinear equality constraint destroys it.
  • Maximizing a convex function: this is a non-convex problem, often NP-hard.
  • Ignoring numerical conditioning: badly scaled data slows interior-point and gradient methods alike.
  • Choosing the wrong solver: interior-point methods exhaust memory on problems with millions of variables.
  • Overtrusting relaxations: a relaxed optimum is only a bound, and rounding it may lose feasibility.

A non-technical view

Imagine looking for the lowest point in a landscape. If the ground is shaped like a single smooth bowl, walking downhill always brings you to the bottom. There is no false valley to trap you.

Convex optimization is the study of problems shaped like that bowl. Because of this shape, a computer can find the best possible answer and also prove it. Many tasks in AI are rough mountain ranges instead. Engineers therefore try to describe a problem as a bowl whenever they honestly can.

A concrete example

A data science team at a mid-sized insurer predicts claim probability from about 400 policy features and 2 million historical records. They fit an L1-regularized logistic regression, which is a convex problem: the logistic loss is convex and the L1 penalty is a norm.

Using a proximal gradient solver, training converges in under two minutes, and repeated runs with different random seeds return exactly the same coefficients. The L1 penalty drives roughly 330 coefficients to zero, leaving a sparse model of about 70 features that underwriters can review. Because the solution is a certified global optimum, auditors can reproduce the model precisely from the stored data and penalty setting, a requirement that a neural network trained from random initialization would struggle to meet.