Skip to content
13

Variance Constraints

PortfolioOptimisers.get_chol_or_sigma_pm Function
julia
get_chol_or_sigma_pm(
    model::Model,
    pr::AbstractPriorResult
) -> Any

Retrieve or compute and cache the upper Cholesky factor of the prior covariance matrix.

If model does not yet contain a G expression, the factor is computed from pr.chol (if available) or by Cholesky-factorising pr.sigma, then stored as model[:G].

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • pr::AbstractPriorResult: Prior result containing sigma and optionally chol.

Returns

  • G::Matrix: Upper Cholesky factor of the prior covariance matrix.

Related

source
PortfolioOptimisers.chol_sigma_selector Function
julia
chol_sigma_selector(
    model::Model,
    pr::AbstractPriorResult,
    r::Union{DistributionValueatRisk, StandardDeviation, Variance}
) -> Any

Select the Cholesky factor to use for the covariance matrix.

Returns the factor from the prior (get_chol_or_sigma_pm) when r.sigma and r.chol are both nothing, the Cholesky of r.sigma when r.chol is nothing, or r.chol directly.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • pr: Prior result.

  • r::CholRM: Risk measure carrying optional sigma and chol fields.

Returns

  • G::Matrix: Upper Cholesky factor of the selected covariance matrix.

Related

source
PortfolioOptimisers.set_variance_risk_bounds_and_expression! Function
julia
set_variance_risk_bounds_and_expression!(
    model::Model,
    opt::RiskJuMPOptimisationEstimator,
    r_expr_ub::AbstractJuMPScalar,
    ub::Union{Nothing, Frontier, Union{var"#s21", var"#s20"} where {var"#s21"<:Number, var"#s20"<:(AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}})}},
    key::Symbol,
    r_expr::AbstractJuMPScalar,
    settings::JuMPRiskMeasureSettings
)
set_variance_risk_bounds_and_expression!(
    model::Model,
    opt::RiskJuMPOptimisationEstimator,
    r_expr_ub::AbstractJuMPScalar,
    ub::Union{Nothing, Frontier, Union{var"#s21", var"#s20"} where {var"#s21"<:Number, var"#s20"<:(AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}})}},
    key::Symbol,
    r_expr::AbstractJuMPScalar,
    settings::JuMPRiskMeasureSettings,
    flag::Bool
)

Set the upper-bound constraint and register the variance risk expression.

Applies set_risk_upper_bound! using r_expr_ub and ub, then registers r_expr via set_risk_expression! according to settings.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • opt::RiskJuMPOptimisationEstimator: Risk-based optimisation estimator.

  • r_expr_ub::JuMP.AbstractJuMPScalar: Expression used for the upper-bound check.

  • ub: Upper bound value.

  • key::Symbol: Symbol used to name constraints or expressions in the model.

  • r_expr::JuMP.AbstractJuMPScalar: Risk expression added to the objective.

  • settings::RiskMeasureSettings: Settings carrying scale and rke flag.

  • flag::Bool: If true, sets upper bound; if false sets lower bound.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk! Method
julia
set_risk!(
    model::Model,
    i,
    r::StandardDeviation,
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    prefix,
    kwargs...
) -> Tuple{VariableRef, Symbol}

Construct the raw standard-deviation or variance risk JuMP variable and second-order cone constraint.

For StandardDeviation, adds a scalar variable sd_risk_i and the SOC constraint [sc * sd_risk; sc * G * w] in SecondOrderCone(). For Variance, dispatches to the appropriate variance formulation (SDP, SOC-squared, or quadratic) and also applies any risk-contribution constraints.

Mathematical definition

Standard deviation:

σ^(w)=Gw2.

Where:

  • σ^(w): Portfolio standard deviation.

  • G: Upper Cholesky factor of the covariance matrix Σ.

  • w: Portfolio weights vector N×1.

SDP variance:

σ^2(w)=tr(ΣW).

Where:

  • σ^2(w): Portfolio variance (SDP formulation).

  • W=ww: Outer product of portfolio weights.

  • Σ: Covariance matrix.

  • tr(): Matrix trace operator.

where G is the upper Cholesky factor of Σ and W is the SDP matrix variable.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r: Risk measure instance (StandardDeviation or Variance).

  • opt::JuMPOptimisationEstimator: JuMP optimisation estimator.

  • pr: Prior result.

  • pl: Optional phylogeny constraints.

Returns

  • A 2-tuple (risk_expr, key) of the JuMP risk expression and its model key.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::StandardDeviation,
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    kwargs...
) -> VariableRef

Add standard-deviation, variance, or uncertainty-set variance risk constraints to model.

Each method builds the appropriate JuMP variables and constraints and then calls set_risk_bounds_and_expression! or set_variance_risk_bounds_and_expression!. The Variance / NonFRCJuMPOpt overload automatically chooses between SDP and SOC/quadratic formulations based on risk-contribution and phylogeny settings.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r: Risk measure instance.

  • opt::JuMPOptimisationEstimator: JuMP optimisation estimator.

  • pr: Prior result.

  • pl: Optional phylogeny constraints.

  • fees: Optional fees structure.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::Variance,
    opt::Union{MeanRisk, NearOptimalCentering, RiskBudgeting},
    pr::AbstractPriorResult,
    pl::Union{Nothing, AbstractPhylogenyConstraintResult, AbstractVector{<:AbstractPhylogenyConstraintResult}},
    args...;
    prefix,
    kwargs...
) -> Any

Add JuMP risk constraints for Variance to model using non-factor-risk-contribution optimisers.

Computes the portfolio variance risk expression and registers the upper-bound constraint and objective contribution according to the variance risk measure settings.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r::Variance: The variance risk measure.

  • opt::NonFRCJuMPOpt: The optimisation estimator.

  • pr: Prior result.

  • pl: Optional phylogeny constraints.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::Variance,
    opt::FactorRiskContribution,
    pr::AbstractPriorResult,
    ,
    ,
    b1::AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
    args...;
    prefix,
    kwargs...
) -> Any

Add JuMP risk constraints for Variance to model using a FactorRiskContribution optimiser.

Computes factor-based risk contributions for the portfolio variance and registers the upper-bound constraint and objective contribution accordingly.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r::Variance: The variance risk measure.

  • opt::FactorRiskContribution: The factor risk contribution optimisation estimator.

  • pr: Prior result.

  • b1::MatNum: Factor budget matrix used for risk contribution computations.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::UncertaintySetVariance,
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    prefix,
    rd,
    kwargs...
) -> Any

Add JuMP risk constraints for UncertaintySetVariance to model.

Computes portfolio variance using an uncertainty set covariance matrix derived from the prior or the risk measure's own ucs field, and registers the upper-bound constraint and objective contribution.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r::UncertaintySetVariance: The uncertainty set variance risk measure.

  • opt::RiskJuMPOptimisationEstimator: Risk-based optimisation estimator.

  • pr: Prior result.

Returns

  • nothing.

Related

source
PortfolioOptimisers.sdp_rc_variance_flag! Function
julia
sdp_rc_variance_flag!(
    _::Model,
    _::Union{MeanRisk, NearOptimalCentering, RiskBudgeting},
    _::Nothing
) -> Bool

Return whether risk-contribution constraints require the SDP variance formulation.

Returns false for Nothing (no risk-contribution constraints) and true for LinearConstraint (risk-contribution constraints are present).

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • opt::NonFRCJuMPOpt: Optimisation estimator.

  • rc: Risk-contribution constraint (nothing or LinearConstraint).

Returns

  • flag::Bool: Whether risk-contribution constraints require the SDP formulation.

Related

source
PortfolioOptimisers.sdp_variance_flag! Function
julia
sdp_variance_flag!(
    model::Model,
    rc_flag::Bool,
    pl::Union{Nothing, AbstractPhylogenyConstraintResult, AbstractVector{<:AbstractPhylogenyConstraintResult}};
    prefix
) -> Union{LinearBound, SquareRootBound}

Return the FrontierBoundEstimator that selects the appropriate variance formulation.

Returns LinearBound (SDP formulation) when any of the following hold: rc_flag is true, model already contains a rc_variance expression, or pl contains a SemiDefinitePhylogeny constraint. Returns SquareRootBound (SOC formulation) otherwise.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • rc_flag::Bool: Whether risk-contribution constraints require the SDP formulation.

  • pl: Optional phylogeny constraint(s).

Returns

Related

source
PortfolioOptimisers.set_variance_risk! Function
julia
set_variance_risk!(
    model::Model,
    i,
    r::Variance,
    pr::AbstractPriorResult,
    ::LinearBound,
    key::Symbol;
    prefix
) -> Any

Build the variance risk JuMP expression according to the selected formulation.

The flag-dispatching overload routes to either set_sdp_variance_risk! (SDP) or the appropriate SOC/quadratic overload. The SquaredSOCRiskExpr overload encodes variance as the square of an SOC variable. The QuadRiskExpr overload encodes variance directly as wΣw.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r::Variance: Variance risk measure.

  • pr::AbstractPriorResult: Prior result containing the covariance matrix sigma.

  • flag:

    • ::LinearBound: Use the SDP formulation.

    • ::SquareRootBound: Use the SOC formulation.

  • key::Symbol: Symbol used to name constraints or expressions in the model.

Returns

  • The variance risk JuMP expression.

Related

source
PortfolioOptimisers.set_sdp_variance_risk! Function
julia
set_sdp_variance_risk!(
    model::Model,
    i,
    r::Variance,
    pr::AbstractPriorResult,
    key::Symbol;
    prefix
) -> Any

Build the SDP variance risk expression using the semidefinite matrix W.

Computes sigma_W = sigma * W and stores tr(sigma_W) as the variance risk expression under key.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r::Variance: Variance risk measure.

  • pr::AbstractPriorResult: Prior result containing the covariance matrix sigma.

  • key::Symbol: Symbol used to name constraints or expressions in the model.

Returns

  • The variance risk JuMP expression.

Related

source
PortfolioOptimisers.variance_risk_bounds_expr Function
julia
variance_risk_bounds_expr(
    model::Model,
    i,
    _::LinearBound
) -> Tuple{Any, Symbol}

Return the JuMP expression and symbol key used for the variance upper-bound check.

When flag is true (SDP formulation) the variance expression and :variance_risk_i key are returned; otherwise the standard-deviation variable and :dev_i key are returned.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index.

  • flag:

    • ::LinearBound: Use the SDP formulation.

    • ::SquareRootBound: Use the SOC formulation.

Returns

  • A 2-tuple (expr, key) of the bound expression and its model key.

Related

source
PortfolioOptimisers.variance_risk_bounds_val Function
julia
variance_risk_bounds_val(
    bound::FrontierBoundEstimator,
    ub::Frontier
) -> Frontier{<:Integer, Int64, <:FrontierBoundEstimator}

Convert a bound value to the appropriate scale for the selected variance formulation.

Dispatches on the FrontierBoundEstimator strategy:

  • LinearBound: passes the bound through unchanged (variance units → variance units).

  • SquareRootBound: applies sqrt to convert from variance to standard-deviation units.

  • SquaredBound: applies squaring to convert from linear to squared units.

Returns nothing when ub is nothing.

Arguments

  • bound::FrontierBoundEstimator: Bound-transformation strategy.

  • ub: Bound value (scalar, vector, Frontier, or nothing).

Returns

  • The rescaled bound, or nothing when ub is nothing.

Related

source
PortfolioOptimisers.rc_variance_constraints! Function
julia
rc_variance_constraints!(args...; kwargs...)

Add linear risk-contribution constraints on the variance decomposition to model.

The fall-through method does nothing. The concrete method extracts the diagonal of the sigma_W_i expression and adds inequality and/or equality constraints of the form A_ineq * diag(sigma_W) <= B_ineq * variance_risk and A_eq * diag(sigma_W) == B_eq * variance_risk.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • rc::LinearConstraint: Linear risk-contribution constraint.

  • variance_risk::JuMP.AbstractJuMPScalar: Total variance risk expression.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_ucs_variance_risk! Function
julia
set_ucs_variance_risk!(
    model::Model,
    i,
    ucs::BoxUncertaintySet,
    args...;
    prefix
) -> Tuple{Any, Symbol}

Build an uncertainty-set variance risk expression for box or ellipsoidal uncertainty.

The BoxUncertaintySet overload introduces symmetric auxiliary matrices Au and Al and encodes the worst-case variance as tr(Au * ub) - tr(Al * lb). The EllipsoidalUncertaintySet overload introduces a PSD matrix E, the compound matrix W + E, and adds an SOC constraint to bound the ellipsoidal perturbation term.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • ucs: Uncertainty set instance (BoxUncertaintySet or EllipsoidalUncertaintySet).

  • sigma::MatNum: Covariance matrix (used by EllipsoidalUncertaintySet).

Returns

  • A 2-tuple (ucs_variance_risk, key) of the uncertainty-set variance expression and its model key.

Related

source