Sparse portfolio algorithms: private API
PortfolioOptimisers.huber_coordinates — Function
huber_coordinates(
alg::HuberOptimum,
phi::AbstractVector,
nu::Real
) -> Any
Computes the coordinates of HuberOptimum at the multiplier nu, each clamped to [-gamma, gamma].
The docstring of HuberOptimum states the formula of the coordinates.
Related
PortfolioOptimisers.huber_multiplier — Function
huber_multiplier(
alg::HuberOptimum,
phi::AbstractVector,
lo::Real,
hi::Real
) -> Any
Finds the multiplier of HuberOptimum in [lo, hi].
The sum of the coordinates is linear between two knots, so the linear interpolation between the two knots that bracket the root gives the root.
Algorithm
- Compute
budget(nu), the sum of the coordinates ofhuber_coordinatesat a multipliernu. - When
budget(lo) <= 1, returnlo. Whenbudget(hi) >= 1, returnhi. - Collect the knots
-phi .- lambdaand-phi .+ lambdathat lie strictly betweenloandhi, givinginner. - Sort
inner, and putlobefore it andhiafter it, givingknots. - Compute
sums, the budget at each knot. - Find the first knot
iwhose sum is at most one. - Interpolate linearly between the knots
i - 1andi, and return the multiplier where the budget is one.
Related
PortfolioOptimisers.huber_remainder! — Function
huber_remainder!(
b::AbstractVector,
phi::AbstractVector
) -> AbstractVector
Adds the remainder of the budget to b in place, in equal parts between tied assets.
At an end of the interval of the multiplier, the assets that take the remainder are the assets where the Huber penalty is linear, so they can hold any amount past gamma. Inside the interval the remainder is rounding.
Algorithm
- Compute the remainder
r = 1 - sum(b). - Find the assets
K, which have the smallest entry ofphiwhenris not negative, and the largest entry whenris negative. - Add
r / count(K)to each asset ofK, and returnb.
Related