I am using numerical optimization to fit a 1 parameter model, in which the input parameter is bounded. I am currently using optimize(), however, the problem turns out to have local minima, and optimize does not always seem to find the global minimum. I could to write a wrapping function that tries multiple intervals or starting values, but I would prefer a package that has built-in methods to make it more robust against local minima. I checked the CRAN Task View for Optimization, however there seem to be a lot of alternatives, and not being an optimization expert, I could use some advice. What could be an appropriate package or function for one-dimensional bounded optimization, that includes some protection against local minima? ----- Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my current projects. -- View this message in context: http://old.nabble.com/1-dimensional-optimization-with-local-minima-tp26160001p26160001.html Sent from the R help mailing list archive at Nabble.com.
Hi, One approach is to use the `multiStart' function in my "BB" package. You have to provide a matrix of starting values for this. Here is a simple, one-dimensional optimization problem with multiple peaks and valleys. I show how to find "all" the peaks in the bounded interval [0, 1]. myfn <- function(x) { exp(-k1 * x) * sin(2*pi*k2*x) } k1 <- 0.5 k2 <- 5 x <- seq(0, 1, length=1000) plot(x, fn(x), type="l") require(BB) p0mat <- matrix(runif(100), 100, 1) # random starting values ans <- multiStart(par=p0mat, fn=myfn, lower=0, upper=1, action="optimize", control=list(maximize=TRUE)) pconv <- ans$par[ans$conv] # converged solutions rp <- !duplicated(round(pconv, 3)) # unique, converged solutions sort(pconv[rp]) # lists all the local maxima Hope this helps, Ravi. ____________________________________________________________________ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvaradhan at jhmi.edu ----- Original Message ----- From: Jeroen Ooms <jeroen.ooms at stat.ucla.edu> Date: Tuesday, November 3, 2009 2:27 am Subject: [R] 1 dimensional optimization with local minima To: r-help at r-project.org> I am using numerical optimization to fit a 1 parameter model, in which > the > input parameter is bounded. I am currently using optimize(), however, > the > problem turns out to have local minima, and optimize does not always > seem to > find the global minimum. I could to write a wrapping function that tries > multiple intervals or starting values, but I would prefer a package > that has > built-in methods to make it more robust against local minima. > > I checked the CRAN Task View for Optimization, however there seem to > be a > lot of alternatives, and not being an optimization expert, I could use > some > advice. What could be an appropriate package or function for one-dimensional > bounded optimization, that includes some protection against local > minima? > > > > ----- > Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University > > > Visit www.jeroenooms.com to explore some of my > current projects. > > > > > > > -- > View this message in context: > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > > PLEASE do read the posting guide > and provide commented, minimal, self-contained, reproducible code.
Most methods for optimization in R seek local minima, though there are some -- mainly for >1 dimensions, that attempt to find the global minimum stochastically (optim method SANN, DEoptim). SANN does, I believe, handle 1 dimension, but does not have a convergence test, but runs a fixed number of function evaluations (I got bitten by this unusual behaviour, as it returns a "converged" flag after the specified number of evaluations). While there are some techniques that can generate global minima given conditions on the function, I would anticipate you will do better graphing your function(s) to learn if they have just a few (++) or very many (-- = very bad for you) optima. You should apply bounds to your domain -- a lot of computational time is wasted when routines take a wild excursion away from a region of interest. That may be enough. Or you may need to segment the domain to isolate the minima then select the best. That is, find a local minimum, choose a new interval that does not include this and apply optimize() again. Messy, but unless you have lots of local minima, should work OK. If you do have lots, it is likely you need to re-pose your problem. JN> Message: 114 > Date: Mon, 2 Nov 2009 23:00:40 -0800 (PST) > From: Jeroen Ooms <jeroen.ooms at stat.ucla.edu> > Subject: [R] 1 dimensional optimization with local minima > To: r-help at r-project.org > Message-ID: <26160001.post at talk.nabble.com> > Content-Type: text/plain; charset=us-ascii > > > I am using numerical optimization to fit a 1 parameter model, in which the > input parameter is bounded. I am currently using optimize(), however, the > problem turns out to have local minima, and optimize does not always seem to > find the global minimum. I could to write a wrapping function that tries > multiple intervals or starting values, but I would prefer a package that has > built-in methods to make it more robust against local minima. > > I checked the CRAN Task View for Optimization, however there seem to be a > lot of alternatives, and not being an optimization expert, I could use some > advice. What could be an appropriate package or function for one-dimensional > bounded optimization, that includes some protection against local minima? > > > > ----- > Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University > > Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my > current projects. > > > > > > > -- View this message in context: http://old.nabble.com/1-dimensional-optimization-with-local-minima-tp26160001p26160001.html Sent from the R help mailing list archive at Nabble.com.