I am having some problems using Quadprog in R. I want to minimize the
objective function :

 

200*P1-1/2*10*P1^2+100*P2-1/2*5*P2^2+160*P3-1/2*8*P3^2+50*P4-1/2*10*P4^2+50*P
5-1/2*20*P5^2+50*P6-1/2*10*P6^2, 

 

Subject to a set of constrains including not only the variables P1, P2, P3,
P4, P5, P6, but also the variables X1, X2,X3,X4,X5,X6,X7,X8,X9.

 

 As the set of variables X's are not affecting the objective function, I
assume that I have to enter them as zero's in the vector "dvec" and the
matrix "Dmat". 

 

My program states as: 

 

mat<-matrix(0,15,15)

diag(Dmat)<-c(10,5,8,10,20,10,0,0,0,0,0,0,0,0,0)

dvec<- c(-200,-100,-160,-50,-50,-50,0,0,0,0,0,0,0,0,0)

Amat<- matrix(c(-1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,1,

                 0,0,0,0,0,0,0,0,0,0,0,0,0,-1,1,0,0,0,0,

                 0,0,0,0,0,0,0,-1,0,0,0,1,0,0,0,0,0,0,0,

                 0,0,0,0,-1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,

                 0,-1,0,1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,

                 1,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,1,0,0,0,0,

                 0,0,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,0,0,0,0,

                 -10,0,0,0,0,0,-1,0,0,-1,0,0,-1,0,0,0,-5,0,

                 0,0,0,0,-1,0,0,-1,0,0,-1,0,0,0,-8,0,0,0,0,

                 0,-1,0,0,-1,0,0,-1,0,0,0,-10,0,0,1,1,1,0,0,

                 0,0,0,0,0,0,0,0,-20,0,0,0,0,1,1,1,0,0,0,0,0,

                 0,0,0,-10,0,0,0,0,0,0,1,1,1),15,15)

bvec <-c(0,-2,-2,-2,0,-1,-2,-1,0,-200,-100,-160,-50,-50,-50)

solve.QP(Dmat,dvec,Amat,bvec=bvec)

 

Nonetheless I get the message: "Error en solve.QP(Dmat, dvec, Amat, bvec =
bvec) : matrix D in quadratic function is not positive definite!".

 

I think it has to do with the fact that in the Dmat matrix I end up with
several columns with zeros. Do anyone have an idea of how to solve such a
problem? 

 

Bests, 

 

Sergio René


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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