Ma · Mathematics

How to Convert a Constrained Optimization Problem into an Unconstrained One

Published By the 9to5Science editorial team

At a glance

  1. 1. Identify constraints

    Separate equality constraints from inequalities and note whether the objective and constraints are linear or quadratic.

  2. 2. Parameterize equalities

    For feasible linear equalities, express every feasible point using free variables in the null space of the constraint matrix.

  3. 3. Substitute into objective

    Replace the original variables with the parameterization to obtain an unconstrained problem over the free variables.

  4. 4. Handle inequalities carefully

    Use an appropriate barrier, penalty, or active-set method; these approaches are not automatically equivalent at finite parameter values.

A constrained optimization problem asks you to minimize an objective only over points satisfying specified conditions. Whether you can turn it into an unconstrained problem depends on the type of constraints and on what “convert” means. For linear equality constraints, there is an exact method: describe the feasible set with free variables, then substitute that description into the objective. Penalty and barrier methods are useful too, but they have different guarantees.

Exact conversion for linear equality constraints

Consider the problem

min⁡xf(x)subject to Ax=b.\min_x f(x) \quad \text{subject to } Ax=b.

First find one feasible point xpx_p such that Axp=bAx_p=b. Next, find a matrix NN whose columns form a basis for the null space of AA, so AN=0AN=0. Every feasible point can then be written as

x=xp+Nz.x=x_p+Nz.

Here, zz is a vector of free variables. The equality constraint is satisfied automatically because

A(xp+Nz)=Axp+ANz=b.A(x_p+Nz)=Ax_p+ANz=b.

Substitute this expression into the objective. The original constrained problem is now the unconstrained problem

min⁡zf(xp+Nz).\min_z f(x_p+Nz).

This is an equivalent reformulation: its feasible choices of zz correspond exactly to feasible choices of xx in the original problem. If the equality constraints have rank rr and there are nn variables, the reduced problem has n−rn-r free variables.

For a quadratic objective with symmetric QQ,

f(x)=12xTQx+cTx,f(x)=\frac12 x^TQx+c^Tx,

the reduced objective is also quadratic:

f(xp+Nz)=12zT(NTQN)z+(NT(Qxp+c))Tz+f(xp).f(x_p+Nz)=\frac12 z^T(N^TQN)z + (N^T(Qx_p+c))^Tz + f(x_p).

The constant term f(xp)f(x_p) does not affect the minimizer, but it can be retained when you want the original objective value.

Worked example

Minimize x12+x22x_1^2+x_2^2 subject to x1+x2=1x_1+x_2=1. A feasible point is (1/2,1/2)(1/2,1/2), and a direction along the constraint line is (1,−1)(1,-1). Thus all feasible points have the form

(x1,x2)=(12+t,12−t),t∈R.(x_1,x_2)=\left(\frac12+t,\frac12-t\right), \qquad t\in\mathbb{R}.

Substitute into the objective:

f(t)=(12+t)2+(12−t)2=12+2t2.\begin{aligned} f(t)&=\left(\frac12+t\right)^2+\left(\frac12-t\right)^2\\ &=\frac12+2t^2. \end{aligned}

This is now an unconstrained one-variable problem. Its minimum occurs at t=0t=0, giving (x1,x2)=(1/2,1/2)(x_1,x_2)=(1/2,1/2) and objective value 1/21/2. The constraint has not been approximated; it is built into the parameterization.

Penalty functions: useful, but usually approximate

A common alternative is to add a penalty for constraint violation. For equality constraints, one choice is

min⁡xf(x)+ρ2∥Ax−b∥2,\min_x f(x)+\frac{\rho}{2}\lVert Ax-b\rVert^2,

where ρ>0\rho>0 controls the penalty strength. This is unconstrained, but for a finite ρ\rho its minimizer generally does not satisfy Ax=bAx=b exactly. Increasing ρ\rho discourages violations; under appropriate conditions, solutions approach solutions of the constrained problem as ρ\rho grows. Very large penalties can also make numerical calculations poorly conditioned.

For example, minimize x2x^2 subject to x=1x=1. The penalized objective is x2+ρ2(x−1)2x^2+\frac{\rho}{2}(x-1)^2. Differentiating and setting the derivative to zero gives

2x+ρ(x−1)=0,x=ρρ+2.2x+\rho(x-1)=0, \qquad x=\frac{\rho}{\rho+2}.

For every finite positive ρ\rho, this minimizer is less than 11, so it violates the original constraint. It approaches 11 as ρ\rho increases, but the penalty formulation is not exactly equivalent at finite ρ\rho.

Inequalities and the Lagrangian

Inequality constraints, such as gi(x)≤0g_i(x)\leq 0, need additional care. A logarithmic barrier, for example, adds terms such as −μlog⁡(−gi(x))-\mu\log(-g_i(x)) to the objective and keeps iterates inside the feasible region. Barrier methods generally solve a sequence of unconstrained problems as μ\mu changes; a single finite barrier parameter does not usually give the exact constrained solution. An active-set method instead identifies which inequalities hold with equality at the solution and treats those as equalities, while checking that the remaining inequalities are satisfied.

The Lagrangian for equality constraints is

L(x,λ)=f(x)+λT(Ax−b).L(x,\lambda)=f(x)+\lambda^T(Ax-b).

It is central to deriving optimality conditions, but simply minimizing LL jointly over xx and λ\lambda is not a valid general conversion: if Ax≠bAx\ne b, changing the unrestricted multiplier can make the Lagrangian arbitrarily small. Instead, the solution is characterized using a saddle point or the Karush–Kuhn–Tucker (KKT) conditions, when the required assumptions hold.

Common mistakes

  • Treating a penalty as exact. A finite quadratic penalty may leave a nonzero constraint residual.
  • Optimizing over multipliers as ordinary variables. Lagrange multipliers enforce stationarity and feasibility through saddle-point or KKT conditions; they are not usually extra variables in a plain minimization.
  • Assuming inequalities disappear by substitution. Parameterizing equalities does not remove inequalities that remain in the reduced variables.
  • Using an infeasible starting point for a parameterization. The expression x=xp+Nzx=x_p+Nz requires Axp=bAx_p=b. If no such xpx_p exists, the equality constraints are infeasible.

For a quadratic program with linear equalities, null-space parameterization is the direct exact route when you want an unconstrained problem. For inequalities, choose a method suited to the goal—such as an active-set, barrier, or penalty method—and account for its assumptions and approximation behavior.

References

  1. Convex Optimization, Stephen Boyd and Lieven Vandenberghe
  2. Numerical Optimization, Jorge Nocedal and Stephen J. Wright

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.