Skip to content
PharosAbad edited this page Jan 25, 2023 · 7 revisions

Welcome to the LightenQP.jl wiki!

OOQP Standard Model

Following closely the the implementation of the C/C++ solver OOQP, LightenQP.jl solves the following convex quadratic programming problems (Let us call it by OOQP)

$$ \begin{array} [c]{cl} \min & \frac{1}{2}\mathbf{x}^{\prime}\mathbf{Vx}+\mathbf{x}^{\prime}% \mathbf{q}\\ s.t. & \mathbf{Ax}=\mathbf{b}\in\mathbb{R}^{M}\\ & \mathbf{Cx}\leq\mathbf{g}\in\mathbb{R}^{L} \end{array} $$

with positive semi-definite symmetric matrix $\mathbf{V}\in\mathbb{R}^{N\times N}$.

Given this solver, a general quadratic programming formulation (OOQP + d≤x≤u + h≤Cx)

$$ \begin{array} [c]{cl} \min & \frac{1}{2}\mathbf{x}^{\prime}\mathbf{Vx}+\mathbf{x}^{\prime} \mathbf{q}\\ s.t. & \mathbf{Ax}=\mathbf{b}\in\mathbb{R}^{M}\\ & \mathbf{h}\leq\mathbf{Cx}\leq\mathbf{g}\in\mathbb{R}^{L}\\ & \boldsymbol{d}\leq\mathbf{x}\leq\boldsymbol{u}\in\mathbb{R}^{N} \end{array} $$

is solved by LightenQP easily, by packaging d≤x≤u + h≤Cx into Cx≤g using mpcQP(V, q, A, b, C, g, d, u, h; settings).

Examples

A Quick Example

using LightenQP

V = [1/100 1/80 1/100
     1/80 1/16 1/40
     1/100 1/40 1/25]
E = [109 / 100; 23 / 20; 119 / 100]

u = [0.7; +Inf; 0.7]
Q = OOQP(V, -E, u)   #OOQP + bounds 0 <= x <= u
x, status = solveOOQP(Q)  #solve by Algorithm MPC (Mehrotra Predictor-Corrector)

outputs

(LightenQP.Solution{Float64}([1.5778379780916563e-14, 0.2999999999999846, 0.6999999999999996], [-1.113750000000001], [0.03450000000000125, 2.288436564531734e-16, 1.1948863025210983e-15, 3.1756152439630536e-16, 0.040750000000000446], [1.5778381702536896e-14, 0.29999999999998467, 0.6999999999999994, 0.6999999999999842, 4.294136336840918e-16]), 15)

where

    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)

Hence, to retrieve the optimal solution

x.x

gives

3-element Vector{Float64}:
 1.5778379780916563e-14
 0.2999999999999846
 0.6999999999999996

Portfolio Selection on S&P 500

An real data on SP500