Allocation Set programme
set_allocation_set_constraints! adds the constraints of a ProgrammeAllocationSet to a JuMP model, in the order a JuMP optimiser adds them. The model is the projection of a raw step onto the set of allowed weights. A follow-the-leader rule adds the same constraints to the optimisation it solves again at each period, through a private function that registers them under other names, so the rule keeps its own constraints and gains those of the set. When the projection does not solve, the rule keeps the weights it had after the price moves of the period, so it trades nothing in that period.
PortfolioOptimisers.set_allocation_set_constraints! — Function
set_allocation_set_constraints!(model::JuMP.Model, set::BoundedAllocationSet, w::AbstractVector, X, pr = nothing)
set_allocation_set_constraints!(model::JuMP.Model, set::BoundedAllocationSet, cbr::Nothing)
set_allocation_set_constraints!(model::JuMP.Model, set::ProgrammeAllocationSet, w::AbstractVector, X, pr = allocation_set_prior(set, X))
set_allocation_set_constraints!(model::JuMP.Model, set::ProgrammeAllocationSet, cbr::ResolvedConstraintBlock)Adds the constraints of a resolved Allocation Set to the bare projection model.
The model must already hold w, k, the two scales and the observation count. On both kinds of set the function adds the weight bounds and the budget of one. On a ProgrammeAllocationSet the projection is the owner of the model, and the set is the owner of its block. The projection writes the budget of one, and the block builder set_block_constraints! adds every kind of the block, which a JuMP optimiser adds through the same builder. The bounds builder set_allocation_risk_return_bounds! adds the risk ceilings and the return floor of the set between the two phases of the block.
The projection programme of project calls the three-argument form. It resolves the block of the set through the shared entry of a bare head, resolve_projection_entry, and gives the set viewed at the Investable Mask and the Result of its block. The four-argument and the five-argument forms are the direct call. They resolve the step themselves, on a model that already holds the width of w, so they cannot drop an asset. A direct call refuses an asset that the prior cannot price, with assert_set_prior_priced, and a distance reader of the set that refuses an asset raises its DistanceReaderRefusalError. A JuMP head does not call this function. The leader re-solve of FollowTheLeader passes the set as a second block of the entry of the head, and assemble_jump_model! adds the block with the same builders under the namespace blk_2_.
Algorithm
- In the direct call on a programme set, the default of
prfits the set's prior onXwithallocation_set_prior. - In the direct call on a programme set, resolve the step with
resolve_allocation_set_step, which gives the set afterfactory(set, w)and the Resultcbrof its block, and call the three-argument form. - On a bounded set, add the weight bounds and the budget of one with
set_allocation_set_bounds!, and returnset.wbwith no block Result. - On a programme set, add the budget of one with
set_budget_constraints!. Add the block, the ceilings and the floor withadd_allocation_set_block!under the empty prefix. Return the bounds of the step andcbr.
Arguments
model::JuMP.Model: The JuMP optimisation model.set: The Allocation Set, resolved once per fold. In the three-argument form, the set afterfactory(set, w), viewed at the Investable Mask of the step.w: The Price-Adjusted Allocation the step trades from. It is the reference of the turnover ceilings and of a tracking benchmark that is not fixed.X: The rows the head holds through the period, aReturnsResult, ornothing.pr: The prior result that the slots which read the rows are built on,allocation_set_priorof the set onX, ornothingwhen the set reads no rows.cbr: TheResolvedConstraintBlockof the set at the step, ornothingfor a bounded set.
Validation
- A slot that reads the rows, with
X === nothing. The default ofprthrows anArgumentError, because a projection gets the rows only inside an Online Update. - In the direct call, a prior whose Investable Mask leaves out an asset the model trades.
assert_set_prior_pricedthrows anArgumentError.
Returns
(wb, cbr)::Tuple: The weight bounds of the step that the model holds, and theResolvedConstraintBlockof the set, ornothingfor a bounded set. The projection programme ofprojectreads the floor ofwbunder a barrier geometry.
Related
PortfolioOptimisers.project — Method
project(proj::AbstractProjectionGeometry, e::Tuple, q::AbstractVector,
w::AbstractVector, X::Option{<:ReturnsResult})Builds and solves the projection programme of one step at the Investable Mask imsk, from the entry e = (imsk, set, cbr) that the shared entry resolved for the step.
resolve_projection_entry gives the entry. The method takes the three values as one Tuple, so a bounded set always comes with no block Result and a programme set with its own block Result. The entry already dropped every asset that a distance reader of the set refuses, so the model is built once, at the final mask. The refused asset takes a zero weight at the step, as an asset that the prior cannot price does. The Investable Mask of the Recursion Result does not change, because it is the active mask of the last row.
Algorithm
- Reduce the geometry and
qto the mask withinvestable_geometry_view. - Make a bare model with the set's two scales and the row count of
X, zero when there are no rows. Registerk = 1, and the vectorwof weight variables. - Add the set's constraints with the three-argument form of
set_allocation_set_constraints!. This gives the weight boundswbof the step. - Refuse a floor of
wbthat the geometry does not admit, withassert_geometry_admits_bounds. - Add the set's custom objective terms with the block builder
set_block_objective_terms!, with the geometry as the objective and the set as the owner. The terms readcbr. - Set the objective with
set_projection_objective!. - Solve on
projection_solverwithsolve_projection_programme!. When the solve gives an allocation, take its answer on the mask withprogramme_answer, and return it with a zero at every asset outside the mask. Otherwise record the Held Step with the solver trials, and return a copy ofw.
JuMP formulation
Variables
w: created, with the base namew, one variable for each asset in the mask. It is registered in the Model State under the keyw.
Expressions
k: the constant one.
Where:
- $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
- $k$: Variable that scales the budget in the homogenised problem.
Arguments
proj: The geometry.e: The entry of the step,(imsk, set, cbr): the Investable Mask of the step, ornothingwhen every asset is investable; the set afterfactory(set, w), viewed at the mask; and the Result of the block of a programme set, ornothingfor a bounded set.q: The raw step.w: The Price-Adjusted Allocation the step trades from.X: The rows of the step, ornothing.
Validation
- The rules of
assert_geometry_admits_boundson the bounds of the step.
Returns
w'::Vector: The projected allocation, orwcopied on a Held Step.
Related