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 type | Mathematical form | Effect on feasible region |
|---|---|---|
| Bound constraint | l ≤ x ≤ u | Box-shaped region, cheap to project onto |
| Linear equality | Ax = b | Restricts search to an affine subspace |
| Linear inequality | Ax ≤ b | Polyhedron with flat faces and vertices |
| Convex nonlinear inequality | g(x) ≤ 0, g convex | Curved but convex region |
| Nonlinear equality | h(x) = 0, h nonlinear | Curved surface, usually non-convex |
| Integrality | x integer | Discrete set of isolated points |
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 class | Typical solver | Solution guarantee |
|---|---|---|
| Linear programming | Simplex or interior-point method | Global optimum in polynomial time (interior point) |
| Convex quadratic programming | Active-set or interior-point method | Global optimum |
| Convex conic programming | Interior-point method | Global optimum to set tolerance |
| Nonlinear programming | SQP or augmented Lagrangian | Local optimum only |
| Mixed-integer programming | Branch and bound with cuts | Global optimum, worst-case exponential time |
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.
| Situation | Recommended method | Reason |
|---|---|---|
| Simple set, millions of parameters | Projected gradient descent | Projection costs little per step |
| Constraints on expectations in learning | Lagrangian min-max training | Multipliers adapt during training |
| Medium-size smooth convex problem | Interior-point solver | High accuracy in few iterations |
| Distributed or separable structure | ADMM | Splits work across blocks or machines |
| Smooth nonlinear engineering model | Sequential quadratic programming | Fast local convergence |
| Discrete decisions present | Branch and bound solver | Handles integrality exactly |
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.