OWA risk measures constraints
The methods below are public. The other names of this topic are private, and the private page documents them.
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::OrderedWeightsArray{<:Any, <:Any, <:ExactOrderedWeightsArray},
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
pr::AbstractPriorResult,
args...;
prefix,
kwargs...
) -> Any
Add Ordered Weights Array (OWA) risk constraints to model using the exact formulation.
The exact formulation is the linear programme that is dual to the assignment problem which sorts the sample. It adds two T × 1 auxiliary variables and one T × T block of linear constraints, and the risk is the sum of the two auxiliary variables. The block costs $T^{2}$ constraints. For a long sample, SortingNetworkOrderedWeightsArray gives the same exact risk at $O(T \log^{2} T)$ rows.
The programme pairs the largest weight with the largest sorted return, so it attains $\mathrm{sort}(\boldsymbol{\omega})^{\intercal} \mathrm{sort}(\hat{\boldsymbol{r}})$. This equals the OWA risk when, and only when, $\boldsymbol{\omega}$ is monotonic non-decreasing, which is also the condition for the risk measure to be convex. Every weight builder in this package returns such a vector.
Mathematical definition
\[\begin{align} \hat{r}_{t} &= \boldsymbol{x}_{t}^{\intercal} \boldsymbol{w}\\ \mathrm{OWA}(\boldsymbol{w}) &= \boldsymbol{\omega}^{\intercal} \mathrm{sort}\left(\hat{\boldsymbol{r}}\right)\\ &= \begin{cases} \underset{\boldsymbol{a},\, \boldsymbol{b}}{\min} & \sum\limits_{t=1}^{T} \left(a_{t} + b_{t}\right)\\ \text{s.t.} & \hat{r}_{i} \omega_{j} - a_{j} - b_{i} \leq 0 \quad \forall i,\, j = 1,\, \ldots,\, T\,. \end{cases} \end{align}\]
Where:
- $\mathrm{OWA}(\boldsymbol{w})$: Is the ordered weighted average risk of the portfolio.
- $\boldsymbol{\omega}$: Is the OWA weight vector,
r.wif it is a vector,r.w(T)if it is a callable. - $\hat{\boldsymbol{r}}$: Is the vector of net portfolio returns, which $\mathrm{sort}$ places in ascending order.
- $\boldsymbol{x}_{t}$: Is the
N × 1vector of asset returns at time $t$. - $\boldsymbol{w}$: Is the
N × 1vector of portfolio weights. - $\boldsymbol{a},\, \boldsymbol{b}$: Are the two
T × 1auxiliary variables of the assignment dual. - $T$: Is the total number of observations.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::OrderedWeightsArray{<:Any, <:Any, <:ExactOrderedWeightsArray}: The OWA risk measure with the exact formulation.opt::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr::AbstractPriorResult: Prior result containing the returns matrixX.
Validation
- The weight vector has one entry for each observation, through
owa_weights. Raises aDimensionMismatch.
Keyword arguments
prefix::Symbol: Model State namespace (default: empty, i.e. the bare key).
Returns
owa_risk: The OWA risk expression added to the model.
Related
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::OrderedWeightsArrayRange{<:Any, <:Any, <:Any, <:ExactOrderedWeightsArray},
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
pr::AbstractPriorResult,
args...;
prefix,
kwargs...
) -> Any
Add JuMP risk constraints for OrderedWeightsArrayRange using the exact OWA formulation to model.
The exact formulation fuses the two tails rather than duplicating them. It forms the single weight vector $\boldsymbol{\omega}_{1} - \boldsymbol{\omega}_{2}$ and builds one assignment dual over it, so the range costs the same T × T block as a single tail. OrderedWeightsArrayRange holds r.w2 reversed, so the difference is the range weight vector.
Mathematical definition
\[\begin{align} \hat{r}_{t} &= \boldsymbol{x}_{t}^{\intercal} \boldsymbol{w}\\ \boldsymbol{\omega} &= \boldsymbol{\omega}_{1} - \boldsymbol{\omega}_{2}\\ \mathrm{OWA}_{\mathrm{rg}}(\boldsymbol{w}) &= \boldsymbol{\omega}^{\intercal} \mathrm{sort}\left(\hat{\boldsymbol{r}}\right)\\ &= \begin{cases} \underset{\boldsymbol{a},\, \boldsymbol{b}}{\min} & \sum\limits_{t=1}^{T} \left(a_{t} + b_{t}\right)\\ \text{s.t.} & \hat{r}_{i} \omega_{j} - a_{j} - b_{i} \leq 0 \quad \forall i,\, j = 1,\, \ldots,\, T\,. \end{cases} \end{align}\]
Where:
- $\mathrm{OWA}_{\mathrm{rg}}(\boldsymbol{w})$: Is the ordered weighted average range risk of the portfolio.
- $\boldsymbol{\omega}_{1}$: Is the loss-tail OWA weight vector,
r.w1if it is a vector,r.w1(T)if it is a callable. - $\boldsymbol{\omega}_{2}$: Is the reversed gain-tail OWA weight vector,
r.w2if it is a vector,r.w2(T)if it is a callable. - $\hat{\boldsymbol{r}}$: Is the vector of net portfolio returns, which $\mathrm{sort}$ places in ascending order.
- $\boldsymbol{a},\, \boldsymbol{b}$: Are the two
T × 1auxiliary variables of the assignment dual. - $T$: Is the total number of observations.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::OrderedWeightsArrayRange{<:Any, <:Any, <:Any, <:ExactOrderedWeightsArray}: The OWA range risk measure with exact formulation.opt::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr::AbstractPriorResult: Prior result containing the returns matrixX.
Validation
- Each tail weight vector has one entry for each observation, through
owa_weights. Raises aDimensionMismatch.
Keyword arguments
prefix::Symbol: Model State namespace (default: empty, i.e. the bare key).
Returns
owa_range_risk: The OWA range risk expression added to the model.
Related
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::OrderedWeightsArray{<:Any, <:Any, <:ApproxOrderedWeightsArray},
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
pr::AbstractPriorResult,
args...;
loss,
prefix,
kwargs...
) -> Any
Add JuMP risk constraints for OrderedWeightsArray using the approximate OWA formulation to model.
The exact formulation orders the sample with a T × T block of constraints. This one drops that block. It keeps only the properties of the OWA weight vector that any ordering leaves unchanged — the minimum, the maximum, the sum, and one p-norm for each entry of r.alg.p — and it writes each p-norm as a power cone. The cost falls to T × M variables, where M is the length of r.alg.p.
Every permutation of the weight vector satisfies those properties, so the feasible set is a superset of the exact one and the risk is an upper bound on the exact OWA risk. The gap closes as the weight vector approaches a line. Cajas [207] studies that linear case. Tables 1 and 3 of [207] compare the objective value with the exact formulations for the Gini mean difference and the tail Gini over samples of 500 to 1,500 observations. The values agree to the printed precision in every cell but one, 12.94 % against 12.93 % in Table 3. At 10,000 observations the exact formulations do not solve, so those rows hold no comparison.
The gap was measured here against the functor at T = 100, N = 8 with the default p. The Gini mean difference is 0.06 % high, the tail Gini is 1.7e-5 % high, and the tail Gini range is 0.37 % high. A fourth-order L-moment weight vector, which is not linear, is 4.5 % high, so prefer SortingNetworkOrderedWeightsArray for a weight vector that is far from a line.
Mathematical definition
\[\begin{align} \hat{r}_{t} &= \boldsymbol{x}_{t}^{\intercal} \boldsymbol{w}\\ \mathrm{OWA}(\boldsymbol{w}) &\approx \begin{cases} \underset{t,\, \boldsymbol{\nu},\, \boldsymbol{\eta},\, \boldsymbol{\varepsilon},\, \boldsymbol{\psi},\, \boldsymbol{\zeta},\, \boldsymbol{y}}{\min} & c_{1} t - c_{2} \boldsymbol{1}^{\intercal} \boldsymbol{\nu} + c_{3} \boldsymbol{1}^{\intercal} \boldsymbol{\eta} + \sum\limits_{k \in S} d_{k} y_{k}\\ \text{s.t.} & \hat{\boldsymbol{r}} + t \boldsymbol{1} - \boldsymbol{\nu} + \boldsymbol{\eta} - \sum\limits_{k \in S} \boldsymbol{\varepsilon}_{k} = \boldsymbol{0}\\ & \zeta_{k} + y_{k} - \boldsymbol{1}^{\intercal} \boldsymbol{\psi}_{k} = 0 \quad \forall k \in S\\ & \left(-k \zeta_{k},\, \dfrac{k}{k-1} \psi_{k,\, t},\, \varepsilon_{k,\, t}\right) \in \mathcal{P}_{3}^{1/k,\, 1-1/k} \quad \forall k \in S,\, \forall t = 1,\, \ldots,\, T\\ & \boldsymbol{\nu},\, \boldsymbol{\eta},\, \boldsymbol{y} \geq \boldsymbol{0} \end{cases}\\ c_{1} &= \boldsymbol{1}^{\intercal} \left(-\boldsymbol{\omega}\right)\\ c_{2} &= \min\left(-\boldsymbol{\omega}\right)\\ c_{3} &= \max\left(-\boldsymbol{\omega}\right)\\ d_{k} &= \lVert -\boldsymbol{\omega} \rVert_{k} \quad \forall k \in S\\ \mathcal{P}_{3}^{\alpha,\, 1-\alpha} &\coloneqq \left\{\boldsymbol{u} \in \mathbb{R}^{3} : u_{1}^{\alpha} u_{2}^{1-\alpha} \geq \lvert u_{3} \rvert,\, u_{1},\, u_{2} \geq 0\right\}\,. \end{align}\]
Where:
- $\boldsymbol{\omega}$: Is the OWA weight vector,
r.wif it is a vector,r.w(T)if it is a callable. - $\hat{\boldsymbol{r}}$: Is the vector of net portfolio returns, negated when
lossisfalse. - $S$: Is the set of p-norm orders,
r.alg.p, or the empty set when at most one entry of $\boldsymbol{\omega}$ lies strictly between its minimum and its maximum.## Relaxationgives the reason. - $t$: Is the scalar auxiliary variable,
owa_t. - $\boldsymbol{\nu},\, \boldsymbol{\eta}$: Are the
T × 1non-negative auxiliary variables,owa_nuandowa_eta. - $\boldsymbol{\varepsilon},\, \boldsymbol{\psi}$: Are the
T × Mauxiliary variables,owa_epsilonandowa_psi. - $\boldsymbol{\zeta},\, \boldsymbol{y}$: Are the
M × 1auxiliary variables,owa_zandowa_y. - $\mathcal{P}_{3}^{\alpha,\, 1-\alpha}$: Is the three-dimensional power cone.
- $T$: Is the total number of observations.
- $M$: Is the number of p-norm orders,
length(r.alg.p).
JuMP formulation
Variables
- The net portfolio returns $\hat{\boldsymbol{r}}$: Read, through
set_net_portfolio_returns!. owa_t_,owa_nu_,owa_eta_,owa_epsilon_,owa_psi_,owa_z_,owa_y_: Created under no name, and stored under these keys with the indexi. They are $t$, $\boldsymbol{\nu} \geq 0$, $\boldsymbol{\eta} \geq 0$, $\boldsymbol{\varepsilon}$, $\boldsymbol{\psi}$, $\boldsymbol{\zeta}$ and $\boldsymbol{y} \geq 0$.
Expressions
aowa_risk_: $c_{1} t - c_{2} \boldsymbol{1}^{\intercal} \boldsymbol{\nu} + c_{3} \boldsymbol{1}^{\intercal} \boldsymbol{\eta} + \sum_{k \in S} d_{k} y_{k}$, the risk.neg_owa_z_owa_p_: $-k \zeta_{k}$ for each $k \in S$.owa_p_o_owa_pm1_: $k / (k - 1)$ for each $k \in S$.
Constraints
Every row is registered under no name, and stored under its key with the index i.
ca1_owa_: $s_c \left(\hat{\boldsymbol{r}} - \boldsymbol{\nu} + \boldsymbol{\eta} - \sum_{k \in S} \boldsymbol{\varepsilon}_{k} + t \boldsymbol{1}\right) = \boldsymbol{0}$.ca2_owa_: $s_c \left(\zeta_{k} + y_{k} - \boldsymbol{1}^{\intercal} \boldsymbol{\psi}_{k}\right) = 0$ for each $k \in S$.ca_owa_pcone_: $\left(-s_c k \zeta_{k},\, s_c \tfrac{k}{k-1} \psi_{k,\, t},\, s_c \varepsilon_{k,\, t}\right) \in \mathcal{P}_{3}^{1/k,\, 1-1/k}$ for each $k \in S$ and each $t$.
Where:
- $s_c$: Constraint scale. It multiplies both sides of a row, so a positive value leaves the feasible set unchanged.
- The other symbols are those of the
Where:list of# Mathematical definition.
Relaxation
The encoding is not exact: the entries below bound the quantity instead of reproducing it, and the bound is tight only under the condition stated here.
- The bounded quantity is
aowa_risk_. At its minimum over the auxiliary variables, it lies at or above the exact OWA risk of the same portfolio, $\boldsymbol{\omega}^{\intercal} \mathrm{sort}(\hat{\boldsymbol{r}})$. The dual of the programme maximises over every vector with the minimum, the maximum, the sum and the p-norms of $-\boldsymbol{\omega}$, and every reordering of $-\boldsymbol{\omega}$ is such a vector. - The bound is exact when at most one entry of the weight vector lies strictly between its minimum and its maximum, as the vectors of
owa_wrand ofowa_cvarat every $\alpha$ do. The box and the sum then describe the convex hull of the reorderings, and every p-norm constraint is redundant. The method then sets $S$ to the empty set, so $M = 0$ and the model is a linear programme. The redundant cones would put the optimum at the apex of every cone, $\boldsymbol{\varepsilon} = \boldsymbol{0}$ and $\boldsymbol{y} = \boldsymbol{0}$, where an interior point solver can stall. For other vectors the gap closes as the vector approaches a line, and the gaps above give its size. - The bound holds while the objective or a bound pulls
aowa_risk_down, as a minimum-risk objective does. UnderMaximumReturnwith no risk bound, nothing pulls, and the value ofaowa_risk_can lie further above. Read the exact figure back withexpected_risk.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::OrderedWeightsArray{<:Any, <:Any, <:ApproxOrderedWeightsArray}: The OWA risk measure with approximate formulation.opt::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr::AbstractPriorResult: Prior result containing the returns matrixX.
Validation
- The weight vector has one entry for each observation, through
owa_weights. Raises aDimensionMismatch. The formulation reads only the sum, the extremes and the norms of the weights, so without the check a vector of the wrong length solves a different problem with no error.
Keyword arguments
loss::Bool: Iftrue(default), the measure is applied to the net portfolio returns; iffalse, to their negation. The method ofset_risk_constraints!forOrderedWeightsArrayRangesets it tofalseto build its gain tail.prefix::Symbol: Model State namespace (default: empty, i.e. the bare key).
Returns
aowa_risk: The OWA risk expression added to the model.
Related
References
- [207] D. Cajas. Efficient Gini Mean Difference and Tail Gini Portfolio Optimization based on P-Norms. Available at SSRN 4711326 (2024). Sections 2.3 and 2.4, Equations 4 and 5; Section 3, Equation 7; Section 4, Tables 1 and 3.
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::OrderedWeightsArrayRange{<:Any, <:Any, <:Any, <:ApproxOrderedWeightsArray},
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
pr::AbstractPriorResult,
args...;
prefix,
kwargs...
) -> Any
Add JuMP risk constraints for OrderedWeightsArrayRange using the approximate OWA formulation to model.
range_tails gives the loss tail from w1 on the net portfolio returns and the gain tail from w2 on their negation. Each tail brings its own power cone block.
Algorithm
- Check
w1andw2withowa_weights, under their own names. Each tail checks its weights again, but under the namewof the tail. - Build the two tails, register their sum under
aowa_range_risk_and bound it, as steps 1 to 5 of the method ofset_risk_constraints!for aRangeRiskMeasuredo. This copy of the steps agrees with that method.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::OrderedWeightsArrayRange{<:Any, <:Any, <:Any, <:ApproxOrderedWeightsArray}: The OWA range risk measure with approximate formulation.opt::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr::AbstractPriorResult: Prior result containing the returns matrixX.
Validation
- Each tail weight vector has one entry for each observation, through
owa_weights. Raises aDimensionMismatchthat namesw1orw2.
Returns
aowa_range_risk: The combinedloss + gainrisk expression added to the model.
Related
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::OrderedWeightsArray{<:Any, <:Any, <:SortingNetworkOrderedWeightsArray},
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
pr::AbstractPriorResult,
args...;
prefix,
kwargs...
) -> Any
Add Ordered Weights Array (OWA) risk constraints to model using the sorting-network formulation.
The formulation is exact for a nondecreasing weight vector, as ExactOrderedWeightsArray is, at $O(T \log^{2} T)$ linear rows in place of $T^{2}$. set_sorting_network_owa! builds the network.
Mathematical definition
\[\begin{align} \mathrm{OWA}(\boldsymbol{w}) &= \begin{cases} \underset{\boldsymbol{z}}{\min} & s\, \boldsymbol{\omega}^{\intercal} \boldsymbol{z}_{\mathrm{out}}\\ \text{s.t.} & z_{l(k)} + z_{h(k)} = z_{a(k)} + z_{b(k)} \quad \forall k = 1,\, \ldots,\, K\\ & z_{h(k)} \geq z_{a(k)},\; z_{h(k)} \geq z_{b(k)} \quad \forall k = 1,\, \ldots,\, K\\ & \boldsymbol{z}_{\mathrm{in}} = \hat{\boldsymbol{r}} / s\,. \end{cases} \end{align}\]
Where:
- $\boldsymbol{\omega}$: Is the OWA weight vector,
r.wif it is a vector,r.w(T)if it is a callable. - $\hat{\boldsymbol{r}}$: Is the vector of net portfolio returns.
- $s$: Is the largest absolute asset return.
- $K$: Is the number of comparators of
r.alg.mergeforTvalues. - $a(k),\, b(k)$: Are the two values that comparator $k$ reads.
- $l(k),\, h(k)$: Are the smaller and the larger value that comparator $k$ writes.
- $\boldsymbol{z}_{\mathrm{in}},\, \boldsymbol{z}_{\mathrm{out}}$: Are the values that the network reads and the last value that it writes to each position, in ascending position.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::OrderedWeightsArray{<:Any, <:Any, <:SortingNetworkOrderedWeightsArray}: The OWA risk measure with the sorting-network formulation.opt::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr::AbstractPriorResult: Prior result containing the returns matrixX.
Validation
- The weight vector has one entry for each observation, through
owa_weights. Raises aDimensionMismatch. - The weight vector is nondecreasing. Raises a
DomainError.
Keyword arguments
prefix::Symbol: Model State namespace (default: empty, i.e. the bare key).
Returns
sowa_risk: The OWA risk expression added to the model.
Related
OrderedWeightsArraySortingNetworkOrderedWeightsArrayset_sorting_network_owa!set_risk_bounds_and_expression!
References
- [212] M. X. Goemans. Smallest compact formulation for the permutahedron. Mathematical Programming 153, 5–11 (2015).
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::OrderedWeightsArrayRange{<:Any, <:Any, <:Any, <:SortingNetworkOrderedWeightsArray},
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
pr::AbstractPriorResult,
args...;
prefix,
kwargs...
) -> Any
Add JuMP risk constraints for OrderedWeightsArrayRange using the sorting-network formulation to model.
The formulation fuses the two tails, as ExactOrderedWeightsArray does. It forms the single weight vector $\boldsymbol{\omega}_{1} - \boldsymbol{\omega}_{2}$ and builds one network over it. OrderedWeightsArrayRange holds r.w2 reversed, so the difference is the range weight vector, and it is nondecreasing when both tails are.
Mathematical definition
\[\begin{align} \boldsymbol{\omega} &= \boldsymbol{\omega}_{1} - \boldsymbol{\omega}_{2}\\ \mathrm{OWA}_{\mathrm{rg}}(\boldsymbol{w}) &= \boldsymbol{\omega}^{\intercal} \mathrm{sort}\left(\hat{\boldsymbol{r}}\right)\,. \end{align}\]
set_sorting_network_owa! states the rows that compute the sorted term.
Where:
- $\mathrm{OWA}_{\mathrm{rg}}(\boldsymbol{w})$: Is the ordered weighted average range risk of the portfolio.
- $\boldsymbol{\omega}_{1}$: Is the loss-tail OWA weight vector,
r.w1if it is a vector,r.w1(T)if it is a callable. - $\boldsymbol{\omega}_{2}$: Is the reversed gain-tail OWA weight vector,
r.w2if it is a vector,r.w2(T)if it is a callable. - $\hat{\boldsymbol{r}}$: Is the vector of net portfolio returns, which $\mathrm{sort}$ places in ascending order.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::OrderedWeightsArrayRange{<:Any, <:Any, <:Any, <:SortingNetworkOrderedWeightsArray}: The OWA range risk measure with the sorting-network formulation.opt::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr::AbstractPriorResult: Prior result containing the returns matrixX.
Validation
- Each tail weight vector has one entry for each observation, through
owa_weights. Raises aDimensionMismatch. - The range weight vector is nondecreasing. Raises a
DomainError.
Keyword arguments
prefix::Symbol: Model State namespace (default: empty, i.e. the bare key).
Returns
sowa_range_risk: The OWA range risk expression added to the model.
Related
OrderedWeightsArrayRangeSortingNetworkOrderedWeightsArrayset_sorting_network_owa!set_risk_bounds_and_expression!
References
- [212] M. X. Goemans. Smallest compact formulation for the permutahedron. Mathematical Programming 153, 5–11 (2015).
References
- [207]
- D. Cajas. Efficient Gini Mean Difference and Tail Gini Portfolio Optimization based on P-Norms. Available at SSRN 4711326 (2024).
- [212]
- M. X. Goemans. Smallest compact formulation for the permutahedron. Mathematical Programming 153, 5–11 (2015).