-
Notifications
You must be signed in to change notification settings - Fork 0
User Guides
LightenQP follows closely the the implementation of the C/C++ solver OOQP
Object
Q = OOQP(V, A, C, q, b, g)
or
Q = OOQP(V, q; A=A, b=b, C=C, g=g)
defines the standard OOQP
model:
For the
OOQP(V, q; kwargs...)
the default values are (
A = ones(1,N), b = [1], C = -I, g = zeros(N)
Hence, OOQP(V, q)
defines the following default model (no short sale in portfolio selection):
For portfolio optimization, OOQP(V, q, u)
defines
While OOQP(V, A, C, q, b, g, d, u)
defines the FP(L=-1)
model: (OOQP + 'd≤z≤u'
)
Why call it FP(L=-1)
? It is the trade-off coefficient
Let Q
be an OOQP
object , we can solve it by
x, status = solveOOQP(Q; settings=Settings())
the output x
and status
:
x::Solution : structure containing the primal solution 'x', dual variables 'y' and 'z' corresponding to the equality
and inequality multipliers respectively, and slack variables 's'
status::Int : > 0 if successful (=iter_count), 0 if infeasibility detected, < 0 if not converged (=-iter_count)
Using mpcQP
, we can solve a QP model without first defining an OOQP
object.
mpcQP
wraps OOQP(...) + solveOOQP(...)
, and solves QP in the following forms:
-
x, status = mpcQP(V, q, A, b, C, g; settings)
solves the standardOOQP
model -
x, status = mpcQP(V, q, A, b, C, g, d, u; settings)
solves theOOQP + 'd≤x≤u'
model (FP(L=-1)
model ) -
x, status = mpcQP(V, q, d, u; settings)
solves theOOQP + 'd≤x≤u' - 'Ax=b, Cx≤g'
model
-
x, status = mpcQP(V, q, C, g, d, u, h; settings)
solves theOOQP + 'd≤x≤u' + 'h≤Cx' - 'Ax=b'
model
-
x, status = mpcQP(V, q, A, b, C, g, d, u, h; settings)
solves theOOQP + 'd≤x≤u' + 'h≤Cx'
model
Given OOQP
object O
,
fPortfolio(O::OOQP, L=0; settings)
fPortfolio(mu, O::OOQP; settings)
solve the following portfolio optimization model: as an illustration, let O
be a FP(L=-1)
model
-
fPortfolio(O)
: forFP(L=0)
, LVEP (Lowest Variance Efficient Portfolio, also called GMVP, Global Minimum Variance Portfolio), by setting$\mathbf{q}=0$ ($L=0$ in EfficientFrontier)
-
fPortfolio(O, -Inf)
: forFP(L=-Inf)
, LMFP (Lowest Mean Frontier Portfolio)
where mpcLP(O)
-
fPortfolio(O, Inf)
: forFP(L=Inf)
, HMFP (Highest Mean Frontier Portfolio), or HVEP (Highest Variance Efficient Portfolio), is the highest expected return efficient portfolio
where mpcLP(O; min=false)
-
fPortfolio(mu0, O)
: forFP(mu=mu0)
, the frontier (minimum variance) portfolio at$\mu=\mu_0$ . By removing$\mathbf{z}^{\prime}\mathbf{q}$ term in the objective function, and adding$\mathbf{q}^{\prime}\mathbf{z}=\mu_0$ to the equality constraints
-
fPortfolio(O, L0)
: forFP(L=L0)
, the frontier (minimum variance) portfolio at$L=L_0$ . By setting$\mathbf{q}\to -L_0\mathbf{q}$ ($L=L_0$ in EfficientFrontier )
Hints: L
version fPortfolio(O, L0)
is better than mu
version fPortfolio(mu0, O)
. Since they are less constrains, L
versions present faster speed, better numerical stability and accuracy.
Solving a LP through solveOOQP
, surely is not efficient since it is a QP solver.
x, status = mpcLP(O::OOQP; settings)
It simply set
x, status = mpcLP(O::OOQP; min=false)
to maximize the objective function
x, status = mpcLP(q, A, b, C, g; settings)
solve the following LP model (keyword argument min=false
to maximize)
and
x, status = mpcLP(q, A, b, C, g, d, u; settings)
solve the following LP model (keyword argument min=false
to maximize)
The fields of struct Settings
are (for Float64
)
struct Settings{T<:AbstractFloat}
maxIter::Int64 #777
scaleStep::T #0.99 a crude step scaling factor (using Mehrotra's heuristic maybe better)
tol::T #2^-26 ≈ 1.5e-8 general (not use in OOQP solver)
tolMu::T #2^-52 ≈ 2.2e-16 violation of the complementary condition
tolR::T #2^-49 ≈ 1.8e-15 norm(resid) <= tolR * norm(OOQP)
minPhi::T #2^23 = 8388608 ≈ 1e7 phi_min_history, not a foolproof test
end