Mathematical optimization

Also known as: mathematical programming · optimization problem

On this page 8

Mathematical optimization, also called mathematical programming, is the discipline of choosing the values of decision variables that minimize or maximize an objective function while satisfying a set of constraints. In artificial intelligence, optimization is the engine behind almost every learning method: training a neural network is the minimization of a loss function, fitting a support vector machine is a quadratic program, and selecting hyperparameters is an optimization over an expensive, noisy black box.

Every optimization problem has the same three ingredients: a search space, a scalar measure of quality and the rules that separate allowed solutions from forbidden ones. What changes from problem to problem is the structure of those ingredients, and that structure decides which algorithms apply, how fast they run and whether the answer can be proven optimal.

How an optimization problem is formulated

A mathematical optimization problem is written in a standard form: minimize f(x) subject to g_i(x) ≤ 0 and h_j(x) = 0, where x is a vector of decision variables. Maximization is handled by minimizing the negative of the objective, so one convention covers both cases. The set of points that satisfy all constraints is the feasible region, and a solution is optimal when no feasible point has a lower objective value.

The distinction between a local optimum and a global optimum is central. A local optimum is the best point within a small neighborhood, while a global optimum is the best point in the whole feasible region. Gradient-based methods only guarantee local optimality in general, which is why the shape of the problem matters as much as the algorithm.

The following table maps the formal components of a problem to their typical meaning in machine learning.

ComponentMathematical roleTypical machine learning meaning
Decision variablesVector x being chosenModel weights, biases or hyperparameters
Objective functionScalar f(x) to minimizeTraining loss, validation error or negative reward
ConstraintsEqualities and inequalities on xNorm bounds, budgets, fairness or capacity limits
Feasible regionAll x meeting the constraintsAllowed models or configurations
Optimal solutionFeasible x with the lowest f(x)Best trained model under the chosen criterion
Components of an optimization problem in machine learning

Main classes of optimization problems

Optimization problems are classified by the form of the objective, the constraints and the variables, because each class has its own theory and solver family. The most important dividing line is convexity: a convex problem has a convex objective over a convex feasible set, so every local optimum is also global. Non-convex problems, such as deep network training, offer no such guarantee.

The table below summarizes the classes that appear most often in artificial intelligence and operations research.

Problem classDefining structureTypical solverExample in AI
Linear programmingLinear objective and linear constraintsSimplex or interior-point methodResource allocation, optimal transport
Quadratic programmingQuadratic objective, linear constraintsActive-set or interior-point methodSupport vector machine training
Convex optimizationConvex objective and convex setProximal, Newton or interior-point methodLogistic regression, lasso
Non-convex optimizationMultiple local optima or saddle pointsStochastic gradient methodsDeep neural network training
Integer programmingSome or all variables are integersBranch and bound, cutting planesScheduling, feature selection
Black-box optimizationNo gradients, costly evaluationsBayesian optimization, random searchHyperparameter tuning
Common problem classes and their properties

Combinatorial optimization deals with discrete structures such as routes, assignments and subsets, where the number of candidates grows exponentially. Classic cases such as the traveling salesman problem are NP-hard, so practitioners combine exact solvers for small instances with metaheuristics such as simulated annealing for large ones.

Optimization algorithms differ mainly in how much information they use about the objective. First-order methods use only gradients, second-order methods also use curvature from the Hessian matrix, and derivative-free methods use only function values. More information usually means fewer iterations but more work per iteration.

The comparison below shows why first-order methods dominate large-scale machine learning while second-order methods remain popular for smaller, well-conditioned problems.

FamilyInformation usedCost per iterationConvergence behavior
Gradient descent and SGDGradient or minibatch gradientLow, scales to billions of parametersSlow but steady, sensitive to step size
Newton’s methodGradient and HessianHigh, cubic in dimensionQuadratic near the optimum
Quasi-Newton such as L-BFGSGradient history approximating curvatureModerateSuperlinear on smooth problems
Interior-point methodBarrier function and Newton stepsHigh per step, few stepsPolynomial time for convex problems
MetaheuristicsFunction values with randomized movesLow per move, many movesNo optimality guarantee
Algorithm families compared

Stochastic optimization replaces the exact gradient with a noisy estimate from a minibatch. This noise is not only a cost: in deep learning it helps the search escape sharp minima and saddle points, and adaptive variants such as Adam rescale each coordinate to cope with poorly scaled loss landscapes.

Optimality conditions and duality

Optimality conditions state what must hold at a solution, which lets solvers certify that they have finished. For unconstrained smooth problems, the gradient equals zero at any local optimum, and a positive definite Hessian confirms a strict local minimum. For constrained problems, the Karush-Kuhn-Tucker conditions generalize this rule with Lagrange multipliers attached to each constraint.

Lagrangian duality builds a second problem whose optimal value bounds the original one. The difference between the two values, the duality gap, is a practical stopping criterion: when it falls below a tolerance such as 1e-6, the solver can report a solution that is provably near-optimal. In convex problems that satisfy mild regularity assumptions, the gap closes to zero.

Choosing an approach in practice

The right approach follows from problem structure, scale and evaluation cost, not from algorithm popularity. A practitioner first asks whether the problem is convex, whether gradients are available and how many variables and evaluations the budget allows.

The decision table below captures common situations and the usual choice.

SituationRecommended approachReason
Millions of parameters, differentiable lossStochastic gradient methodsCheap updates scale with data size
Small smooth convex problemL-BFGS or Newton’s methodFast, accurate convergence
Linear constraints and objectiveDedicated LP solverMature, certified optimal solutions
Discrete decisions with logic constraintsMixed-integer solverHandles integrality exactly
Each evaluation costs hoursBayesian optimizationSpends few evaluations wisely
Decision guide for selecting a method

Limitations and common mistakes

Most failures come from a mismatch between the model and reality rather than from the solver. An optimizer will exploit any flaw in the objective, so a poorly specified loss produces a solution that is optimal on paper and useless in practice.

  • Optimizing the wrong objective: minimizing training loss alone invites overfitting, so validation metrics and regularization must guide the search.
  • Ignoring scaling: badly scaled variables create ill-conditioned problems on which gradient methods crawl.
  • Trusting a local optimum as global: in non-convex problems, restarts or problem reformulation are often necessary.
  • Loose tolerances: stopping too early yields unstable results, while very tight tolerances waste computation.
  • Assuming integer rounding is harmless: rounding a relaxed solution can break feasibility or degrade quality badly.

Explained without jargon

Mathematical optimization is the science of finding the best choice. You state what you want, such as the lowest cost or the smallest error. You also state the rules you must follow. A method then searches for the choice that does best within those rules.

Think of hiking down a foggy hill to reach the lowest valley. You cannot see far, so you feel the slope and step downhill. You may end up in a small dip instead of the deepest valley. That is why the shape of the landscape matters so much. AI systems learn in exactly this way, by stepping downhill on their error.

A typical use case

A logistics team at a regional grocery distributor plans daily deliveries from one warehouse to 140 stores with 22 refrigerated trucks. Each truck has a capacity of 18 pallets, each store has a delivery time window and drivers may not exceed a ten-hour shift. The team models this as a mixed-integer optimization problem, where binary variables decide which truck serves which store and in which order.

A commercial solver combined with a local search heuristic returns a plan within ten minutes, with a reported optimality gap of about 2 percent. Compared with the previous manually planned routes, the optimized plan uses three fewer trucks per day and cuts total driving distance by roughly 11 percent, while every time window and shift limit is respected. The same team uses Bayesian optimization to tune the heuristic’s parameters overnight.