Hi Sergio,
Having singular Dmat is certainly a problem.
I can see two possibilities:
1) try to eliminate X1,...,X9, so that you are left with P1,...,P6 only.
2) if you can not do this, add eps*X1^+...+eps*X9^2 to your matrix Dmat so that
it is positive definite (eps is a small positive number). You can then try to
make eps smaller and smaller (but still not too small in order not to get into
numerical problems) and check whether your solution converges.
--- On Fri, 19/2/10, Araujo-Enciso, Sergio Rene <Sergio-Rene.Araujo-Enciso at
agr.uni-goettingen.de> wrote:
> From: Araujo-Enciso, Sergio Rene <Sergio-Rene.Araujo-Enciso at
agr.uni-goettingen.de>
> Subject: [R] Quadprog help
> To: r-help at r-project.org
> Received: Friday, 19 February, 2010, 7:40 PM
> 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]]
>
>
> -----Inline Attachment Follows-----
>
> ______________________________________________
> R-help at 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.
>