advanced22 min studyLesson 285 in Mathematics

Complementary slackness and sensitivity

Turn a duality gap into componentwise conditions and identify the range over which shadow prices remain valid.

On this page

What you’ll understand

  • Apply complementary slackness only after checking feasibility.
  • Interpret shadow prices as local value changes with explicit validity ranges.
  • Recompute a basis under right-hand-side and objective perturbations.

Dual variables often receive an economic interpretation as prices of scarce resources. That interpretation is useful only when its scope is clear. A resource can be tight and still have zero price, and a price valid for a small perturbation can fail after the optimal basis changes. Complementary slackness explains which constraints and activities support a certificate, while sensitivity analysis computes how long that explanation survives a change to the data.

Decompose the gap into nonnegative pieces

For the primal maximization form Ax≤bAx\le b, x≥0x\ge0 and dual ATy≥cA^Ty\ge c, y≥0y\ge0, expand the gap as yT(b−Ax)+xT(ATy−c)y^T(b-Ax)+x^T(A^Ty-c). Every summand is nonnegative at a feasible pair. Therefore a zero gap is equivalent to every product being zero. A positive dual price forces its resource constraint to be tight. A positive primal activity forces its corresponding dual inequality to be tight. These implications are one-way: a tight constraint need not carry a positive price, and an activity with zero reduced profit need not be used.

Complementary slackness is necessary and sufficient for optimality of a primal-dual feasible pair. Dropping the feasibility condition breaks the theorem because positive and negative terms could cancel or the proposed points could lie outside their domains. In practice one can guess the support of an optimizer, solve the resulting equalities for primal and dual variables, then verify all remaining signs and inequalities. This converts intuition about active resources into a rigorous certificate. If any sign check fails, the guessed support was not justified, even when the resulting objective looks attractive.

bTy−cTx=∑iyi(bi−aiTx)+∑jxj((ATy)j−cj)b^Ty-c^Tx=\sum_i y_i(b_i-a_i^Tx)+\sum_j x_j((A^Ty)_j-c_j)
At a feasible pair the terms are nonnegative, so a zero gap forces each complementary product to vanish.↔ Scroll wide equations horizontally.

Shadow prices have a validity region

Let v(b)v(b) be the optimal maximization value when only the resource vector changes and the other data remain fixed. Every dual feasible yy gives v(b′)≤b′Tyv(b')\le b'^Ty whenever the perturbed primal is feasible. If y∗y^* is optimal at bb, this becomes v(b′)≤v(b)+y∗T(b′−b)v(b')\le v(b)+y^{*T}(b'-b). Thus an optimal price is a supergradient of the concave value function on its feasible domain. Equality for a finite perturbation requires that the same dual certificate remain optimal; the bound alone does not promise a constant marginal price forever.

A convenient sufficient check uses a fixed standard-form basis. Right-hand-side perturbations change its basic coordinates to B−1(b+Δb)B^{-1}(b+\Delta b), while reduced costs remain unchanged because AA and cc do not change. If the old basis was dual feasible and the new basic vector stays nonnegative, it remains optimal. The new value is exactly affine over that basis's feasibility region. At its boundary a basic variable reaches zero; beyond it a different basis may take over, the model may become infeasible, or multiple prices may describe a kink.

v(b′)≤v(b)+y∗T(b′−b),xB(b′)=B−1b′≥0v(b')\le v(b)+y^{*T}(b'-b),\qquad x_B(b')=B^{-1}b'\ge0
The first statement is a global dual upper bound; the second, together with unchanged dual feasibility of the basis, identifies a region where the affine prediction is exact.↔ Scroll wide equations horizontally.

Changing objective coefficients

Objective perturbations reverse the bookkeeping: a fixed basis keeps the same primal coordinates when AA and bb are unchanged, but its reduced costs change. For maximization, their required sign is nonpositive after eliminating the basic variables. Equivalently, solve BTy=cBB^Ty=c_B for the basis price vector and check every inequality ANTy≥cNA_N^Ty\ge c_N. This gives inequalities in the perturbed cost coefficients. As long as they hold, the original feasible basis remains optimal. At equality, another activity may become competitive and alternate optima may appear.

Sensitivity reports should specify which parameters change jointly. Separate one-at-a-time allowable ranges cannot generally be combined into a rectangular region of simultaneous validity. Degeneracy can produce several optimal bases and several dual solutions; a solver's single reported price may describe only one supporting bound at a nondifferentiable value function. Units matter as well: a price is objective units per resource unit, so rescaling a constraint rescales its multiplier. These qualifications turn a solver printout into an interpretable model rather than a collection of apparently universal marginal values.

Compute a shadow-price range

For max⁡3x1+2x2\max 3x_1+2x_2 with x1+x2≤4+δx_1+x_2\le4+\delta, 2x1+x2≤52x_1+x_2\le5, and x≥0x\ge0, find when both resource constraints remain an optimal active basis.

  1. Solving the two equalities gives x1=1−δx_1=1-\delta and x2=3+2δx_2=3+2\delta. Both remain nonnegative exactly when −3/2≤δ≤1-3/2\le\delta\le1.

  2. The dual prices y=(1,1)y=(1,1) still satisfy ATy=(3,2)TA^Ty=(3,2)^T, independently of the changed right-hand side. They are dual feasible throughout this range.

  3. The primal value is 3(1−δ)+2(3+2δ)=9+δ3(1-\delta)+2(3+2\delta)=9+\delta, equal to the dual bound (4+δ)+5(4+\delta)+5. Hence the first resource has marginal value one on the stated interval.

The result

The affine prediction 9 + δ is exact for −1.5 ≤ δ ≤ 1. Outside that range this active-basis argument no longer certifies the optimum.

Explore the model

Interactive lab

Interactive lab · vectors

Resource prices depend on units

Pause and Reset, then set angle to 0 degrees and magnitude to 1. Predict x-projection one as a one-resource price. Reset and set angle to 0 and magnitude to 2; the projection doubles. If one new resource unit represents half an old unit, its numerical price should halve instead, so in another reset run set angle to 0 and magnitude to 0.5.

Resource prices depend on unitsPlayback traces a fixed vector and its projections. Angle and magnitude set the geometry; the moving marker does not change them. Current readings: x component: 1.393; y component: 0.975; Magnitude: 1.7. All parameters are adjustable with the labeled controls below.−7.46−3.7303.737.46−3.5−1.7501.753.5xyvvₓ = 1.39
Vectorx / y projectionsTrace marker
x component
1.393
y component
0.975
Magnitude
1.7
t = 0 s

Playback traces a fixed vector and its projections. Angle and magnitude set the geometry; the moving marker does not change them. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forThe projection makes price scaling visible. This vector instrument does not compute a parametric LP value function; the exact allowable perturbation interval comes from the basis inequalities in the worked example.

Check your understanding

At a primal-dual feasible optimal pair, a resource constraint is tight. Which assertion is always justified?

Try it yourself

In the worked model with δ=0\delta=0, change the objective to c1x1+2x2c_1x_1+2x_2. Find the interval of c1c_1 for which (1,3)(1,3) stays certified by nonnegative dual prices.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Both primal coordinates are positive, so impose y1+2y2=c1y_1+2y_2=c_1 and y1+y2=2y_1+y_2=2, then check the signs.

Compare with the solution

Subtracting gives y2=c1−2y_2=c_1-2 and y1=4−c1y_1=4-c_1. Both are nonnegative exactly for 2≤c1≤42\le c_1\le4. Their dual inequalities are equalities, so this feasible price vector certifies (1,3)(1,3) throughout that interval, including endpoints where alternate optima may occur.

Take it with you

  • Complementary slackness closes a nonnegative gap only at feasible pairs.
  • Shadow prices predict finite changes exactly only while a suitable certificate remains optimal.
  • Right-hand-side changes affect basic feasibility; cost changes affect reduced-cost feasibility.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.