Ordered Weights Array: private API
PortfolioOptimisers.AbstractOrderedWeightsArrayEstimator — Type
abstract type AbstractOrderedWeightsArrayEstimator <: AbstractEstimatorAbstract supertype for all Ordered Weights Array (OWA) estimator types.
All concrete and/or abstract types implementing OWA estimation algorithms should be subtypes of AbstractOrderedWeightsArrayEstimator.
Related
References
- [109] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.AbstractOrderedWeightsArrayAlgorithm — Type
abstract type AbstractOrderedWeightsArrayAlgorithm <: AbstractAlgorithmAbstract supertype for all Ordered Weights Array (OWA) algorithm types.
All concrete and/or abstract types implementing specific OWA algorithms should be subtypes of AbstractOrderedWeightsArrayAlgorithm.
Related
References
- [109] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.SquaredOrderedWeightsArrayAlgorithm — Type
abstract type SquaredOrderedWeightsArrayAlgorithm{T} <: AbstractOrderedWeightsArrayAlgorithmAbstract supertype for squared OWA weight optimisation algorithms.
Subtypes find OWA weights by minimising a squared-distance or squared-sum objective subject to OWA constraints, and are parameterised by the optimisation algorithm type T.
Related
References
- [109] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.UnionAllSOCRiskExpr — Type
const UnionAllSOCRiskExpr = Union{<:SquaredSOCRiskExpr, <:RSOCRiskExpr, <:SOCRiskExpr}Union of all second-order cone risk expression formulation types.
Related
PortfolioOptimisers.UnionSOCRiskExpr — Type
const UnionSOCRiskExpr = Union{<:SquaredSOCRiskExpr, <:SOCRiskExpr}Union of squared and plain SOC risk expression formulation types (excludes RSOC).
Related
PortfolioOptimisers.UnionRSOCSOCRiskExpr — Type
const UnionRSOCSOCRiskExpr = Union{<:RSOCRiskExpr, <:SOCRiskExpr}Union of RSOC and plain SOC risk expression formulation types (excludes squared SOC).
Related
PortfolioOptimisers.EntropyFormulation — Type
abstract type EntropyFormulation <: AbstractAlgorithmAbstract supertype for entropy formulations used in the MaximumEntropy OWA algorithm.
Related
References
- [109] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.OWA_Func_VecNum — Type
const OWA_Func_VecNum = Union{<:Func_VecNum, <:AbstractOrderedWeightsArrayFunction}Union type for OWA weight specifications: a function, a numeric vector, or an AbstractOrderedWeightsArrayFunction callable.
Related
PortfolioOptimisers.OrderedWeightsArrayFormulation — Type
abstract type OrderedWeightsArrayFormulation <: AbstractAlgorithmAbstract supertype for ordered weights array (OWA) formulation types.
Determines whether OWA weights are computed exactly or approximately.
Related
References
- [110] W. Ogryczak and T. Śliwiński. On solving linear programs with the ordered weighted averaging objective. European Journal of Operational Research 148, 80–91 (2003).
- [107] D. Cajas. OWA portfolio optimization: A disciplined convex programming framework. Available at SSRN 3988927 (2021).
- [108] D. Cajas. Efficient Gini Mean Difference and Tail Gini Portfolio Optimization based on P-Norms. Available at SSRN 4711326 (2024).
- [5] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 7.1.5.
PortfolioOptimisers.OWA_RevFunc — Type
const OWA_RevFunc = ComposedFunction{typeof(reverse),
<:AbstractOrderedWeightsArrayFunction}The reversal of an ordered-weights builder, which is what OrderedWeightsArrayRange stores in w2 under the approximate formulation.
It is a Function and it computes no quantity, so it is the one occupant of a weight slot that a reader of the calibration channel must part from a Calibration Rule. The name is written once here, because the type is long and three sites read it.
Related
PortfolioOptimisers.OWA_CalOccupant — Type
const OWA_CalOccupant = Union{<:AbstractOrderedWeightsArrayFunction, <:OWA_RevFunc}The occupants of an OrderedWeightsArray weight slot that carry a calibration slot of their own: a weight builder, and the reversal of one that the Range container builds.
The slot also takes a weight vector and a caller's own plain function, and neither carries a slot. Neither is therefore named in calibration_slots, and the distinction matters because a plain function standing in a calibration slot is a Calibration Rule everywhere else in the library. The rule is what resolve_calibration_slot calls and what assert_calibrated_slots refuses, so a weight builder written as a plain function must not reach either.
Related
PortfolioOptimisers.resolve_deferred_quantities — Method
resolve_deferred_quantities(x, ) -> StandardDeviation
resolve_deferred_quantities(x, , ) -> StandardDeviation
Resolve every Deferred Quantity held by x against prior result pr, returning a struct of the same type whose deferred slots hold plain values.
This resolves the deferred state and nothing else. A slot left unstated stays nothing, so whichever fallback the consumer already applies — sel on the factory path, chol_sigma_selector and its siblings on the JuMP path — keeps working unchanged. The two paths are separate: a JuMP model builder reads the risk measure's slots directly and never calls factory, so both entry points resolve.
Given a prior result the rule has two halves. Container recursion is derived from deferred_slots, so a type that only holds children needs no method at all. A type that resolves a quantity of its own defines a method, which overrides the derived one. Writing that half per type — rather than per field — is what lets slots that travel together be resolved together: a deferred sigma supplies chol from the same fit, so the pair is never mixed across two sources.
slv is the effective solver, and it is what a Calibration Rule in the same struct reads. It carries the value the optimisation settled on, so a rule resolves against one solver on both routes. On the factory route the @cprop selection has already put that solver on the struct, so the argument stays at its default. On the JuMP route no selection runs, so set_risk_constraints! reads the solver off the estimator and threads it here. A type that carries a solver of its own settles it locally as sel(x.slv, slv), beside the observation weights it already settles that way, and a type that carries none gives its rules none on either route.
Algorithm
- Return
xunchanged. This method is the arm for a second argument that is not a prior result: with no prior in hand nothing can be fitted, so the deferred state travels on.
A more specific method dominates this one on a prior result: the one that deferred_slots derives for a container, and the hand-written one of a type that resolves a quantity of its own.
Related
resolve_deferred_quantities(x, pr::AbstractPriorResult, slv = nothing)Resolve the children that deferred_slots declared and the slots that calibration_slots declared, and return x itself when none of them changed.
This is the derived half of the resolution rule. A container declares its children once and both entry points follow: factory reaches them through @fprop, and the JuMP builders reach them through this method. Neither needs a forwarding method per container.
A type that resolves a quantity of its own overrides this with its own method, which is more specific. So the derivation carries container recursion alone, and never guesses how a matrix, a tensor or the centre a moment was taken about comes out of a fit.
Both channels end in one rebuild: a measure that carries both kinds of slot must not be rebuilt twice. resolve_calibration_slots states the calibration half and returns its resolved slots rather than a rebuilt object, and the two answers merge here. The deferred half merges last, so it wins a key both channels declare. A container names one child in both, and the child the recursion resolved is the one to keep.
slv is the effective solver, and the recursion threads it to every child. A container states no solver of its own, so it changes none: each child settles the one it was handed against the one it carries.
Algorithm
- Read the slots
xdeclares withdeferred_slots, givingslots. - Read the resolved calibration slots with
resolve_calibration_slots, givingcalibrated. - Return
xunchanged when both are empty. A type with neither kind of slot needs no method of its own. - Resolve every entry of
slotswithresolve_deferred_child, threadingprandslvto each, givingresolved. - Refuse a slot the recursion left unresolved with
assert_declared_slot_resolver. - Hand
merge(calibrated, resolved)torebuild_with_slots, which returnsxitself when no entry moved and a rebuilt copy when one did.
Returns
xitself when no slot moved, and a rebuilt copy ofxwhen one did.
Related
resolve_deferred_quantities(
x::ComposedFunction{typeof(reverse), <:AbstractOrderedWeightsArrayFunction},
pr::AbstractPriorResult
) -> ComposedFunction{typeof(reverse)}
resolve_deferred_quantities(
x::ComposedFunction{typeof(reverse), <:AbstractOrderedWeightsArrayFunction},
pr::AbstractPriorResult,
slv
) -> ComposedFunction{typeof(reverse)}
Resolve the weight builder inside the reversal that OrderedWeightsArrayRange wraps its w2 in.
The Range constructor stores w2 as reverse ∘ w2 whenever the caller has not already reversed it, so the object the w2 slot holds is a composition and the builder a rule sits in is its inner half. Without this method the recursion would stop at the composition and a rule in the gain-side builder would never resolve, while the same rule in w1 did.
The composition is rebuilt around the resolved half, so the reversal survives. The bound names reverse and an AbstractOrderedWeightsArrayFunction, so no other composition reaches it.
Related
PortfolioOptimisers.owa_l_moment_crm_sumsq_obj — Function
owa_l_moment_crm_sumsq_obj(method::OWAJuMP{<:Any, <:Any, <:Any, <:Any,
<:SquaredOrderedWeightsArrayAlgorithm},
model::JuMP.Model)Set the minimisation objective of a SquaredOrderedWeightsArrayAlgorithm OWA problem on model.
The caller adds the cone constraint that relates the scalar variable t to the quantity being minimised. This method only sets the objective, and it dispatches on the SecondMomentFormulation that parameterises method.alg. It does not solve the model.
Arguments
method: OWA estimator whosealgis aMinimumSquaredDistanceor aMinimumSumSquares. Itssofield scales the objective.model::JuMP.Model: Model built byowa_model_setup, already carrying thetvariable and its cone constraint.
Returns
- The objective function set on
model. The model is modified in place.
Details
- Under
SOCRiskExprorRSOCRiskExprthe objective isso * t. - Under
SquaredSOCRiskExprthe objective isso * t^2, because the caller's cone boundstbelow by a norm rather than by its square. - All three encodings share the same minimiser, so they return the same OWA weights to solver tolerance.
Related
MinimumSquaredDistanceMinimumSumSquaresSquaredOrderedWeightsArrayAlgorithmowa_model_setupowa_l_moment_crmowa_l_moment_crm_entropy
References
- [109] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.ncrra_weights — Function
ncrra_weights(weights::MatNum, g::Number = 0.5)Compute normalised constant relative risk aversion (CRRA) Ordered Weights Array (OWA) weights.
This function generates OWA weights using a normalised CRRA scheme, parameterised by g. The CRRA approach interpolates between risk-neutral and risk-averse weighting profiles, controlled by the risk aversion parameter g.
It is the risk aversion coefficients that are normalised to sum to one, not the returned OWA weights. The returned vector is a combination of the columns of weights, so its sum is the same combination of their column sums.
Arguments
weights: Matrix of weights (typically order statistics or moment weights).g: Risk aversion parameter.
Validation
0 < g < 1.
Returns
w::VecNum: Vector of OWA weights of lengthsize(weights, 1).
Details
The function computes the OWA weights as follows:
For each order statistic, recursively compute the CRRA weight using the formula:
e *= g + i - 1 phis[i] = e / factorial(i + 1)
The vector
phisis normalised to sum to one.The final OWA weights are computed as a weighted sum of the input
weightsandphis, with monotonicity enforced by taking the maximum up to each index.
Examples
julia> w = [1.0 0.5; 0.5 1.0]2×2 Matrix{Float64}: 1.0 0.5 0.5 1.0julia> PortfolioOptimisers.ncrra_weights(w, 0.5)2-element Vector{Float64}: 0.8333333333333333 0.8333333333333333Related
References
- [109] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.owa_model_setup — Function
owa_model_setup(method::OWAJuMP, weights::MatNum)Construct a JuMP model for Ordered Weights Array (OWA) weight estimation.
This function sets up a JuMP optimization model for OWA weights, given an OWAJuMP estimator and a matrix of weights (e.g., order statistics or moment weights). The model includes variables for the OWA weights (phi) and auxiliary variables (theta), and enforces constraints for non-negativity, upper bounds, sum-to-one, monotonicity, and consistency with the input weights.
Arguments
method: OWA estimator containing solver, scaling, and algorithm configuration.weights: Matrix of weights (typically order statistics or moment weights).
Returns
model::JuMP.Model: Configured JuMP model with variables and constraints for OWA weight estimation.
Constraints
phi(OWA weights) are non-negative and bounded above bymax_phi.- The sum of
phiis 1. thetais constrained to be equal to the weighted sum of the input weights andphi.- Monotonicity is enforced on
phiandtheta.
Related
References
- [109] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.owa_model_solve — Function
owa_model_solve(model::JuMP.Model, method::OWAJuMP, weights::MatNum)Solve a JuMP model for OWA weight estimation and extract the resulting OWA weights.
This function solves the provided JuMP model using the solver(s) specified in the OWAJuMP estimator. If the optimization is successful, it reads the OWA weights off the model's theta variable, which owa_model_setup has already constrained to equal weights * phi. If the optimization fails, a warning is issued and a fallback to ncrra_weights is used.
Arguments
model: JuMP model for OWA weight estimation.method: OWA estimator containing solver configuration.weights: Matrix of weights (typically order statistics or moment weights).
Returns
w::VecNum: Vector of OWA weights of lengthsize(weights, 1).
Details
- If the solver succeeds, the solution is the value of the model's
thetavariable. It is the risk aversion coefficientsphithat the model constrains to sum to one, nottheta. - If the solver fails, a warning is issued and the fallback
ncrra_weights(weights, 0.5)is returned. The model is infeasible whenTis too small for the monotonicity constraint ontheta, so this fallback is the ordinary path for a short sample.
Related
References
- [109] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.owa_l_moment_crm_entropy — Function
owa_l_moment_crm_entropy(method::OWAJuMP{<:Any, <:Any, <:Any, <:Any, <:MaximumEntropy},
model::JuMP.Model)Add the entropy objective of the MaximumEntropy OWA problem to model.
The method dispatches on the EntropyFormulation held in method.alg.alg. It reads the model's x variable, adds the auxiliary variables and cone constraints that encode $-\sum_{t} x_{t} \log(x_{t})$, and sets the maximisation objective. It does not solve the model.
Arguments
method: OWA estimator whosealgis aMaximumEntropy. Itsscandsofields scale the constraints and the objective.model::JuMP.Model: Model built byowa_model_setup, already carrying thexvariable.
Returns
nothing. The model is modified in place.
Details
- Under
RelativeEntropy, oneJuMP.MOI.RelativeEntropyConeof dimension2T + 1bounds a scalartbelow by $\sum_{t} x_{t} \log(x_{t})$, and the objective maximises-t. - Under
ExponentialConeEntropy,TseparateJuMP.MOI.ExponentialConeconstraints bound eacht[i]above by $-x_{i} \log(x_{i})$, and the objective maximisessum(t). - Both formulations attain the same OWA weights to solver tolerance.
Related
References
- [109] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
References
- [5]
- D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).
- [107]
- D. Cajas. OWA portfolio optimization: A disciplined convex programming framework. Available at SSRN 3988927 (2021).
- [108]
- D. Cajas. Efficient Gini Mean Difference and Tail Gini Portfolio Optimization based on P-Norms. Available at SSRN 4711326 (2024).
- [109]
- D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
- [110]
- W. Ogryczak and T. Śliwiński. On solving linear programs with the ordered weighted averaging objective. European Journal of Operational Research 148, 80–91 (2003).