solve.QP.compact.RdThis routine implements the dual method of Goldfarb and Idnani (1982, 1983) for solving quadratic programming problems of the form \(\min(-d^T b + 1/2 b^T D b)\) with the constraints \(A^T b >= b_0\).
solve.QP.compact(Dmat, dvec, Amat, Aind, bvec, meq=0, factorized=FALSE)matrix appearing in the quadratic function to be minimized.
vector appearing in the quadratic function to be minimized.
matrix containing the non-zero elements of the matrix \(A\) that
defines the constraints. If \(m_i\) denotes the number of
non-zero elements in the \(i\)-th column of \(A\) then the first
\(m_i\) entries of the \(i\)-th column of Amat hold these
non-zero elements. (If \(maxmi\) denotes the maximum of all
\(m_i\), then each column of Amat may have arbitrary
elements from row \(m_i+1\) to row \(maxmi\) in the \(i\)-th
column.)
matrix of integers. The first element of each column 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.
vector holding the values of \(b_0\) (defaults to zero).
the first meq constraints are treated as equality
constraints, all further as inequality constraints (defaults to 0).
logical flag: if TRUE, then we are passing
\(R^{-1}\) (where \(D = R^T R\)) instead of the matrix
\(D\) in the argument Dmat.
a list with the following components:
vector containing the solution of the quadratic programming problem.
scalar, the value of the quadratic function at the solution
vector containing the unconstrained minimizer of the quadratic function.
vector of length 2, the first component contains the number of iterations the algorithm needed, the second indicates how often constraints became inactive after becoming active first.
vector with the Lagragian at the solution.
vector with the indices of the active constraints at the solution.
D. Goldfarb and A. Idnani (1982). Dual and Primal-Dual Methods for Solving Strictly Convex Quadratic Programs. In J. P. Hennart (ed.), Numerical Analysis, Springer-Verlag, Berlin, pages 226–239.
D. Goldfarb and A. Idnani (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 <- rbind(c(2,2,2),c(1,1,2),c(2,2,3))
Amat <- rbind(c(-4,2,-2),c(-3,1,1))
bvec <- c(-8,2,0)
solve.QP.compact(Dmat,dvec,Amat,Aind,bvec=bvec)
#> $solution
#> [1] 0.4761905 1.0476190 2.0952381
#>
#> $value
#> [1] -2.380952
#>
#> $unconstrained.solution
#> [1] 0 5 0
#>
#> $iterations
#> [1] 3 0
#>
#> $Lagrangian
#> [1] 0.0000000 0.2380952 2.0952381
#>
#> $iact
#> [1] 3 2
#>