Skip to content
All library documents

Hard Constraints, Soft Penalties, and Lagrangian Duality in Portfolio Optimization

Article Quant Q&A · Author: uday

Summary

The document compares constrained minimum-variance portfolio optimization with an unconstrained objective that penalizes deviations from a target return and linear exposure constraints. It explains that choosing penalty weights by hand can make the original objective dominate or become negligible, while hard constraints avoid that calibration but can make a problem infeasible or overly restrictive.

It connects the hard-constraint problem to Lagrangian duality: multipliers for equality constraints turn them into terms in an objective, and under convexity and an appropriate constraint qualification, the primal and dual problems have equal optimal values. The multipliers that achieve this relationship are determined through the dual optimization, rather than arbitrary penalty tuning. This addresses exact constraint enforcement; it does not prescribe suitable trade-offs when constraints are genuinely preferences. The source offers a conceptual explanation and references standard convex optimization texts, but provides no empirical portfolio comparison or practical calibration procedure for soft-constraint penalties.

Key ideas

  • Lagrange multipliers represent equality constraints as terms in an objective function.
  • Under convexity and Slater’s condition, the primal and dual problems have no duality gap.
  • Hard constraints can make a portfolio problem infeasible or overly restrictive.
  • Soft penalties require choices that determine the trade-off between portfolio risk and constraint violations.
  • Duality explains how selected multipliers can recover the hard-constrained solution, but does not decide the right preference trade-off.

Tags

Full text
# soft vs hard contraints in portfolio optimizations


# soft vs hard contraints in portfolio optimizations












Consider two sample portfolio optimizations:

Optimization 1: $\begin{matrix} \\ \min \frac{1}{2} w'\Sigma w \\ w'\mu = r \\ Aw = 0 \\ w_l \le w \le w_u \end{matrix}$

Optimization 2: $\begin{matrix} \\ \min \frac{1}{2} w'\Sigma w - \lambda_1 (w'\mu - r)^2 - \lambda_2 w'(A'A)w \\ w_l \le w \le w_u \end{matrix}$

In both cases (wherever applicable): $\begin{matrix} \\ w, w_l, w_u \in \mathbb{R}^{N\times 1} \\ \Sigma \in \mathbb{R}^{N \times N} \\ A \in \mathbb{R}^{m \times N} \\ r, \lambda_1, \lambda_2 \in \mathbb{R}^{1 \times 1} \end{matrix}$

Where $N$ is the number of instruments and $m$ is the number of constraints

Question - Calibration of $\lambda_1$ and $\lambda_2$

- In the first Optimization, which uses hard constraints, we don't have to calibrate any $\lambda_1$, $\lambda_2$, however there is a possibility that the optimization is infeasible, or the constraints are too binding (causing the optimal answer to be very poor compared to practically desired portfolios)

- In the second Optimization, the soft constraints can ensure the optimization is feasible and the constraints are also not overly binding if necessary, but it is not clear how to calibrate or set reasonable values of $\lambda_1$ or $\lambda_2$ so that there is a balance between the original objective function $w'\Sigma w$ and the penalties? Example, in this case, too small values of $\lambda_1$ and $\lambda_2$ will make the objective function equivalent to $w'\Sigma w$, and too large values will ignore the original objective function altogether.

Has this sort of problem been looked at before?

Does this sort of problem have a name?

Are there any papers or academic work related to this?

Any work that has evaluated such pros and cons in more detail?

## Answer by Matthew Gunn (score 2)

https://quant.stackexchange.com/a/36193

Your two problems are highly related. See perhaps Boyd and Vandenberghe Chapter 5 on Lagrangian duality.

Let $\mathcal{W} = \left\{ \mathbf{w}: \mathbf{w}_l \leq \mathbf{w} \leq \mathbf{w}_u \right\}$

Optimization 1: \begin{equation} \begin{array}{*2{>{\displaystyle}r}} \mbox{minimize (over $\mathbf{w}$)} & \frac{1}{2} \mathbf{w}'\Sigma\mathbf{w} \\ \mbox{subject to} & \mathbf{w}'\boldsymbol{\mu} = r \\ & A \mathbf{w} = \mathbf{0} \\ & \mathbf{w} \in \mathcal{W} \end{array} \end{equation}

Let me define an optimization problem 2b (similar to your optimization problem 2) to more closely match Lagrangian duality.

Optimization 2b: \begin{equation} \begin{array}{*2{>{\displaystyle}r}} \mbox{minimize (over $\mathbf{w}$)} & \frac{1}{2} \mathbf{w}'\Sigma\mathbf{w} + \lambda \left( \mathbf{w}'\boldsymbol{\mu} - r \right) + \mathbf{v}' A \mathbf{w} \\ \mbox{subject to} & \mathbf{w} \in \mathcal{W} \end{array} \end{equation}

#### Lagrangian duality

Problem 1 and problem 2b are highly related problems. Define the Lagragian function as:

$$ \mathcal{L}\left(\mathbf{w}, \lambda, \mathbf{v} \right) = \frac{1}{2} \mathbf{w}'\Sigma\mathbf{w} + \lambda \left( \mathbf{w}'\boldsymbol{\mu} - r \right) + \mathbf{v}' A \mathbf{w} $$

where scalar $\lambda$ and vector $\mathbf{v}$ are Lagrange multipliers.

Your optimization problem 1 is: $$\min_{\mathbf{w} \in \mathcal{W}} \max_{\lambda, \mathbf{v}} \mathcal{L}(\mathbf{w}, \lambda, \mathbf{v}) $$.

Min-max interpretation: First you pick $\mathbf{w}$ (to minimize the objective), and then (after observing your choice) I get to pick penalties $\lambda$ and $\mathbf{v}$ to maximize the objective. If you violate the constraints, I can choose arbitrarily large penalties so the objective is $\infty$!

This is a convex problem. If furthermore the feasible set has a non-empty relative interior then Slater's condition holds and then the duality gap is zero. We then have: $$\min_{\mathbf{w} \in \mathcal{W}} \max_{\lambda, \mathbf{v}} \mathcal{L}(\mathbf{w}, \lambda, \mathbf{v}) = \max_{\lambda, \mathbf{v}}\min_{\mathbf{w} \in \mathcal{W}} \mathcal{L}(\mathbf{w}, \lambda, \mathbf{v}) $$.

Interpretation: If the duality gap is zero (i.e. the saddle point property), then the order doesn't matter! The max of the min is the same as the min of the max. The primal problem (the left hand side) is the same as the dual problem (on the right hand side).

Define the Lagrangian dual function as:

$$ g(\lambda, \mathbf{v}) = \min_{w \in \mathcal{W}} \mathcal{L}(\mathbf{w}, \lambda, \mathbf{v}) $$

Note that the dual function is the value obtained from solving optimization problem 2b. The dual problem is known as:

$$ \max_{\lambda, \mathbf{v}} g(\lambda, \mathbf{v}) $$

#### Summary

Define the Lagrangian dual function $g(\lambda, \mathbf{v}$) as value obtained from solving optimization problem 2b. If Slater's condition holds, then your optimization problem 1 is equivalent to the dual problem $\max_{\lambda, \mathbf{v}} g( \lambda, \mathbf{v})$.

There exists a $\lambda^*$ and a $\mathbf{v}^*$ such that solving problem 2b gives the same answer as problem 1.

Perhaps the real issue (as I go into in the comments) is in carefully defining your problem. If constraints really are hard constraints, then you can't violate them period. End of story. Where you seem to be going though is that perhaps some of these constraints are more goals than requirements. What's the right penalty then for violating these soft constraints? I don't know?

#### References

Boyd, Stephen and Lieven Vandenberghe, Convex Optimization, 2004

Rockafellar, R. T., Conjugate Duality and Optimization, 1974

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.