| Prev | Next |  |  |  |  |  |  |

Solve a Quadratic Program Using Interior Point Method
Syntax
`ok = qp_interior(
level, c, C, g, G, epsilon, maxitr, xin, xout, yout, sout
)`
Prototype

    template <class Vector>
    bool qp_interior(
         size_t        level   ,
         const Vector& c       ,
         const Vector& C       ,
         const Vector& g       ,
         const Vector& G       ,
         double        epsilon ,
         size_t        maxitr  ,
         const Vector& xin     ,
         Vector&       xout    ,
         Vector&       yout    ,
         Vector&       sout    )

Source
This following is a link to the source code for this example: qp_interior.hpp .
Purpose
This routine could be used to create a version of abs_min_linear that solved Quadratic programs (instead of linear programs).
Problem
We are given C ∈ R m × n , c ∈ R m , G ∈ R n × n , g ∈ R n , where G is positive semi-definite and G + C T C is positive definite. This routine solves the problem minimize 1 2 x T G x + g T x w . r . t x ∈ R n subject to C x + c ≤ 0
Vector
The type `Vector` is a simple vector with elements of type `double`.
level
This value is zero or one. If `level == 0` , no tracing is printed. If `level == 1` , a trace of the `qp_interior` optimization is printed.
c
This is the vector c in the problem.
C
This is a row-major of the matrix C in the problem.
g
This is the vector g in the problem.
G
This is a row-major of the matrix G in the problem.
epsilon
This argument is the convergence criteria; see KKT conditions below. It must be greater than zero.
maxitr
This is the maximum number of newton iterations to try before giving up on convergence.
xin
This argument has size `n` and is the initial point for the algorithm. It must strictly satisfy the constraints; i.e., C x - c < 0 for `x = xin` .
xout
This argument has size is `n` and the input value of its elements does no matter. Upon return it is the primal variables corresponding to the problem solution.
yout
This argument has size is `m` and the input value of its elements does no matter. Upon return it the components of `yout` are all positive and it is the dual variables corresponding to the program solution.
sout
This argument has size is `m` and the input value of its elements does no matter. Upon return it the components of `sout` are all positive and it is the slack variables corresponding to the program solution.
ok
If the return value `ok` is true, convergence is obtained; i.e., | F 0 ( xout , yout , sout ) | ∞ ≤ epsilon where | v | ∞ is the maximum absolute element for the vector v and F μ ( x , y , s ) is defined below.
KKT Conditions
Give a vector v ∈ R m we define D ( v ) ∈ R m × m as the corresponding diagonal matrix. We also define 1 m ∈ R m as the vector of ones. We define F μ : R n + m + m → R n + m + m by F μ ( x , y , s ) = ( g + G x + y T C C x + c + s D ( s ) D ( y ) 1 m - μ 1 m ) The KKT conditions for a solution of this problem is 0 ≤ y , 0 ≤ s , and F 0 ( x , y , s ) = 0 .
Newton Step
The derivative of F μ is given by F μ ( 1 ) ( x , y , s ) = ( G C T 0 n , m C 0 I m , m 0 m , m D ( s ) D ( y ) ) The Newton step solves the following equation for Δ x , Δ y , and Δ z F μ ( 1 ) ( x , y , s ) ( Δ x Δ y Δ s ) = - F μ ( x , y , s ) To simplify notation, we define r x ( x , y , s ) = g + G x + y T C r y ( x , y , s ) = C x + c + s r s ( x , y , s ) = D ( s ) D ( y ) 1 m - μ 1 m It follows that ( G C T 0 n , m C 0 I m , m 0 m , m D ( s ) D ( y ) ) ( Δ x Δ y Δ s ) = - ( r x ( x , y , s ) r y ( x , y , s ) r s ( x , y , s ) )
Elementary Row Reduction
Subtracting D ( y ) times the second row from the third row we obtain: ( G C T 0 n , m C 0 I m , m - D ( y ) C D ( s ) 0 m , m ) ( Δ x Δ y Δ s ) = - ( r x ( x , y , s ) r y ( x , y , s ) r s ( x , y , s ) - D ( y ) r y ( x , y , s ) ) Multiplying the third row by D ( s ) -1 we obtain: ( G C T 0 n , m C 0 I m , m - D ( y / s ) C I m , m 0 m , m ) ( Δ x Δ y Δ s ) = - ( r x ( x , y , s ) r y ( x , y , s ) D ( s ) -1 r s ( x , y , s ) - D ( y / s ) r y ( x , y , s ) ) where y / s is the vector in R m defined by ( y / s ) i = y i / s i . Subtracting C T times the third row from the first row we obtain: ( G + C T D ( y / s ) C 0 n , m 0 n , m C 0 I m , m - D ( y / s ) C I m , m 0 m , m ) ( Δ x Δ y Δ s ) = - ( r x ( x , y , s ) - C T D ( s ) -1 [r s ( x , y , s ) - D ( y ) r y ( x , y , s ) ] r y ( x , y , s ) D ( s ) -1 r s ( x , y , s ) - D ( y / s ) r y ( x , y , s ) )
Solution
It follows that G + C T D ( y / s ) C is invertible and we can determine Δ x by solving the equation [ G + C T D ( y / s ) C ] Δ x = C T D ( s ) -1 [r s ( x , y , s ) - D ( y ) r y ( x , y , s ) ] - r x ( x , y , s ) Given Δ x we have that Δ s = - r y ( x , y , s ) - C Δ x Δ y = D ( s ) -1 [ D ( y ) r y ( x , y , s ) - r s ( x , y , s ) + D ( y ) C Δ x ]
Example
The file qp_interior.cpp contains an example and test of `qp_interior`. It returns true if the test passes and false otherwise.

Input File: example/abs_normal/qp_interior.hpp