我是R的新手并且正在尝试使用R解决QP问题。我一直收到以下错误:
Amat and dvec are incompatible.
这里是我的代码:
d <- 4
Fr <- as.vector(Fr) ;
Aeq <- matrix(data=1, nrow=1, ncol=d) %*% U
Amat <- rbind(Aeq,U);
bv <- vector( mode= "integer", length = nrow(Amat))
bv[1] <- 1
neq <- 1
output_qp <- solve.QP(S, Fr, Amat, bv, neq, factorized=FALSE)
答案 0 :(得分:2)
?solve.QP doc提及
problems of the form min(-d^T b + 1/2 b^T D b) with the constraints A^T b >= b_0.
所以至少你必须改变这个:Amat
t(Amat)
output_qp <- solve.QP(S, Fr, t(Amat), bv, neq, factorized=FALSE)