Hello,

here is an example from the manual. How to turn this minimization
problem into maximization problem, i.e. -(0 5 0) %*% b - 1/2 b^T b?

# Assume we want to minimize: -(0 5 0) %*% b + 1/2 b^T b
# under the constraints: A^T b >= b0
# with b0 = (-8,2,0)^T
# and (-4 2 0)
# A = (-3 1 -2)
# ( 0 0 1)
# we can use solve.QP.compact as follows:
#
library(quadprog)
Dmat <- matrix(0,3,3)
diag(Dmat) <- 1
dvec <- c(0,5,0)
Aind <- rbind(c(2,2,2),c(1,1,2),c(2,2,3))
Amat <- rbind(c(-4,2,-2),c(-3,1,1))
bvec <- c(-8,2,0)
solve.QP.compact(Dmat,dvec,Amat,Aind,bvec=bvec)

Thanks,
Serguei

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to