2

I am new to R and am trying to solve a QP problem using R. I keep getting the following error :

Amat and dvec are incompatible.

here my code:

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)
4

1 回答 1

3

?solve.QP 文档提到

   problems of the form min(-d^T b + 1/2 b^T D b) with the constraints A^T b >= b_0.

所以至少你必须改变这个Amatt(Amat)

 output_qp <- solve.QP(S, Fr, t(Amat), bv, neq, factorized=FALSE)
于 2013-07-02T21:49:19.187 回答