qp_solve — linear quadratic programming solver builtin
[x [,iact [,iter [,f]]]]=qp_solve(Q,p1,C1,b,me)
real positive definite symmetric matrix (dimension n
x n).
real (column) vector (dimension n)
real matrix (dimension (me + md) x n).
This matrix may be stored as either a dense matrix either a sparse
one.
RHS column vector (dimension (me +
md))
number of equality constraints (i.e. x'*C(:,1:me) =
b(1:me)')
optimal solution found.
vector, indicator of active constraints. The first non zero entries give the index of the active constraints
. 2x1 vector, first component gives the number of "main" iterations, the second one says how many constraints were deleted after they became active.
Minimize 0.5*x'*Q*x - p'*x
under the constraints
x' C(:,j) = b(j), j=1,...,me
x' C(:,j) >= b(j), j=me+1,...,me+md
This function requires Q to be positive definite,
if it is not the case, one may use the contributed quapro toolbox.
This is a builtin associated with the Berwin A. Turlach code. Use preferabily the qpsolve function built on it which handles variable boundaries and match the quapro problem definition
//Find x in R^6 such that:
//x'*C1 = b1 (3 equality constraints i.e me=3)
C1= [ 1,-1, 2;
-1, 0, 5;
1,-3, 3;
0,-4, 0;
3, 5, 1;
1, 6, 0];
b1=[1;2;3];
//x'*C2 >= b2 (2 inequality constraints)
C2= [ 0 ,1;
-1, 0;
0,-2;
-1,-1;
-2,-1;
1, 0];
b2=[ 1;-2.5];
//and minimize 0.5*x'*Q*x - p'*x with
p=[-1;-2;-3;-4;-5;-6]; Q=eye(6,6);
me=3;
[x,iact,iter,f]=qp_solve(Q,p,[C1 C2],[b1;b2],me)
//Only linear constraints (1 to 4) are active
The contributed toolbox "quapro" may also be of interest, in
particular for singular Q.