From: <markleeds_at_verizon.net>

Date: Fri, 21 Dec 2007 19:38:19 -0600 (CST)

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. Received on Sat 22 Dec 2007 - 01:43:04 GMT

Date: Fri, 21 Dec 2007 19:38:19 -0600 (CST)

I was playing around with a simple example using solve.qp ( function is in the quadprog package ) and the code is below. ( I'm not even sure there if there is a reasonable solution because I made the problem up ).

But, when I try to use solve.QP to solve it, I get the error that D in the quadratic function is not positive
definite. This is because Dmat is zero

because I don't have a quadratic term in my
objective function. So, I was wondering if
it was possible to use solve.QP when there isn't
a quadratic term in the objective function.

I imagine that there are other functions in R that can be used but I would like to use solve.QP because, in my real problem, I will have a lot of fairly complex constraints and solve.QP provides a very nice way for implementing them. Maybe there is another linear solver that allows you to implement hundreds of constraints just solve.QP that I am unaware of ? Thanks for any suggestions.

**# IN THE CODE BELOW, WE MINIMIZE
**

# -3*b1 + 4*b2 + 6*b3

**# SUBJECT TO
**

# -(b1 b2 + b3) >= 0

# IE : b1 + b2 + b3 = 0.

Dmat <- matrix(0,3,3) # QUADRATIC TERM dvec <- c(-3,4,6) # LINEAR TERM Amat <- matrix(c(1,-1,0,1,-1,0,1,-1,0),3,3)

#print(Amat)

bvec = c(0,0,0) # THIRD ZERO IS SAME AS NO CONSTRAINT

result <- solve.QP(Dmat, dvec, Amat)

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. Received on Sat 22 Dec 2007 - 01:43:04 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Mon 24 Dec 2007 - 14:30:22 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*