Cardinality Constraints
PortfolioOptimisers.set_card_constraints! Function
set_card_constraints!(
model::Model,
sp::AbstractMIPSpace,
ind::AbstractMIPIndicators,
card::Integer
)Add the cardinality constraint sum(ib) ≤ card to the JuMP optimisation model.
ind is the indicator bundle the MIP builder that ran returned; the held binary (held_bin) is summed, so the sum counts held assets and the bound caps how many may be non-zero. The constraint key is named for the space sp via mip_key, so the same emitter serves the asset space and every sub-group. The fall-through method does nothing when card is nothing — and so never reads a held indicator the bundle may not carry.
Arguments
model::JuMP.Model: The JuMP optimisation model.sp::AbstractMIPSpace: Weight space the constraint acts on.ind::AbstractMIPIndicators: Indicator bundle returned by the MIP builder that ran.card::Option{<:Integer}: Maximum number of non-zero assets, ornothing.
Returns
nothing.
Related
sourcePortfolioOptimisers.set_gcard_constraints! Function
set_gcard_constraints!(
model::Model,
sp::AbstractMIPSpace,
ind::AbstractMIPIndicators,
gcard::LinearConstraint
)Add the group-cardinality constraints A * ib ≤ B and A * ib = B to the model.
Enforces the linear group-cardinality constraint carried by gcard on the held binary (held_bin) of the bundle ind, capping (or fixing) how many assets in each group may be held. The constraint keys are named for the space sp via mip_key, so the same emitter serves the asset space and every sub-group. The fall-through method does nothing when gcard is nothing — and so never reads a held indicator the bundle may not carry.
Arguments
model::JuMP.Model: The JuMP optimisation model.sp::AbstractMIPSpace: Weight space the constraints act on.ind::AbstractMIPIndicators: Indicator bundle returned by the MIP builder that ran.gcard::Option{<:LinearConstraint}: Group-cardinality constraint, ornothing.
Returns
nothing.
Related
sourcePortfolioOptimisers.set_all_smip_constraints! Function
set_all_smip_constraints!(
model::Model,
wb::WeightBounds,
card::Union{Nothing, Integer},
gcard::Union{Nothing, LinearConstraint},
smtx::Union{Nothing, AbstractMatrix{<:Union{var"#s34", var"#s33"} where {var"#s34"<:Number, var"#s33"<:AbstractJuMPScalar}}},
lt::Union{Nothing, Threshold},
st::Union{Nothing, Threshold},
ss::Union{Nothing, Number}
)
set_all_smip_constraints!(
model::Model,
wb::WeightBounds,
card::Union{Nothing, Integer},
gcard::Union{Nothing, LinearConstraint},
smtx::Union{Nothing, AbstractMatrix{<:Union{var"#s34", var"#s33"} where {var"#s34"<:Number, var"#s33"<:AbstractJuMPScalar}}},
lt::Union{Nothing, Threshold},
st::Union{Nothing, Threshold},
ss::Union{Nothing, Number},
i::Integer
)Add all sub-group MIP constraints for a single or multiple selection matrices.
The single-matrix method runs the shared indicator builder (run_mip_builder!) on a SubsetMIPSpace — applying long/short thresholds and weight bounds — then emits the sub-group cardinality and group-cardinality constraints through the same space-generic emitters as the asset space (set_card_constraints!, set_gcard_constraints!). The vector method iterates over collections of cardinalities, group constraints, and selection matrices.
Arguments
model::JuMP.Model: The JuMP optimisation model.wb::WeightBounds: Weight bound specification containing lower and upper bounds.card: Cardinality bound(s) for the sub-group(s).gcard: Group-cardinality constraint(s) for the sub-group(s).smtx: Selection matrix (or vector thereof) for the sub-group(s).lt: Long-side minimum-holding threshold(s).st: Short-side minimum-holding threshold(s).ss::Option{<:Number}: Big-M scaling constant (computed viaget_mip_sswhennothing).i::Integer = 1: Index for generating unique names (single-matrix method only).
Returns
nothing.
Related
PortfolioOptimisers.set_scardmip_constraints! Function
set_scardmip_constraints!(
model::Model,
wb::WeightBounds,
card::Union{Nothing, Integer},
smtx::Union{Nothing, AbstractMatrix{<:Union{var"#s34", var"#s33"} where {var"#s34"<:Number, var"#s33"<:AbstractJuMPScalar}}},
lt::Union{Nothing, Threshold},
st::Union{Nothing, Threshold},
ss::Union{Nothing, Number}
)
set_scardmip_constraints!(
model::Model,
wb::WeightBounds,
card::Union{Nothing, Integer},
smtx::Union{Nothing, AbstractMatrix{<:Union{var"#s34", var"#s33"} where {var"#s34"<:Number, var"#s33"<:AbstractJuMPScalar}}},
lt::Union{Nothing, Threshold},
st::Union{Nothing, Threshold},
ss::Union{Nothing, Number},
i::Integer
)Add sub-group cardinality MIP constraints using a selection matrix.
The single-matrix method runs the shared indicator builder (run_mip_builder!) on the sub-group and enforces sum(sib) ≤ card through set_card_constraints!. The vector method iterates over collections of cardinalities and selection matrices.
Arguments
model::JuMP.Model: The JuMP optimisation model.wb::WeightBounds: Weight bound specification containing lower and upper bounds.card: Cardinality bound(s) for the sub-group(s).smtx: Selection matrix (or vector thereof).lt: Long-side minimum-holding threshold(s).st: Short-side minimum-holding threshold(s).ss::Option{<:Number}: Big-M scaling constant (computed viaget_mip_sswhennothing).i::Integer = 1: Index for generating unique names (single-matrix method only).
Returns
nothing.
Related
sourcePortfolioOptimisers.set_sgcardmip_constraints! Function
set_sgcardmip_constraints!(
model::Model,
wb::WeightBounds,
gcard::Union{Nothing, LinearConstraint},
smtx::Union{Nothing, AbstractMatrix{<:Union{var"#s34", var"#s33"} where {var"#s34"<:Number, var"#s33"<:AbstractJuMPScalar}}},
lt::Union{Nothing, Threshold},
st::Union{Nothing, Threshold},
ss::Union{Nothing, Number}
)
set_sgcardmip_constraints!(
model::Model,
wb::WeightBounds,
gcard::Union{Nothing, LinearConstraint},
smtx::Union{Nothing, AbstractMatrix{<:Union{var"#s34", var"#s33"} where {var"#s34"<:Number, var"#s33"<:AbstractJuMPScalar}}},
lt::Union{Nothing, Threshold},
st::Union{Nothing, Threshold},
ss::Union{Nothing, Number},
i::Integer
)Add sub-group group-cardinality MIP constraints using a selection matrix.
The single-matrix method runs the shared indicator builder (run_mip_builder!) on the sub-group and enforces the linear group cardinality constraints A * sib ≤ B and A * sib = B through set_gcard_constraints!. The vector method iterates over multiple group constraints and selection matrices.
Arguments
model::JuMP.Model: The JuMP optimisation model.wb::WeightBounds: Weight bound specification containing lower and upper bounds.gcard: Group-cardinality constraint(s).smtx: Selection matrix (or vector thereof).lt: Long-side minimum-holding threshold(s).st: Short-side minimum-holding threshold(s).ss::Option{<:Number}: Big-M scaling constant (computed viaget_mip_sswhennothing).i::Integer = 1: Index for generating unique names (single-matrix method only).
Returns
nothing.
Related
sourcePortfolioOptimisers.set_smip_constraints! Function
set_smip_constraints!(
model::Model,
wb::WeightBounds,
card::Union{Nothing, Integer, AbstractVector{<:Integer}},
gcard::Union{Nothing, LinearConstraint, AbstractVector{<:LinearConstraint}},
smtx::Union{Nothing, AbstractMatrix{<:Union{var"#s34", var"#s33"} where {var"#s34"<:Number, var"#s33"<:AbstractJuMPScalar}}, AbstractVector{<:AbstractMatrix{<:Union{var"#s34", var"#s33"} where {var"#s34"<:Number, var"#s33"<:AbstractJuMPScalar}}}},
sgmtx::Union{Nothing, AbstractMatrix{<:Union{var"#s34", var"#s33"} where {var"#s34"<:Number, var"#s33"<:AbstractJuMPScalar}}, AbstractVector{<:AbstractMatrix{<:Union{var"#s34", var"#s33"} where {var"#s34"<:Number, var"#s33"<:AbstractJuMPScalar}}}},
lt::Union{Nothing, Threshold, AbstractVector{<:Union{Nothing, var"#s823"} where var"#s823"<:Threshold}},
st::Union{Nothing, Threshold, AbstractVector{<:Union{Nothing, var"#s823"} where var"#s823"<:Threshold}},
glt::Union{Nothing, Threshold, AbstractVector{<:Union{Nothing, var"#s823"} where var"#s823"<:Threshold}},
gst::Union{Nothing, Threshold, AbstractVector{<:Union{Nothing, var"#s823"} where var"#s823"<:Threshold}},
ss::Union{Nothing, Number}
)Add all sub-group MIP constraints (both cardinality and group-cardinality) to the JuMP optimisation model.
Dispatches between combined selection matrices (calling set_all_smip_constraints!) and separate cardinality/group-cardinality selection matrices (calling set_scardmip_constraints! and set_sgcardmip_constraints! independently).
Arguments
model::JuMP.Model: The JuMP optimisation model.wb::WeightBounds: Weight bound specification containing lower and upper bounds.card: Cardinality bound(s).gcard: Group-cardinality constraint(s).smtx: Cardinality selection matrix (or vector thereof).sgmtx: Group-cardinality selection matrix (or vector thereof).lt: Long-side minimum-holding threshold(s) for cardinality sub-groups.st: Short-side minimum-holding threshold(s) for cardinality sub-groups.glt: Long-side minimum-holding threshold(s) for group-cardinality sub-groups.gst: Short-side minimum-holding threshold(s) for group-cardinality sub-groups.ss::Option{<:Number}: Big-M scaling constant (computed viaget_mip_sswhennothing).
Returns
nothing.
Related