Lesson 0005

Stationarity Finds the Dual

When a portfolio cap blocks the objective, stationarity turns the objective's leftover slope into the cap's shadow price.

The One-Step Skill

You already know the active/inactive test: if the unconstrained target is past the cap, the solution sits on the cap and the dual is positive. The next skill is computing how positive.

Use this toy score for the weight in one asset:

score(w) = -(w - 0.80)^2
constraint: w <= 0.70
solution: w* = 0.70

The score still wants to move right at w* = 0.70. The cap says no. The dual variable measures the pressure needed to cancel that blocked push.

Derive the Pressure

The derivative of the score is:

score'(w) = -2(w - 0.80)

At the constrained solution:

score'(0.70) = -2(0.70 - 0.80)
             = 0.20

For a maximization problem with an upper bound w <= cap, stationarity says:

objective push - constraint pressure = 0
score'(w*) - lambda = 0
lambda = score'(w*) = 0.20
Memory hook: at an upper cap, a positive slope means the objective wants more weight. The cap's dual must be the same size, pushing back.

Try the Lab

Move the unconstrained target and cap. When the solution is on the cap, the displayed slope is the upper-bound dual. When the target is inside the cap, the solution is unconstrained and the dual falls to zero.

Stationarity Lab

The dashed line is the local slope at the chosen feasible point. A positive slope at the cap becomes positive shadow price.

objective curve forbidden region chosen feasible point
Target
Cap
Solution
Slope
Dual

Portfolio Reading

In a real Markowitz optimizer, the gradient has more terms: expected return, risk penalty, transaction cost, and maybe factor exposure. Stationarity is the same idea. At the solution, every active constraint contributes enough dual pressure to cancel any remaining objective push in forbidden directions.

This is why solver duals are useful diagnostics. A high dual on an asset cap means the model's local tradeoff wants more of that asset, after accounting for the objective and all other constraints.

Retrieval Practice

For score(w)=-(w-0.80)^2, what is score'(0.70)?

If the upper cap binds and the score slope is +0.20, what is the dual?

If the unconstrained target is 60% and the cap is 70%, what happens?

Primary Source

For the formal version, read the KKT sections in Boyd and Vandenberghe's Convex Optimization. To see the same idea in code, use the official CVXPY quadratic-program example, which shows dual values on constraints. Keep the stationarity reference open while reviewing this lesson.