[R] Help with factorized argument in solve.QP

David S. Khabie-Zeitoune dave at mirabellafunds.com
Mon Jun 2 18:46:29 CEST 2003


Hi
 
I'm having problems getting the "factorized" argument in solve.QP (part
of the quadprog library) to work as expected. The helpfile states that
when the factorized argument is set to TRUE, then the function requires
the inverse of a square-root factor of the Hessian instead of the
Hessian itself. That is, when factorized=TRUE, the Dmat argument should
be a matrix R^(-1), such that the Hessian of the objective function is
t(R) %*% R.
 
I modified the example in the helpfile slightly to test this out:
 
R          = matrix(rnorm(9),3,3)
R.inv      = solve(R)
Dmat       = t(R) %*% R
dvec       = c(0,5,0)
Amat       = matrix(c(-4,-3,0,2,1,0,0,-2,1),3,3)
bvec       = c(-8,2,0)
 
x1 	     = solve.QP(Dmat=Dmat, dvec=dvec, Amat=Amat, bvec=bvec,
factorized=FALSE)
x2 	     = solve.QP(Dmat=R.inv, dvec=dvec, Amat=Amat, bvec=bvec,
factorized=TRUE)
print(x1$solution)
print(x2$solution)

I would have expected that x1$solution and x2$solution were the same (or
numerically similar); however they are typically very different. Where
am I going wrong...?
 
Thanks
 
David




More information about the R-help mailing list