Constrained optimization

Also known as: constrained minimization

On this page 7

Constrained optimization is the problem of minimizing or maximizing an objective function while the decision variables must satisfy equality and inequality constraints, so that only points inside a defined feasible region count as valid solutions. Optimization of this kind appears throughout artificial intelligence, from fairness-constrained classifiers and safe reinforcement learning to resource allocation, scheduling and the training of models under budgets on memory, latency or energy.

The standard form writes the task as minimize f(x) subject to g_i(x) ≤ 0 and h_j(x) = 0. Constraints change the character of the problem: the best point is often on the boundary of the feasible region rather than where the gradient vanishes, which is why constrained methods rely on Lagrange multipliers, projections, penalties or barriers instead of plain gradient descent.

How constraints reshape the search for an optimum

A constraint removes part of the search space, and the optimum of the remaining region is found where the objective cannot improve without violating an active constraint. At such a point the gradient of the objective is balanced by a weighted combination of the gradients of the active constraints. The weights are the Lagrange multipliers, and each one measures how much the optimal value would change if its constraint were relaxed slightly.

This balance is formalized by the Karush-Kuhn-Tucker conditions: stationarity of the Lagrangian, primal feasibility, dual feasibility (multipliers of inequality constraints are nonnegative) and complementary slackness, which states that an inactive constraint must carry a zero multiplier. For convex problems that satisfy a regularity condition such as Slater’s condition, the KKT conditions are both necessary and sufficient, so any point that satisfies them is a global optimum. For non-convex problems they only identify candidates, which may be local optima or saddle points.

The table below summarizes the main constraint types and how each one affects the geometry of the problem.

Constraint typeMathematical formEffect on feasible region
Bound constraintl ≤ x ≤ uBox-shaped region, cheap to project onto
Linear equalityAx = bRestricts search to an affine subspace
Linear inequalityAx ≤ bPolyhedron with flat faces and vertices
Convex nonlinear inequalityg(x) ≤ 0, g convexCurved but convex region
Nonlinear equalityh(x) = 0, h nonlinearCurved surface, usually non-convex
Integralityx integerDiscrete set of isolated points
Constraint types and their effect on the feasible region

Main problem classes in constrained optimization

The structure of the objective and the constraints determines which solver is appropriate and what guarantees it offers. Linear programming has a linear objective and linear constraints and can be solved reliably at very large scale. Quadratic programming adds a quadratic objective, which covers support vector machine training and portfolio problems. Nonlinear programming allows general smooth functions, while mixed-integer programming adds discrete variables and becomes NP-hard in general.

The following table compares these classes by difficulty and typical solution method.

Problem classTypical solverSolution guarantee
Linear programmingSimplex or interior-point methodGlobal optimum in polynomial time (interior point)
Convex quadratic programmingActive-set or interior-point methodGlobal optimum
Convex conic programmingInterior-point methodGlobal optimum to set tolerance
Nonlinear programmingSQP or augmented LagrangianLocal optimum only
Mixed-integer programmingBranch and bound with cutsGlobal optimum, worst-case exponential time
Problem classes and standard solvers

Algorithms for handling constraints

Constraint-handling algorithms fall into a few families, and the choice depends on problem size, smoothness and how strictly feasibility must hold during the iterations. In machine learning, large and noisy problems favor simple first-order methods, while engineering problems with dozens to thousands of variables often use second-order solvers with high accuracy.

  • Projected gradient descent takes a gradient step and then projects the point back onto the feasible set; it is efficient when the projection is cheap, as with boxes, simplices or norm balls.
  • Penalty methods add a term proportional to constraint violation to the objective; they are simple but become ill-conditioned as the penalty weight grows.
  • Augmented Lagrangian methods combine a penalty with multiplier estimates, which reaches feasibility without an infinite penalty weight; ADMM belongs to this family.
  • Barrier and interior-point methods keep iterates strictly inside the region with a logarithmic barrier and follow a central path toward the optimum.
  • Sequential quadratic programming solves a series of quadratic subproblems built from local models and is a standard choice for smooth nonlinear problems.

The table below matches each family to the situation where it performs best.

SituationRecommended methodReason
Simple set, millions of parametersProjected gradient descentProjection costs little per step
Constraints on expectations in learningLagrangian min-max trainingMultipliers adapt during training
Medium-size smooth convex problemInterior-point solverHigh accuracy in few iterations
Distributed or separable structureADMMSplits work across blocks or machines
Smooth nonlinear engineering modelSequential quadratic programmingFast local convergence
Discrete decisions presentBranch and bound solverHandles integrality exactly
Choosing a constraint-handling method

Constrained optimization in machine learning

In machine learning, constraints express requirements that a loss function alone cannot capture. Fairness constraints bound differences in error rates or positive rates across groups. Safe reinforcement learning formulates policies as constrained Markov decision processes, where the expected cost must stay below a threshold while reward is maximized. Norm constraints on weights act as regularization, and resource budgets limit model size or inference latency in neural architecture search.

Most of these settings use the Lagrangian relaxation as a min-max game: the model parameters minimize the Lagrangian while the multipliers rise when constraints are violated. This approach scales to deep networks, but the guarantee weakens: in a non-convex model the result usually satisfies constraints only approximately and on average, and constraint satisfaction measured on training data may not carry over to new data.

Limitations and common mistakes

The most frequent failure is treating a hard constraint as a soft penalty with an arbitrary weight, which yields solutions that are infeasible in deployment. Other problems arise from poor scaling, from infeasible formulations and from expecting global guarantees in non-convex settings.

  • Infeasible problems: conflicting constraints leave an empty region; solvers report infeasibility, and the fix is to diagnose which constraints conflict.
  • Poor scaling: variables and constraints with very different magnitudes slow convergence and cause numerical instability.
  • Degenerate constraints: redundant or nearly parallel constraints break regularity assumptions and destabilize multiplier estimates.
  • Non-convexity: local solvers return local optima, so multiple starting points or global methods are needed when quality matters.

The short version

Constrained optimization means finding the best option within fixed rules. You want the lowest cost or the highest score. But some choices are not allowed. A budget has a ceiling. A truck has a weight limit. A model must treat groups fairly.

The best allowed answer often sits right at the edge of the rules. Think of planning a trip with a fixed amount of money. The ideal hotel may be too expensive, so the best real choice is the best hotel you can afford. Solvers do the same thing with numbers, very quickly and at large scale.

Where it makes a difference

A lending team at a regional bank trains a credit-scoring model on about two million past applications. Unconstrained training produces good accuracy, but approval rates differ by nine percentage points between two demographic groups, which exceeds the internal fairness policy limit of three points.

The data scientists reformulate training as a constrained problem: minimize log loss subject to the approval-rate gap staying below three percentage points. They use a Lagrangian min-max procedure in which the multiplier increases whenever a training batch violates the limit. The final model meets the gap on a held-out validation set, at the cost of about one point of AUC. Because the constraint is explicit, the team can show auditors exactly which requirement the model satisfies and how much accuracy it cost.