solve.QP.compact(Dmat, dvec, Amat, Aind, bvec, meq=0, miter=1000, factorized=F)
Dmat
| an n times n matrix appearing in the quadratic function to be minimized. |
dvec
| a vector of length n appearing in the quadratic function to be minimized. |
Amat
| an m times q matrix containing in the first row of each column the non-zero elements of the corresponding column of the matrix A that defines the q constraints. (Hence, if mi denotes the number of non-zero elements in the i-th column of A then m will be the maximum of m1, m2,...{}, mq. If mi < m, then Amat will contain zeros in the i-th column from row mi+1 upto row m.) |
Aind
| a (m+1) times q matrix. In the first row each entry gives the number of non-zero elements in the corresponding column of the matrix A. The following entries in each column contain the indexes of the rows in which these non-zero elements are. |
bvec
| a vector of length q holding the values of b0 (defaults to zero). |
meq
| the first meq constraints are treated as equality constraints, all further as inequality constraints. 0 <= meq <= q, defaults to 0. |
miter
| maximum number of iteration allowed in the algorithm. (Actually not necessary since the algorithm is guaranteed to converge if D is positive definite and the constraints are consistent. Failure of either is detected, but miter is kept as additional safeguard.) |
factorized
| logical flag: if TRUE, then we are passing R^-1 (where D = R^T R) instead of the matrix D in the argument Dmat. |
solution
| a vector of length n containing the solution of the quadratic programming problem. |
value
| scalar, the value of the quadratic function at the solution |
unconstrained.solution
| a vector of lenth n containing the unconstrained minimizer of the quadratic function. |
iterations
| a vector of length 2, the first component contains the number of iterations the algorithm needed, the second indicates how often constraints became inactive again after becoming active first. vector of length p containing the indices of the active constraints at the solution. |
Goldfarb, D. and Idnani, A. (1983). A numerically stable dual method for solving strictly convex quadratic programs, Mathematical Programming, 27, 1-33.
# # Assume we want to minimize: -(0 5 0) %*% b + 1/2 b^T b # under the constraints: A^T b >= b0 # with b0 = (-8,2,0)^T # and (-4 2 0) # A = (-3 1 -2) # ( 0 0 1) # we can use solve.QP.compact as follows: # Dmat <- matrix(0,3,3) diag(Dmat) <- 1 dvec <- c(0,5,0) Aind <- c(2,2,2) Aind <- rbind(Aind,c(1,1,2)) Aind <- rbind(Aind,c(2,2,3)) Amat <- c(-4,2,-2) Amat <- rbind(Amat,c(-3,1,1)) bvec <- c(-8,2,0) solve.QP.compact(Dmat,dvec,Amat,Aind,bvec=bvec)