Base Constraint Generation

PortfolioOptimisers.ComparisonOperatorType
const ComparisonOperator = Union{typeof(==), typeof(<=), typeof(>=)}

Union type representing supported comparison operators for constraint generation.

This type is used to specify which comparison operators are valid for defining constraints. It includes equality and both directions of inequality.

Related

source
PortfolioOptimisers.comparison_sign_ineq_flagFunction
comparison_sign_ineq_flag(op::ComparisonOperator)

Return the multiplicative sign and inequality flag for a given comparison operator.

Arguments

  • op::ComparisonOperator: The comparison operator.

Returns

  • sign::Int: The multiplicative sign for the constraint.
  • is_inequality::Bool: true if the operator is an inequality, false for equality.

Examples

julia> PortfolioOptimisers.comparison_sign_ineq_flag(==)(1, false)julia> PortfolioOptimisers.comparison_sign_ineq_flag(<=)(1, true)julia> PortfolioOptimisers.comparison_sign_ineq_flag(>=)(-1, true)

Related

source
PortfolioOptimisers.resolve_axis_nameFunction
resolve_axis_name(name, nx::AbstractVector, sdict::AbstractDict) -> Option{Vector}

Resolve one name against an axis: an axis entry names itself, a sdict key expands to its members, and an unknown name gives nothing.

This is the precedence every name-taking constraint generator uses — asset first, then group — written once. The caller diagnoses the nothing, because the suggestion pool differs by caller. The member vector is a copy: sdict is the caller's UniverseSets dictionary, which is configuration reused across folds and optimisers, so de-duplication must never edit it.

Arguments

  • name: The name to resolve.
  • nx: The axis, usually the asset universe.
  • sdict: Dictionary mapping group names to vectors of member names.

Returns

  • [name] if name is on the axis.
  • unique(members) if name is a key of sdict.
  • nothing if name is neither.

Related

source
PortfolioOptimisers.axis_name_indicesFunction
axis_name_indices(members, nx::AbstractVector, on_missing) -> Vector

Map resolved member names to axis indices, drop the members that miss the axis, and report them once through on_missing.

on_missing takes the vector of missing members and decides the policy, so a caller can throw, warn, or stay silent without a second copy of the mapping. on_missing is not called when every member is on the axis.

Arguments

  • members: Member names, as resolve_axis_name returns them.
  • nx: The axis, usually the asset universe.
  • on_missing: Callable applied to the vector of members that miss the axis.

Returns

  • idx: Axis indices of the members that are on the axis, in the order of members.

Related

source