\(\newcommand{\W}[1]{ \; #1 \; }\) \(\newcommand{\R}[1]{ {\rm #1} }\) \(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} }\) \(\newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} }\) \(\newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} }\) \(\newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }\)
qp_interior¶
View page sourceSolve a Quadratic Program Using Interior Point Method¶
Syntax¶
qp_interior
(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 \in \B{R}^{m \times n}\), \(c \in \B{R}^m\), \(G \in \B{R}^{n \times n}\), \(g \in \B{R}^n\), where \(G\) is positive semi-definite and \(G + C^T C\) is positive definite. This routine solves the problem
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.
Lower c¶
This is the vector \(c\) in the problem.
Upper C¶
This is a row-major of the matrix \(C\) in the problem.
Lower g¶
This is the vector \(g\) in the problem.
Upper 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.,
where \(| v |_\infty\) is the maximum absolute element for the vector \(v\) and \(F_\mu (x, y, s)\) is defined below.
KKT Conditions¶
Give a vector \(v \in \B{R}^m\) we define \(D(v) \in \B{R}^{m \times m}\) as the corresponding diagonal matrix. We also define \(1_m \in \B{R}^m\) as the vector of ones. We define \(F_\mu : \B{R}^{n + m + m } \rightarrow \B{R}^{n + m + m}\) by
The KKT conditions for a solution of this problem is \(0 \leq y\), \(0 \leq s\), and \(F_0 (x , y, s) = 0\).
Newton Step¶
The derivative of \(F_\mu\) is given by
The Newton step solves the following equation for \(\Delta x\), \(\Delta y\), and \(\Delta z\)
To simplify notation, we define
It follows that
Elementary Row Reduction¶
Subtracting \(D(y)\) times the second row from the third row we obtain:
Multiplying the third row by \(D(s)^{-1}\) we obtain:
where \(y/s\) is the vector in \(\B{R}^m\) defined by \((y/s)_i = y_i / s_i\). Subtracting \(C^T\) times the third row from the first row we obtain:
Solution¶
It follows that \(G + C^T D(y/s) C\) is invertible and we can determine \(\Delta x\) by solving the equation
Given \(\Delta x\) we have that
Example¶
The file qp_interior.cpp contains an example and test of
qp_interior
.