Weight norm constraints: private API
PortfolioOptimisers.set_weight_norm_2_constraints! — Function
set_weight_norm_2_constraints!(model::JuMP.Model, val::Number; prefix::Symbol = Symbol(""))
set_weight_norm_2_constraints!(model::JuMP.Model, ::Nothing; prefix::Symbol = Symbol(""))Bound the 2-norm of the weights above by val, a ceiling that spreads the portfolio over more assets as it falls.
The row multiplies val by the homogenisation variable k, so the ceiling holds on the weights the result reports: on $\boldsymbol{w} / k$ under MaximumRatio, on the renormalised weights under RiskBudgeting, and on $\boldsymbol{w}$ itself under every other objective, where $k = 1$. The budget does not scale the ceiling. The builder takes a number. The caller-facing slot also takes an AbstractNormCeilingCalibrationAlgorithm, which computes the ceiling from the universe the prior result carries, and the stage 2 of the constraint block, resolve_constraint_block, resolves it before the library builds the model. nothing adds nothing to the model. Any other type or arity is a MethodError.
Mathematical definition
\[\begin{align} \lVert \boldsymbol{w} \rVert_{2} &\leq \mathrm{val} \cdot k\,. \end{align}\]
For reported weights that sum to one, the ceiling is a floor on the effective number of assets, and val = 1 / sqrt(m) states the floor $m$:
\[\begin{align} \lVert \boldsymbol{w} \rVert_{2} \leq \frac{1}{\sqrt{m}} &\iff \mathrm{ENA}_{2}(\boldsymbol{w}) \geq m\,. \end{align}\]
Weights that sum to one have $\lVert \boldsymbol{w} \rVert_{2} \geq 1 / \sqrt{N}$, with equality at equal weights. A ceiling below $1 / \sqrt{N}$ admits none of them, and the model is infeasible.
Where:
- $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
- $k$: Variable that scales the budget in the homogenised problem.
- $\mathrm{val}$: Ceiling on the 2-norm of the weights.
- $\mathrm{ENA}_{p}(\boldsymbol{w}) = \lVert \boldsymbol{w} \rVert_{p}^{p/(1 - p)}$: Effective number of assets of order $p$, for weights that sum to one. It is $m$ on $m$ equal weights. $\mathrm{ENA}_{2}(\boldsymbol{w}) = 1 / \lVert \boldsymbol{w} \rVert_{2}^{2}$ is
number_effective_assetson weights whose absolute values sum to one, and $\mathrm{ENA}_{\infty}(\boldsymbol{w}) = 1 / \lVert \boldsymbol{w} \rVert_{\infty}$. - $m$: Floor on the effective number of assets.
- $N$: Number of assets.
JuMP formulation
Variables
w: read. The portfolio weights.k: read. The homogenisation variable.l2c: created. The epigraph $t$ of the 2-norm.
Constraints
cl2c_soc: $(s_c t, s_c \boldsymbol{w}) \in \mathcal{K}_{2}$, that is $t \geq \lVert \boldsymbol{w} \rVert_{2}$.cl2c: $s_c (t - \mathrm{val} \cdot k) \leq 0$.
Where:
- $s_c$: Constraint scale. It multiplies both sides of a row, so a positive value leaves the feasible set unchanged.
- $\mathcal{K}_{q} = \{(t, \boldsymbol{x}) : t \geq \lVert \boldsymbol{x} \rVert_{q}\}$: Norm cone of order $q$. $\mathcal{K}_{2}$ is the second-order cone.
Arguments
model::JuMP.Model: The JuMP optimisation model.val::Number: Ceiling on the 2-norm of the weights.resolve_constraint_blockchecks that it is finite and> 0, so the builder checks nothing.prefix::Symbol = Symbol(""): Model State namespace of the call. The builder reads the weights under it, and every entry that it registers takes it, so two calls under two prefixes add two sets of rows to one model. The empty default gives the bare names.
Returns
nothing.
Related
set_weight_norm_p_constraints!set_weight_norm_inf_constraints!Num_NormCeilCalresolve_calibration_slotnumber_effective_assetsJuMPOptimiser
References
- [198] M. S. Lobo, L. Vandenberghe, S. Boyd and H. Lebret. Applications of second-order cone programming. Linear Algebra and its Applications 284, 193–228 (1998). Section 1.1.
PortfolioOptimisers.set_weight_norm_p_constraints! — Function
set_weight_norm_p_constraints!(model::JuMP.Model, lps::LpReg_VecLpReg; prefix::Symbol = Symbol(""))
set_weight_norm_p_constraints!(model::JuMP.Model, ::Nothing; prefix::Symbol = Symbol(""))Bound the $p$-norm of the weights above, once for each term of lps.
Each term is an LpRegularisation that serves as a ceiling: its p field is the norm order, and its val field is the ceiling. The row multiplies val by the homogenisation variable k, so the ceiling holds on the weights the result reports, as in set_weight_norm_2_constraints!. norm_ceiling_factory refuses an AbstractAmbiguityRadiusCalibrationAlgorithm in val, resolves an AbstractNormCeilingCalibrationAlgorithm against the prior result with the term's own norm order, and rebuilds the term. Every val this builder sees is therefore a number that the constructor of LpRegularisation checked. The entries carry names apart from those of set_lp_regularisation!, so a model can carry an Lp penalty and a $p$-norm ceiling at once. nothing adds nothing to the model. Any other type or arity is a MethodError.
Mathematical definition
\[\begin{align} \lVert \boldsymbol{w} \rVert_{p_i} &\leq \mathrm{val}_i \cdot k\,, \quad i = 1, \ldots, n\,. \end{align}\]
For reported weights that sum to one, each ceiling is a floor on the effective number of assets of order $p_i$, and $\mathrm{val}_i = m^{1/p_i - 1}$ states the floor $m$:
\[\begin{align} \lVert \boldsymbol{w} \rVert_{p} \leq m^{1/p - 1} &\iff \mathrm{ENA}_{p}(\boldsymbol{w}) \geq m\,. \end{align}\]
The exponent $1/p - 1$ tends to $-1$ as $p$ grows, which gives the ceiling $1 / m$ of set_weight_norm_inf_constraints!. Weights that sum to one have $\lVert \boldsymbol{w} \rVert_{p} \geq N^{1/p - 1}$, with equality at equal weights. A ceiling below $N^{1/p - 1}$ admits none of them, and the model is infeasible.
Where:
- $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
- $k$: Variable that scales the budget in the homogenised problem.
- $p_i > 1$: Norm order of the $i$-th term, its
pfield. - $\mathrm{val}_i$: Ceiling of the $i$-th term, its
valfield. - $n$: Number of terms in
lps. - $\mathrm{ENA}_{p}(\boldsymbol{w}) = \lVert \boldsymbol{w} \rVert_{p}^{p/(1 - p)}$: Effective number of assets of order $p$, for weights that sum to one. It is $m$ on $m$ equal weights. $\mathrm{ENA}_{2}(\boldsymbol{w}) = 1 / \lVert \boldsymbol{w} \rVert_{2}^{2}$ is
number_effective_assetson weights whose absolute values sum to one, and $\mathrm{ENA}_{\infty}(\boldsymbol{w}) = 1 / \lVert \boldsymbol{w} \rVert_{\infty}$. - $m$: Floor on the effective number of assets.
- $N$: Number of assets.
JuMP formulation
Variables
w: read. The portfolio weights.k: read. The homogenisation variable.t_lpc_i: created. The epigraph $t_i$ of the $p_i$-norm.r_lpc_i: created. The $N$ auxiliaries $r_{i,j}$ of the $i$-th term, one for each asset.
Constraints
clpc_i: $(s_c r_{i,j}, s_c t_i, s_c w_j) \in \mathcal{P}_{1/p_i}$ for $j = 1, \ldots, N$, that is $r_{i,j} \geq \lvert w_j \rvert^{p_i} / t_i^{p_i - 1}$.cslpc_i: $s_c \left(\sum_{j} r_{i,j} - t_i\right) = 0$. With the rows ofclpc_i, it gives $t_i^{p_i} \geq \sum_{j} \lvert w_j \rvert^{p_i}$, that is $t_i \geq \lVert \boldsymbol{w} \rVert_{p_i}$.clpc_bnd_i: $s_c (t_i - \mathrm{val}_i \cdot k) \leq 0$.
Where:
- $s_c$: Constraint scale. It multiplies both sides of a row, so a positive value leaves the feasible set unchanged.
- $\mathcal{P}_{\alpha} = \{(x, y, z) : x^{\alpha} y^{1 - \alpha} \geq \lvert z \rvert,\ x \geq 0,\ y \geq 0\}$: Power cone of exponent $\alpha \in (0, 1)$, in the argument order of
MOI.PowerCone.
Arguments
model::JuMP.Model: The JuMP optimisation model.lps::LpReg_VecLpReg: One or more $p$-norm ceilings.prefix::Symbol = Symbol(""): Model State namespace of the call. The builder reads the weights under it, and every entry that it registers takes it, so two calls under two prefixes add two sets of rows to one model. The empty default gives the bare names.
Returns
nothing.
Related
LpRegularisationLpReg_VecLpRegset_weight_norm_2_constraints!set_weight_norm_inf_constraints!norm_ceiling_factoryassert_norm_ceiling_roleNum_NormCeilCalset_lp_regularisation!: the Lp penalty that the same estimator states in thelpfield.JuMPOptimiser
References
- [206] P. R. Chares. Cones and interior-point algorithms for structured convex optimization involving powers and exponentials. Ph.D. Thesis, Université catholique de Louvain, Louvain-la-Neuve, Belgium (2009). Section 4.1.2, Equations 4.4 and 4.5.
PortfolioOptimisers.set_weight_norm_inf_constraints! — Function
set_weight_norm_inf_constraints!(model::JuMP.Model, val::Number; prefix::Symbol = Symbol(""))
set_weight_norm_inf_constraints!(model::JuMP.Model, ::Nothing; prefix::Symbol = Symbol(""))Bound the largest absolute weight above by val, the ∞-norm ceiling of the weights.
The row multiplies val by the homogenisation variable k, so the ceiling holds on the weights the result reports, as in set_weight_norm_2_constraints!. So val = 0.2 keeps each reported weight within 20% of a portfolio that sums to one. The builder takes a number. The caller-facing slot also takes an AbstractNormCeilingCalibrationAlgorithm, which computes the ceiling from the universe the prior result carries, and the stage 2 of the constraint block, resolve_constraint_block, resolves it before the library builds the model. nothing adds nothing to the model. Any other type or arity is a MethodError.
Mathematical definition
\[\begin{align} \lVert \boldsymbol{w} \rVert_{\infty} &\leq \mathrm{val} \cdot k\,. \end{align}\]
For reported weights that sum to one, val = 1 / m states the floor $m$ on the effective number of assets of order $\infty$:
\[\begin{align} \lVert \boldsymbol{w} \rVert_{\infty} \leq \frac{1}{m} &\iff \mathrm{ENA}_{\infty}(\boldsymbol{w}) \geq m\,. \end{align}\]
At least $m$ of those weights are then non-zero, because $n$ non-zero weights that sum to one have $1 \leq n \lVert \boldsymbol{w} \rVert_{\infty}$. Weights that sum to one have $\lVert \boldsymbol{w} \rVert_{\infty} \geq 1 / N$, with equality at equal weights. A ceiling below $1 / N$ admits none of them, and the model is infeasible.
Where:
- $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
- $k$: Variable that scales the budget in the homogenised problem.
- $\mathrm{val}$: Ceiling on the largest absolute weight.
- $\mathrm{ENA}_{p}(\boldsymbol{w}) = \lVert \boldsymbol{w} \rVert_{p}^{p/(1 - p)}$: Effective number of assets of order $p$, for weights that sum to one. It is $m$ on $m$ equal weights. $\mathrm{ENA}_{2}(\boldsymbol{w}) = 1 / \lVert \boldsymbol{w} \rVert_{2}^{2}$ is
number_effective_assetson weights whose absolute values sum to one, and $\mathrm{ENA}_{\infty}(\boldsymbol{w}) = 1 / \lVert \boldsymbol{w} \rVert_{\infty}$. - $m$: Floor on the effective number of assets.
- $n$: Number of non-zero weights.
- $N$: Number of assets.
JuMP formulation
Variables
w: read. The portfolio weights.k: read. The homogenisation variable.t_linfc: created. The epigraph $t$ of the ∞-norm.
Constraints
clinfc_nic: $(s_c t, s_c \boldsymbol{w}) \in \mathcal{K}_{\infty}$, that is $t \geq \lVert \boldsymbol{w} \rVert_{\infty}$.clinfc: $s_c (t - \mathrm{val} \cdot k) \leq 0$.
Where:
- $s_c$: Constraint scale. It multiplies both sides of a row, so a positive value leaves the feasible set unchanged.
- $\mathcal{K}_{q} = \{(t, \boldsymbol{x}) : t \geq \lVert \boldsymbol{x} \rVert_{q}\}$: Norm cone of order $q$. $\mathcal{K}_{2}$ is the second-order cone.
Arguments
model::JuMP.Model: The JuMP optimisation model.val::Number: Ceiling on the largest absolute weight.resolve_constraint_blockchecks that it is finite and> 0, so the builder checks nothing.prefix::Symbol = Symbol(""): Model State namespace of the call. The builder reads the weights under it, and every entry that it registers takes it, so two calls under two prefixes add two sets of rows to one model. The empty default gives the bare names.
Returns
nothing.
Related
set_weight_norm_2_constraints!set_weight_norm_p_constraints!Num_NormCeilCalresolve_calibration_slotset_linf_regularisation!: the ∞-norm penalty on the weights.JuMPOptimiser
PortfolioOptimisers.norm_epigraph! — Function
norm_epigraph!(model::JuMP.Model, t, x, p::Number, sc::Number)Adds the rows that bound the p-norm of x by t, $t \geq \lVert \boldsymbol{x} \rVert_p$, scaled by sc, and returns them.
The order picks the cone. At $p = 1$, $p = 2$ and $p = \infty$ it is the cone of the norm. At every other order it is one power cone for each entry of x, and one row that sums the auxiliary variables. It is the one epigraph of a norm in the library, so that set_norm_error_epigraph!, norm_ball_dual_norm_epigraph! and the path budget of BudgetedHindsightPath write the same rows. It registers no name. A caller that names the rows stores what it returns.
JuMP formulation
Variables
t: read. It is the caller's epigraph variable.r: created at an order other than1,2andInf, an anonymous vector of one variable for each entry ofx.
Constraints
Every row is registered under no name.
cone: $(s_c t,\, s_c \boldsymbol{x}) \in \mathcal{K}_{p}$ for $p \in \{1, 2, \infty\}$. At every other order it holds one row for each entry ofx, $(s_c r_j,\, s_c t,\, s_c x_j) \in \mathcal{P}_{1/p}$, that is $r_j \geq \lvert x_j \rvert^{p} / t^{p - 1}$.csum: $s_c \left(\sum_{j} r_j - t\right) = 0$, at an order other than1,2andInf. With the rows ofcone, it gives $t^{p} \geq \sum_{j} \lvert x_j \rvert^{p}$.
Where:
- $t$: Epigraph of the norm.
- $\boldsymbol{x}$: The affine expression whose norm is bounded, with entries $x_j$.
- $p$: Norm order.
- $r_j$: Auxiliary variable of entry $j$.
- $s_c$: Constraint scale. It multiplies both sides of a row, so a positive value leaves the feasible set unchanged.
- $\mathcal{K}_{q} = \{(t, \boldsymbol{x}) : t \geq \lVert \boldsymbol{x} \rVert_{q}\}$: Norm cone of order $q$. $\mathcal{K}_{2}$ is the second-order cone.
- $\mathcal{P}_{\alpha} = \{(x, y, z) : x^{\alpha} y^{1 - \alpha} \geq \lvert z \rvert,\ x \geq 0,\ y \geq 0\}$: Power cone of exponent $\alpha \in (0, 1)$, in the argument order of
MOI.PowerCone.
Arguments
model::JuMP.Model: The JuMP optimisation model.t: The epigraph variable.x: Affine expression, a vector of at least one entry.p: The norm order,1 <= p, withInfadmitted.sc: The constraint scale. A model with no registered scale passes1.
Returns
(cone, csum, r): The cone row or rows, the sum row and the auxiliary variables.csumandrarenothingat $p \in \{1, 2, \infty\}$.
Related
PortfolioOptimisers.norm_ball_dual_norm_epigraph! — Function
norm_ball_dual_norm_epigraph!(model::JuMP.Model, prefix::Symbol, i, x, p::Number)Register an epigraph variable of the dual norm of x, and bound it below by that norm.
The dual order $q$ picks the cone, and norm_epigraph! writes the rows. At $q = 2$ it is the second-order cone, as in set_weight_norm_2_constraints!. At $q = 1$ ($p = \infty$) it is the norm-one cone, as in set_l1_regularisation!. At $q = \infty$ ($p = 1$) it is the norm-infinity cone, as in set_weight_norm_inf_constraints!. At every other order it is one power cone for each entry of x, as in set_weight_norm_p_constraints!. The two norm-ball consumers call it, the mean builder on $\mathbf{L}^{\intercal}\boldsymbol{w}$ and the covariance builder on $\mathbf{L}^{\intercal}\operatorname{vec}(\mathbf{W} + \mathbf{E})$, so it takes prefix and i and registers every entry under both. A model can carry a set on each axis, and then both builders share one prefix, so the mean builder passes the index w_i and the covariance builder the index i. The variable equals the dual norm only where the caller's objective pulls it down.
Mathematical definition
\[\begin{align} t &\geq \lVert \boldsymbol{x} \rVert_{q}\,, \\ q &= \frac{p}{p - 1}\,. \end{align}\]
The dual order is $q = 1$ at $p = \infty$, and $q = \infty$ at $p = 1$.
Where:
- $t$: Epigraph of the dual norm.
- $\boldsymbol{x}$: The affine expression whose dual norm is bounded.
- $p$: Norm order of the ball.
- $q$: Dual norm order of $p$.
JuMP formulation
Variables
t_nbucs_i: created, underprefix. The epigraph $t$.r_nbucs_i: created, underprefix, on the power-cone route only. One auxiliary $r_j$ for each entry ofx.
Constraints
nbucs_cone_i: $(s_c t, s_c \boldsymbol{x}) \in \mathcal{K}_{q}$ for $q \in \{1, 2, \infty\}$. On the power-cone route it holds one row for each entry ofx, $(s_c r_j, s_c t, s_c x_j) \in \mathcal{P}_{1/q}$, that is $r_j \geq \lvert x_j \rvert^{q} / t^{q - 1}$.nbucs_cone_sum_i: $s_c \left(\sum_{j} r_j - t\right) = 0$, on the power-cone route only. With the rows ofnbucs_cone_i, it gives $t^{q} \geq \sum_{j} \lvert x_j \rvert^{q}$.
Where:
- $s_c$: Constraint scale. It multiplies both sides of a row, so a positive value leaves the feasible set unchanged.
- $\mathcal{K}_{q} = \{(t, \boldsymbol{x}) : t \geq \lVert \boldsymbol{x} \rVert_{q}\}$: Norm cone of order $q$. $\mathcal{K}_{2}$ is the second-order cone.
- $\mathcal{P}_{\alpha} = \{(x, y, z) : x^{\alpha} y^{1 - \alpha} \geq \lvert z \rvert,\ x \geq 0,\ y \geq 0\}$: Power cone of exponent $\alpha \in (0, 1)$, in the argument order of
MOI.PowerCone.
Arguments
model::JuMP.Model: The JuMP optimisation model.prefix: Model State prefix that the entries are registered under.i: Index of the term, which suffixes every name that the builder registers. The mean builder passesSymbol(:w_, i), so its names differ from those of the covariance builder.x: Affine expression, a vector of at least one entry.p::Number: Norm order of the ball,p >= 1, withInfadmitted.
Returns
t_nbucs: The epigraph variable.
Related
NormBallUncertaintySetdual_norm_ordernorm_epigraph!set_ucs_return_constraints!set_ucs_variance_risk!
References
- [198] M. S. Lobo, L. Vandenberghe, S. Boyd and H. Lebret. Applications of second-order cone programming. Linear Algebra and its Applications 284, 193–228 (1998). Section 1.1.
- [206] P. R. Chares. Cones and interior-point algorithms for structured convex optimization involving powers and exponentials. Ph.D. Thesis, Université catholique de Louvain, Louvain-la-Neuve, Belgium (2009). Section 4.1.2, Equations 4.4 and 4.5.
References
- [198]
- M. S. Lobo, L. Vandenberghe, S. Boyd and H. Lebret. Applications of Second-Order Cone Programming. Linear Algebra and its Applications 284, 193–228 (1998).
- [206]
- P. R. Chares. Cones and Interior-Point Algorithms for Structured Convex Optimization Involving Powers and Exponentials. Ph.D. Thesis, Université catholique de Louvain (Louvain-la-Neuve, Belgium, 2009).