[R] Help using spg optimization in BB package

Ravi Varadhan RVaradhan at jhmi.edu
Wed Apr 22 18:56:50 CEST 2009


Here is another approach using an augmented penalty lagragian method.  

The same example:

fr <- function(x) { ## Rosenbrock Banana function

x1 <- x[1] 

x2 <- x[2] 

100 * (x2 - x1 * x1)^2 + (1 - x1)^2 

} 

fr.pen <- function(x, k=1e05) {
fr(x) + k * ( 1 - sum(x))^2
}

require(BB)

spg(par=c(0, 0), fn=fr.pen)  # Note:  this starting value will fail for the
"projection method" due to division by zero

Ravi.

----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 

----------------------------------------------------------------------------
--------


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of dre968
Sent: Wednesday, April 22, 2009 8:23 AM
To: r-help at r-project.org
Subject: [R] Help using spg optimization in BB package


i'm trying to use the BB package to minimize the sum of the squared
deviations for 2 vectors.  The only thing am having trouble with is defining
the project constraint.  I got the upper and lower bounds to work but i am
not sure how to create a constraint that the sum of x must be 1.  Any help
would be greatly appreciated.  
--
View this message in context:
http://www.nabble.com/Help-using-spg-optimization-in-BB-package-tp23175224p2
3175224.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.




More information about the R-help mailing list