| Prev | Next |  |  |  |  |  |  |

abs_normal: Solve a Quadratic Program With Box Constraints
Syntax
`ok = qp_box(
level, a, b, c, C, g, G, epsilon, maxitr, xin, xout
)`
Prototype

    template <class Vector>
    bool qp_box(
         size_t        level   ,
         const Vector& a       ,
         const Vector& b       ,
         const Vector& c       ,
         const Vector& C       ,
         const Vector& g       ,
         const Vector& G       ,
         double        epsilon ,
         size_t        maxitr  ,
         const Vector& xin     ,
         Vector&       xout    )

Source
This following is a link to the source code for this example: qp_box.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 a ∈ R n , b ∈ R n , c ∈ R m , C ∈ R m × n , g ∈ R n , G ∈ R n × n , where G is positive semi-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 and a ≤ x ≤ b The matrix G + C T C must be positive definite on components of the vector x where the lower limit minus infinity and the upper limit is plus infinity; see `a` and `b` below.
Vector
The type `Vector` is a simple vector with elements of type `double`.
level
This value is less that or equal two. If `level == 0` , no tracing is printed. If `level >= 1` , a trace of the `qp_box` operations is printed. If `level == 2` , a trace of the qp_interior sub-problem is printed.
a
This is the vector of lower limits for x in the problem. If `a[j]` is minus infinity, there is no lower limit for x j .
b
This is the vector of upper limits for x in the problem. If `a[j]` is plus infinity, there is no upper limit for x j .
c
This is the value of the inequality constraint function at x = 0 .
C
This is a row-major representation of thee the inequality constraint matrix C .
g
This is the gradient of the objective function.
G
This is a row-major representation of the Hessian of the objective function. For j = 0 , … , n -1 , - ∞ < a j or b j < + ∞ or G j , j > 0.0 .
epsilon
This argument is the convergence criteria; see KKT conditions below. It must be greater than zero.
maxitr
This is the maximum number of qp_interior 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., `
a < xin, xin < b, C * xin - c < 0
`
xout
This argument has size is `n` and the input value of its elements does no matter. Upon return it is the primal variables x corresponding to the problem solution.
ok
If the return value `ok` is true, convergence is obtained; i.e., | F ( x , y a , s a , y b , s b , y c , s c ) | ∞ < ε where | v | ∞ is the infinity norm of the vector v , ε is `epsilon` , x is equal to `xout` , y a , s a ∈ R + n , y b , s b ∈ R + n and y c , s c ∈ R + m .
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 ( x , y a , s a , y b , s b , y c , s c ) = ( g + G x - y a + y b + y c T C a + s a - x x + s b - b C x + c + s c D ( s a ) D ( y a ) 1 m D ( s b ) D ( y b ) 1 m D ( s c ) D ( y c ) 1 m ) where x ∈ R n , y a , s a ∈ R + n , y b , s b ∈ R + n and y c , s c ∈ R + m . The KKT conditions for a solution of this problem is F ( x , y a , s a , y b , s b , y c , s c ) = 0
Example
The file qp_box.cpp contains an example and test of `qp_box`. It returns true if the test passes and false otherwise.

Input File: example/abs_normal/qp_box.hpp