This function takes arguments slightly differently from solve.QP, to make it more convenient for internal use. It also implements measures to robustify calls to solve.QP:
A rounding hack to prevent a bug in solve.QP that occasionally produces all-NaN solutions without returning a warning or error. Rounding has been found to eliminate almost all such bugs.
A call to lpSolve's lp() to check feasibility before running solve.QP
solve.QP is called within tryCatch to eliminate unwanted crashes.
The output of this function is a list with elements
flag
is 0 for successful completion, 1 for failure at the LP check stage,
and 2 for failure at the QP stage (usually the "NaN solution" bug).
QP
is the list returned by solve.QP
. If the QP was not run due to
infeasibility, this element is NULL.
QPsolve(D, d, A, b, Aeq, beq)
A list with elements described above.
The matrix of the quadratic objective.
The vector in the linear term of the quadratic objective.
The matrix of inequality constraints.
The vector of RHS of the inequalities.
The matrix of equality constraints.
The vector of RHS of the equalities.
solve.QP defines its quadratic program as minimizing 1/2 * x'Dx - x'd, subject to constraints A'x >= b. Equality constraints have to be in the first rows of A'.
This function minimizes x'Dx - x'd, subject to inequality constraints Ax >= b and Equality constraints Aeq*x = beq.