Near optimal centering (b): private API

PortfolioOptimisers.assemble_near_optimal_centering_model! — Method
assemble_near_optimal_centering_model!(alg, model, noc, setup, rd; blocks = ())

Run the model-assembly middle of the Near Optimal Centering variant alg.

The two variants share a head and a Result, and differ only in the middle and in the solve. This is the middle. ConstrainedNearOptimalCentering delegates to the shared assemble_jump_model!, whose block builder adds every block, the weight bounds and the budgets among them. UnconstrainedNearOptimalCentering adds the weight bounds and the budgets of opt with set_weight_constraints!, and the weight bounds and the budgets of each block after the first with set_block_weight_constraints!. It adds no other row of a block. It then runs the four steps of that sequence it needs — non-fixed fees, risk, scalarisation, return — and then the same assert_frontier_sweep_cap tail.

set_non_fixed_fees! runs before the risk build, as it does in assemble_jump_model!. It is what makes the model's return expression net of fees, and the barrier compares that expression against the noc_rt target, which near_optimal_centering_setup computes net of fees as well. A fixed fee still does not apply: it needs the cardinality binaries set_mip_constraints! produces, and that builder belongs to the middle this variant does not run.

UnconstrainedNearOptimalCentering lists every opt setting the resulting model reads and every setting it does not.

The unconstrained variant reads setup.opt, which near_optimal_centering_setup has already replaced with the no_bounds_optimiser copy. So opt.ret is the bound-free return estimator, and opt.pe, opt.fees and opt.sca are the processed values setup.attrs carries. The phylogeny argument is nothing because the variant applies no phylogeny constraints.

Arguments

Returns

  • nothing. Mutates model in place.

Related

source
PortfolioOptimisers.anchor_cone_scale — Function
anchor_cone_scale(delta::Num_VecNum, anchor::Num_VecNum)

Return the scale that divides the slack of an anchor cone of the barrier of NearOptimalCentering.

The scale is the width delta of the near optimal region, which is the slack of the cone at the anchor of the objective. When the width is negligible against the bound anchor, the scale is one, and the cone keeps its slack in the units of the bound. The anchors of a degenerate region are one portfolio, so its width is of the order of the rounding error. A slack divided by that width puts the tolerance of the solver at the scale of the rounding error, and the solve stops without progress. The width can also be negative by a rounding error, so the bound sits outside the region by that error. A scale below one makes the error larger. With the anchors of the factor exposure test of test_02, a width of -1.1e-13 and a risk bound of 0.0073, the slack divided by the bound stopped at NUMERICAL_ERROR under --check-bounds=yes and coverage, and the slack in the units of the bound solved.

Algorithm

  1. Compute $s = \max_{i} |\delta_{i}|$ and $m$, the bound_scale of anchor.
  2. Return $1$ when isapprox(m + s, m), and $s$ otherwise.

Arguments

  • delta::Num_VecNum: The width, rk_delta or rt_delta of NearOptimalSetup.
  • anchor::Num_VecNum: The bound of the cone, rk_opt or rt_opt, or one for each point of a sweep.

Returns

  • The scale, a positive number.

Related

source
PortfolioOptimisers.solve_near_optimal_centering! — Method
solve_near_optimal_centering!(alg, model, noc, setup)

Run the solve tail of the Near Optimal Centering variant alg.

Reads the arguments each solve_noc! overload needs off setup, so the two variants share one _optimise head. The constrained variant sweeps both frontier registries, so it passes the two Val flags that select the sweeping overload; the unconstrained variant registers no frontier bound and passes neither. Both variants pass the anchor_cone_scale of the widths rk_delta and rt_delta of the near optimal region, which divide the anchor cones of the barrier.

Arguments

Returns

  • (retcode, sol) or (retcodes, sols), as solve_noc! returns.

Related

source
PortfolioOptimisers.get_overall_retcode — Function
get_overall_retcode(w_min_retcode, w_opt_retcode, w_max_retcode, noc_retcode)

Compute the overall optimisation return code from individual sub-problem return codes.

Combines the return codes from the minimum, optimal, and maximum weight sub-problems with the near-optimal centering return code to determine the overall status.

Arguments

  • w_min_retcode: Return code from the minimum weight sub-problem.
  • w_opt_retcode: Return code from the optimal weight sub-problem.
  • w_max_retcode: Return code from the maximum weight sub-problem.
  • noc_retcode: Return code from the near-optimal centering sub-problem.

Returns

  • OptimisationSuccess() if every sub-problem succeeded; otherwise an OptimisationFailure whose res is a named tuple (; msg, w_min, w_opt, w_max, noc_opt) carrying the failure summary and the individual sub-problem return codes (including their solver trial diagnostics).

Related

source
PortfolioOptimisers.compute_risk_ubs — Method
compute_risk_ubs(model::JuMP.Model, noc::NearOptimalCentering{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:ConstrainedNearOptimalCentering}, pr::AbstractPriorResult, fees::Option{<:Fees}, w_min::VecNum, w_max::VecNum, args...)

Compute risk upper bounds for a constrained NearOptimalCentering frontier sweep.

Identifies risk frontier entries that are not yet resolved (i.e. not concrete weight vectors) and rebuilds them using the minimum and maximum portfolio weights.

Arguments

  • model::JuMP.Model: JuMP optimisation model containing risk_frontier.
  • noc::NearOptimalCentering{..., <:ConstrainedNearOptimalCentering}: Constrained Near Optimal Centering optimiser.
  • pr::AbstractPriorResult: Prior result with asset moments.
  • fees::Option{<:Fees}: Optional fees configuration.
  • w_min::VecNum: Minimum-risk portfolio weights.
  • w_max::VecNum: Maximum-risk (maximum-return) portfolio weights.

Returns

  • Updated risk frontier vector of (keys, vals) pairs.

Related

source