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.
| Component | Mathematical role | Typical machine learning meaning |
|---|---|---|
| Decision variables | Vector x being chosen | Model weights, biases or hyperparameters |
| Objective function | Scalar f(x) to minimize | Training loss, validation error or negative reward |
| Constraints | Equalities and inequalities on x | Norm bounds, budgets, fairness or capacity limits |
| Feasible region | All x meeting the constraints | Allowed models or configurations |
| Optimal solution | Feasible x with the lowest f(x) | Best trained model under the chosen criterion |
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 class | Defining structure | Typical solver | Example in AI |
|---|---|---|---|
| Linear programming | Linear objective and linear constraints | Simplex or interior-point method | Resource allocation, optimal transport |
| Quadratic programming | Quadratic objective, linear constraints | Active-set or interior-point method | Support vector machine training |
| Convex optimization | Convex objective and convex set | Proximal, Newton or interior-point method | Logistic regression, lasso |
| Non-convex optimization | Multiple local optima or saddle points | Stochastic gradient methods | Deep neural network training |
| Integer programming | Some or all variables are integers | Branch and bound, cutting planes | Scheduling, feature selection |
| Black-box optimization | No gradients, costly evaluations | Bayesian optimization, random search | Hyperparameter tuning |
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.
Algorithms and how they search
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.
| Family | Information used | Cost per iteration | Convergence behavior |
|---|---|---|---|
| Gradient descent and SGD | Gradient or minibatch gradient | Low, scales to billions of parameters | Slow but steady, sensitive to step size |
| Newton’s method | Gradient and Hessian | High, cubic in dimension | Quadratic near the optimum |
| Quasi-Newton such as L-BFGS | Gradient history approximating curvature | Moderate | Superlinear on smooth problems |
| Interior-point method | Barrier function and Newton steps | High per step, few steps | Polynomial time for convex problems |
| Metaheuristics | Function values with randomized moves | Low per move, many moves | No optimality guarantee |
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.
| Situation | Recommended approach | Reason |
|---|---|---|
| Millions of parameters, differentiable loss | Stochastic gradient methods | Cheap updates scale with data size |
| Small smooth convex problem | L-BFGS or Newton’s method | Fast, accurate convergence |
| Linear constraints and objective | Dedicated LP solver | Mature, certified optimal solutions |
| Discrete decisions with logic constraints | Mixed-integer solver | Handles integrality exactly |
| Each evaluation costs hours | Bayesian optimization | Spends few evaluations wisely |
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.