Base Risk Constraints
PortfolioOptimisers.scalarise_risk_expression! — Function
scalarise_risk_expression!(model::JuMP.Model, sca)Reduce the entries of model[:risk_vec] to the one risk expression model[:risk].
This is the declaration of the generic function. Each scalariser defines a method in the file of the risk constraints.
Related
PortfolioOptimisers.risk_constraint_solver — Method
risk_constraint_solver(opt::JuMPOptimisationEstimator)Returns the solver against which a risk measure builder resolves a Deferred Quantity.
The method for a JuMP optimiser returns the solver of the optimiser, opt.opt.slv. A programme Allocation Set has a method of its own, which AbstractProgrammeAllocationSet states.
Arguments
opt: The JuMP optimiser that owns the constraint.
Returns
slv: The solver, or the vector of solvers, of the optimiser.
Related
PortfolioOptimisers.set_risk_constraints! — Function
set_risk_constraints!(
model::Model,
r::RiskMeasure,
opt::Union{AbstractProgrammeAllocationSet, JuMPOptimisationEstimator},
pr::AbstractPriorResult,
pl::Union{Nothing, AbstractPhylogenyConstraintResult, AbstractVector{<:AbstractPhylogenyConstraintResult}},
fees::Union{Nothing, Fees};
...
)
set_risk_constraints!(
model::Model,
r::RiskMeasure,
opt::Union{AbstractProgrammeAllocationSet, JuMPOptimisationEstimator},
pr::AbstractPriorResult,
pl::Union{Nothing, AbstractPhylogenyConstraintResult, AbstractVector{<:AbstractPhylogenyConstraintResult}},
fees::Union{Nothing, Fees},
b1::Union{Nothing, AbstractMatrix{<:Union{Number, AbstractJuMPScalar}}};
kwargs...
)
Builds the constraints of one risk measure, or of each measure in a vector, and gives each measure its index.
This route calls no factory, so a measure that states no solver of its own still holds nothing. Both methods resolve the measure against the solver of the owner, risk_constraint_solver. A Calibration Rule that reads the solver then sees the same solver here and on the factory route.
Algorithm
- The method for one measure drops the
scaleofrwithunit_scale_risk_measure, and builds the measure at index1.scaleweighs a measure against the other measures of a vector, so it has no effect on one measure alone. - The method for a vector builds each measure
rs[i]at indexi, and keeps itsscale. - Each build calls
set_resolved_risk_constraints!, which resolves the measure, builds it and records it as the owner of the:risk_frontierentries that it adds.
Arguments
model::JuMP.Model: The JuMP optimisation model.r: ARiskMeasure, orrs, a vector of risk measures.opt: The owner of the constraint, aJuMPOptimisationEstimatoror a programme Allocation Set.RiskConstraintOwnerstates the owners.pr: Prior result.pl: Optional phylogeny constraints.fees: Optional fees structure.b1::Option{<:MatNum} = nothing: Basis of the decision vector ofFactorRiskContribution, which maps it to the asset weights: the pseudoinverse of the transposed loadings, followed by the off-factor basis whenflag = true.nothingfor all other optimisers.
Returns
nothing.
Related
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::RangeRiskMeasure,
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
pr::AbstractPriorResult,
args...;
prefix,
kwargs...
) -> Any
Adds the constraints of a range risk measure to model, as the sum of its loss tail and its gain tail.
This is the build of every RangeRiskMeasure formulation that decomposes. The two tails from range_tails carry rke = false and no bound, so the sum alone reaches the objective and the bound. Each tail builds under its own index, which nested_index composes from the side and i. The keys of the two tails therefore differ, also when a range holds a range. A formulation that fuses its tails has a method of its own, which is more specific.
Two decomposed formulations do work of their own before the tails: OrderedWeightsArrayRange under ApproxOrderedWeightsArray checks w1 and w2 under their names, and GenericValueatRiskRange of two DistributionValueatRisk tails builds the cone that the tails share. Their methods hold a copy of the five steps below, and the copies agree with this method.
Mathematical definition
\[\begin{align} \mathcal{R}_{\mathrm{range}}(\boldsymbol{w}) &= \mathcal{R}_{\mathrm{loss}}(\hat{\boldsymbol{r}}) + \mathcal{R}_{\mathrm{gain}}(-\hat{\boldsymbol{r}})\,. \end{align}\]
Where:
- $\mathcal{R}_{\mathrm{range}}(\boldsymbol{w})$: The range risk of the portfolio.
- $\mathcal{R}_{\mathrm{loss}}$, $\mathcal{R}_{\mathrm{gain}}$: The loss tail and the gain tail of the range measure, each a risk measure of a return series.
- $\hat{\boldsymbol{r}}$: The net portfolio returns, $T \times 1$, with entries $\hat{r}_t$.
- $\hat{r}_t$: Net portfolio return at observation $t$, $\boldsymbol{x}_t^\intercal \boldsymbol{w}$ less the fees charged at $t$.
Algorithm
- Read the tails
lossandgainofrwithrange_tails, and the keynameof the sum withrange_risk_key. - Build
lossat indexnested_index(:loss_, i)withloss = true, givingloss_risk. - Build
gainat indexnested_index(:gain_, i)withloss = false, givinggain_risk. The builder then reads the negated net portfolio returns. - Register
range_risk = loss_risk + gain_riskunder the Model State key ofnameandi. - Bound
range_riskand add it torisk_vecwithset_risk_bounds_and_expression!, fromr.settings.
JuMP formulation
Expressions
<prefix><name><i>: $\mathcal{R}_{\mathrm{loss}} + \mathcal{R}_{\mathrm{gain}}$, registered as a Model State entry.nameisrange_risk_key(r).
Where:
- $\mathcal{R}_{\mathrm{loss}}$, $\mathcal{R}_{\mathrm{gain}}$: The risk expressions that the two tail builds return.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::RangeRiskMeasure: The range risk measure, a formulation that decomposes.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.
Keyword arguments
prefix::Symbol: Model State namespace (default: empty, i.e. the bare key).
Returns
range_risk: The combinedloss + gainrisk expression added to the model.
Related
PortfolioOptimisers.range_risk_key — Function
range_risk_key(r::RangeRiskMeasure) -> SymbolReturns the Model State key of the sum of the two tails of the range r.
Every RangeRiskMeasure formulation that decomposes implements a method, beside its builder. The key follows the convention <base>_range_risk_, where <base> is the key of the point measure, so a reader of the model finds the range from the name of its base.
| Formulation | Key |
|---|---|
ValueatRiskRange under MIPValueatRisk | :var_range_risk_ |
ConditionalValueatRiskRange | :cvar_range_risk_ |
DistributionallyRobustConditionalValueatRiskRange | :drcvar_range_risk_ |
EntropicValueatRiskRange | :evar_range_risk_ |
RelativisticValueatRiskRange | :rlvar_range_risk_ |
PowerNormValueatRiskRange | :pvar_range_risk_ |
GenericValueatRiskRange | :genvar_range_risk_ |
OrderedWeightsArrayRange under ApproxOrderedWeightsArray | :aowa_range_risk_ |
There is no fallback. A formulation that fuses its tails states its key in its own builder, so a missing method stays a MethodError.
Arguments
r::RangeRiskMeasure: The range risk measure.
Returns
name::Symbol: The bare Model State key of the sum.state_set!adds the prefix and the index.
Related
PortfolioOptimisers.set_risk_bounds_and_expression! — Function
set_risk_bounds_and_expression!(
model::Model,
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
r_expr::AbstractJuMPScalar,
settings::RiskMeasureSettings,
name::Symbol;
...
)
set_risk_bounds_and_expression!(
model::Model,
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
r_expr::AbstractJuMPScalar,
settings::RiskMeasureSettings,
name::Symbol,
flag::Bool;
prefix
)
Bounds a risk expression by settings.ub, and adds it to the risk that the objective reads.
Every risk measure builder ends with this call, or with a sibling that takes a separate bound expression.
Algorithm
- Compose
keyfromprefix,nameand, in the index method,i, withstate_key. The builder registered its risk expression under the same key, so the bound keys cannot differ from it. - Bound
r_exprbysettings.ubwithset_risk_upper_bound!, in the direction thatflaggives. - Append
r_exprtimessettings.scaletorisk_vecwithset_risk_expression!, whensettings.rkeistrue.
Arguments
model::JuMP.Model: The JuMP optimisation model.opt: The owner of the constraint, aRiskConstraintOwner.r_expr::JuMP.AbstractJuMPScalar: The risk expression.settings::RiskMeasureSettings: The settings of the measure, which give the bound, the weight andrke.name::Symbol: The Model State name of the risk expression. The bound keys<name>_uband<name>_ub_varderive from it.i: The index of the measure, in the index method.flag::Bool:truefor an upper bound andfalsefor a lower bound (default:true).
Keyword arguments
prefix::Symbol: Model State namespace forname(default: empty, i.e. the bare key).
Returns
nothing.
Related