Complementary slackness and sensitivity
Turn a duality gap into componentwise conditions and identify the range over which shadow prices remain valid.
On this page
The question for today
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 , and dual , , expand the gap as . 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.
Shadow prices have a validity region
Let be the optimal maximization value when only the resource vector changes and the other data remain fixed. Every dual feasible gives whenever the perturbed primal is feasible. If is optimal at , this becomes . 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 , while reduced costs remain unchanged because and 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.
Changing objective coefficients
Objective perturbations reverse the bookkeeping: a fixed basis keeps the same primal coordinates when and are unchanged, but its reduced costs change. For maximization, their required sign is nonpositive after eliminating the basic variables. Equivalently, solve for the basis price vector and check every inequality . 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.
Work it through
Compute a shadow-price range
For with , , and , find when both resource constraints remain an optimal active basis.
Solving the two equalities gives and . Both remain nonnegative exactly when .
The dual prices still satisfy , independently of the changed right-hand side. They are dual feasible throughout this range.
The primal value is , equal to the dual bound . Hence the first resource has marginal value one on the stated interval.
The affine prediction 9 + δ is exact for −1.5 ≤ δ ≤ 1. Outside that range this active-basis argument no longer certifies the optimum.
The living notebook
Explore the model
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.
- x component
- 1.393
- y component
- 0.975
- Magnitude
- 1.7
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.
Pause & reason
Check your understanding
Your turn
Try it yourself
In the worked model with , change the objective to . Find the interval of for which 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 and , then check the signs.
Compare with the solution
Subtracting gives and . Both are nonnegative exactly for . Their dual inequalities are equalities, so this feasible price vector certifies throughout that interval, including endpoints where alternate optima may occur.
Keep the idea
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.