[R] quadprog error?

none investorcurious at gmail.com
Fri Mar 16 17:20:04 CET 2012


I forgot to attach the problem data, 'quadprog.Rdata' file, in my prior 
email.


I want to report a following error with quadprog. The solve.QP function
finds a solution to the problem below that violates the last equality
constraint. I tried to solve the same problem using ipop from kernlab
package and get the solution in which all equality constraints are
enforced. I also tried an old version of quadprog, Version: 1.4-11,
Date: 2007-07-12 and my problem is solved correctly.

I have tried to contact Berwin A. Turlach <Berwin.Turlach at gmail.com>
(maintainer for quadprog package) a week ago, with no success.


##############################################################
load(file='quadprog.Rdata')		

	# solve QP using quadprog	
	require(quadprog)
	sol = solve.QP(Dmat, dvec, Amat, bvec, meq)
		x = sol$solution
		check = x %*% Amat - bvec	
		# for some reason last equality constraint is violated
		round(check[1:meq], 4)


	# solve QP using kernlab
	require(kernlab)	
	n = nrow(Amat)
	sv = ipop(c = matrix(dvec), H = Dmat, A = t(Amat[,1:meq]),
			b = bvec[1:meq], l = rep(-1000, n),
			u = rep(1000, n), r = rep(0,meq))
				
		x = primal(sv)
		check = x %*% Amat - bvec	
		# all constraints are ok
		round(check[1:meq], 4)







More information about the R-help mailing list