Nonlinear programming (NLP), also called nonlinear optimization, is the branch of mathematical optimization that minimizes or maximizes an objective function subject to constraints when the objective or at least one constraint is not a linear function of the decision variables. In artificial intelligence, it is the framework behind training models with smooth losses, fitting constrained estimators, tuning control policies and allocating resources under physical or budget limits.
A nonlinear program is usually written as minimizing f(x) subject to equality constraints h(x) = 0 and inequality constraints g(x) ≤ 0, with x a vector of continuous variables. Unlike linear programming, where the optimum always sits at a vertex of a polyhedron, a nonlinear problem can have curved feasible regions, interior optima and many local optima, which changes both the theory and the algorithms.
How a nonlinear program is structured
Every nonlinear program has three components: decision variables, an objective and a set of constraints that defines the feasible region. The problem is nonlinear as soon as one of these functions involves products, powers, exponentials, logarithms or other curved relationships between variables.
The geometry of the problem determines how hard it is. When the objective is convex and the feasible region is convex, the problem is a convex nonlinear program and every local optimum is global. When either part is non-convex, solvers can converge to a local optimum or a saddle point, and certifying global optimality generally becomes computationally hard.
The table below summarizes the main problem classes inside nonlinear programming and the guarantees each one offers.
| Problem class | Defining feature | Optimality guarantee |
|---|---|---|
| Unconstrained NLP | Smooth objective, no constraints | Local optimum from gradient methods |
| Convex NLP | Convex objective and convex feasible set | Any local optimum is global |
| Quadratic programming | Quadratic objective, linear constraints | Global if the Hessian is positive semidefinite |
| Non-convex NLP | Curved objective or non-convex constraints | Local optimum only, in general |
| Mixed-integer NLP | Some variables restricted to integers | Requires branch and bound or similar search |
Optimality conditions and the KKT system
The Karush-Kuhn-Tucker conditions are the first-order necessary conditions for a point to be a local optimum of a constrained nonlinear program. They extend the classical method of Lagrange multipliers to inequality constraints by requiring stationarity of the Lagrangian, primal feasibility, nonnegative multipliers on inequalities and complementary slackness.
Complementary slackness states that each inequality constraint is either active at the solution or carries a zero multiplier. The multiplier itself measures how much the optimal objective would improve if that constraint were relaxed slightly, which is why engineers read multipliers as shadow prices of scarce resources.
The KKT conditions hold only under a constraint qualification, such as linear independence of the active constraint gradients or the Slater condition for convex problems. Second-order conditions, based on the Hessian matrix of the Lagrangian restricted to feasible directions, separate true minima from saddle points and maxima.
Algorithms used to solve nonlinear programs
Nonlinear programming solvers are iterative methods that generate a sequence of improving points rather than a closed-form answer. They differ in how much derivative information they use, how they handle constraints and how they control step size through line search or trust regions.
The following table compares the algorithm families that practitioners meet most often in optimization work for AI and engineering.
| Method | Information used | Typical use |
|---|---|---|
| Gradient descent and variants | First derivatives | Large unconstrained losses such as neural networks |
| Newton’s method | Gradient and Hessian | Small to medium smooth problems needing fast convergence |
| Quasi-Newton (L-BFGS) | Gradients plus curvature estimates | Medium to large smooth problems |
| Sequential quadratic programming | Gradients, Hessian approximation | Constrained engineering design |
| Interior-point methods | Gradients, Hessian, barrier terms | Large constrained problems with many inequalities |
| Augmented Lagrangian and ADMM | Gradients and multiplier updates | Distributed or separable constrained problems |
Sequential quadratic programming solves a quadratic approximation of the problem at each iterate, while interior-point methods replace inequalities with logarithmic barrier terms and follow a central path toward the solution. Mature solvers such as IPOPT, SNOPT and KNITRO implement these ideas with careful scaling, globalization and automatic differentiation for derivatives.
Nonlinear programming compared with related problem types
Nonlinear programming sits between linear programming and fully combinatorial optimization. It keeps continuous variables but abandons linearity, so it inherits rich theory from calculus while losing the clean vertex structure that the simplex algorithm exploits.
| Problem type | Variables | Functions | Main difficulty |
|---|---|---|---|
| Linear programming | Continuous | All linear | Scale, degeneracy |
| Nonlinear programming | Continuous | At least one nonlinear | Local optima, curvature, scaling |
| Integer programming | Integer | Usually linear | Combinatorial explosion |
| Stochastic optimization | Continuous or discrete | Expected values over randomness | Noisy gradients and estimates |
In machine learning, most training problems are unconstrained or simply constrained non-convex programs solved with stochastic first-order methods. Classical NLP solvers remain essential where constraints are central: support vector machine training, constrained reinforcement learning, fairness-constrained models, optimal control and model predictive control.
Practical modeling and solver choices
The formulation often matters more than the solver. Reformulating a problem into a convex form, removing redundant constraints and scaling variables to similar magnitudes can turn an unstable model into one that converges in a few dozen iterations.
The decision table below links common situations to a reasonable first choice of approach.
| Situation | Recommended approach | Reason |
|---|---|---|
| Millions of parameters, few constraints | Stochastic gradient methods | Low cost per iteration |
| Smooth problem, thousands of variables | L-BFGS or trust region Newton | Fast convergence with modest memory |
| Many inequality constraints | Interior-point solver | Handles inequalities robustly at scale |
| Expensive black-box objective | Derivative-free or Bayesian methods | No reliable gradients available |
| Global optimum required, small model | Spatial branch and bound | Provides certified bounds |
Practitioners should supply exact derivatives whenever possible, since finite-difference approximations add noise and cost. They should also run multiple starting points on non-convex problems and compare the resulting objective values before trusting any single solution.
Limitations and common mistakes
The most serious limitation is that general non-convex problems are NP-hard, so no efficient algorithm guarantees the global optimum. A solver that reports success has usually found a point satisfying local optimality conditions, not proof of the best possible answer.
- Treating a local optimum as global without testing other starting points or bounds.
- Ignoring poor variable scaling, which produces ill-conditioned Hessians and stalled progress.
- Using nonsmooth functions such as absolute values or maximums without reformulation, which breaks gradient-based solvers.
- Setting tolerances too loose, which returns points that violate constraints in practice.
- Assuming that a convergence message means the model itself is correct.
Put simply
Nonlinear programming is a way to find the best choice under rules when the relationships involved are curved, not straight. Think of hiking in fog to find the lowest valley. You can feel the slope under your feet. You cannot see the whole landscape.
Some landscapes have one valley. Then any downhill path ends in the right place. Others have many valleys. A hiker may stop in a small one and miss a deeper one nearby. That is why the shape of the problem decides how much the answer can be trusted.
In practice
A data science team at a regional power utility builds a model to schedule battery storage across 40 substations for the next 24 hours. Each hour, the model decides how much energy to charge or discharge. Battery losses grow quadratically with current, and transformer temperatures depend nonlinearly on load, so the scheduling task is a nonlinear program with about 4,000 variables and several thousand constraints.
The team writes the model in an algebraic modeling language and solves it with an interior-point solver using exact derivatives from automatic differentiation. A typical run finishes in under a minute. Because the thermal constraints are non-convex, the team solves from five starting points and keeps the best feasible schedule. Compared with the earlier rule-based schedule, the optimized plan reduces peak transformer loading by roughly 8 percent while keeping every battery within its state-of-charge limits.