_______________________________________________________________________________________
Ah! I didn't notice this until now. Yes, following Nocedal & Wright (excellent book, that) I've defined a quadratic penalty function to enforce an equality constraint, and added it to the objective. (Originally I had an inequality constraint in mind, but the equality one doesn't run into problems when you're on the boundary -- as is likely to happen in this case -- and gets the job done.) Getting the gradient right was a bit tedious, but it seems to be working now. I did find an interesting thing in working with both Splus and R, though. In Splus, both optim and nlminb run fairly slowly with a pure-S objective function supplied, even when it was as vectorized as I could make it. So I thought to compile the objective function in C, and this sped it up by a factor of 2-4x. On the other hand, the pure-S version actually ran quite fast in R, and the compiled version actually _slowed_ it down by a small but noticeable amount. Is this a common experience? Is the R interpreter so efficient that using compiled code is unlikely to improve speed further? (I'm using R 2.2 and Splus 7.04, on a Windows XP workstation with 3GB of memory.) -- Hong Ooi Senior Research Analyst, IAG Limited 388 George St, Sydney NSW 2000 +61 (2) 9292 1566 -----Original Message----- From: Spencer Graves [mailto:[EMAIL PROTECTED] Sent: Tuesday, 29 November 2005 12:58 PM To: Hong Ooi Cc: Thomas Lumley; [email protected] Subject: Re: [R] Looking for constrained optimisation code Have you considered migrating the constraints into the objective function, then cranking up the penalty for constraint violation once you have a more or less feasible solution? spencer graves Hong Ooi wrote: > ________________________________________________________________________ _______________ > > > You know, this is the first time I've heard of constrOptim. > > I actually have a rather complicated, nonlinear boundary expression in > mind, so this function by itself isn't quite what I'm after. Still, I > should be able to hack up a barrier function in my own code and feed > that into optim/nlminb/constrOptim. > > Thanks! > > -- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA [EMAIL PROTECTED] www.pdf.com <http://www.pdf.com> Tel: 408-938-4420 Fax: 408-280-7915 _______________________________________________________________________________________ The information transmitted in this message and its attachme...{{dropped}} ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
