Lesson 0006

Read Solver Duals

A solver's dual values are not decoration. They tell you which portfolio constraints are actually shaping the optimum.

The One-Step Skill

You can already compute the dual for one binding cap. Now practice the production version: read a small table of solver output and decide which constraints matter locally.

For each inequality constraint, read two numbers together:

slack = right side - left side
dual  = solver's multiplier for that inequality

The fast diagnostic is:

positive slack  -> inactive constraint -> dual should be near zero
near-zero slack -> active constraint   -> dual may be positive

Boyd and Vandenberghe call this complementary slackness: an inequality's multiplier is zero unless the constraint is tight. CVXPY exposes those multipliers through each constraint's dual_value field.

A Tiny Portfolio Solver Output

Imagine a long-only, fully invested portfolio optimizer. The expected-return estimate likes asset A, so the optimizer pushes A until a cap stops it.

Variables:
  w_A = 0.70
  w_B = 0.30

Constraints:
  w_A <= 0.70
  w_B <= 0.80
  w_A + w_B = 1.00

A cap

w_A = 0.70, cap 0.70, slack 0.00, dual 0.18.

B cap

w_B = 0.30, cap 0.80, slack 0.50, dual 0.00.

Budget

w_A + w_B = 1.00. This is equality-constrained, so its dual can have either sign.

The useful reading is not "A has a dual." It is more precise: the model wants more A at the solution, and the A cap is the active wall blocking that move. The B cap is loose, so relaxing it would not help locally.

Mind the Convention

Portfolio papers often write maximization problems, while CVXPY's quadratic-program example is written as a minimization problem. The economic reading is the same if you keep the direction straight.

maximize utility:
  positive upper-cap dual -> relaxing the cap can improve utility

minimize risk-adjusted cost:
  positive upper-cap dual -> tightening the cap can increase cost

Do not memorize the sign alone. Pair it with the problem direction, the inequality direction, and the slack.

Retrieval Practice

A cap has slack 0.42 and dual 0.00. What is the diagnosis?

A cap has slack 0.00 and dual 0.18. What should you inspect first?

In CVXPY, where do you read a solved constraint's multiplier?

Portfolio Reading

When reading a portfolio optimization paper or solver log, annotate each constraint with three labels: tight or loose, dual zero or nonzero, and economic meaning. A nonzero dual on a turnover constraint says trading friction is shaping the trade. A nonzero dual on a sector cap says the optimizer wants more exposure to that sector under the current objective.

Interview phrasing: "I would inspect the active constraints and their duals first, because they identify which modeling choices are binding and how much local objective value is attached to relaxing them."

Primary Source

Read the official CVXPY pages on dual variables and the quadratic-program example. For the formal condition behind the diagnostic, use chapter 5 of Boyd and Vandenberghe's Convex Optimization. Keep the solver dual diagnostics reference nearby.