All, I am looking for an optimization library that does well on something as chaotic as the Schwefel function: schwefel <- function(x) sum(-x * sin(sqrt(abs(x)))) With these guys, not much luck:> optim(c(1,1), schwefel)$value[1] -7.890603> optim(c(1,1), schwefel, method="SANN", control=list(maxit=10000))$value[1] -28.02825> optim(c(1,1), schwefel, lower=c(-500,-500), upper=c(500,500), method="L-BFGS-B")$value[1] -7.890603> optim(c(1,1), schwefel, method="BFGS")$value[1] -7.890603> optim(c(1,1), schwefel, method="CG")$value[1] -7.890603 All trapped in local minima. I get the right answer when I pick a starting point that's close:> optim(c(400,400), schwefel, lower=c(-500,-500), upper=c(500,500), method="L-BFGS-B")$value[1] -837.9658 Of course I can always roll my own: r <- vector() for(i in 1:1000) { x <- runif(2, -500,500) m <- optim(x, schwefel, lower=c(-500,-500), upper=c(500,500), method="L-BFGS-B") r <- rbind(r, c(m$par, m$value)) } And this does fine. I'm just wondering if this is the right approach, or if there is some other package that wraps this kind of multi-start up so that the user doesn't have to think about it. Best, Ara
Vartanian, Ara <aravart <at> indiana.edu> writes:> All, > > I am looking for an optimization library that does well on something as > chaotic as the Schwefel function: > > schwefel <- function(x) sum(-x * sin(sqrt(abs(x)))) > > With these guys, not much luck: > > > optim(c(1,1), schwefel)$value > [1] -7.890603 > > optim(c(1,1), schwefel, method="SANN", control=list(maxit=10000))$value > [1] -28.02825 > > optim(c(1,1), schwefel, lower=c(-500,-500), upper=c(500,500), > method="L-BFGS-B")$value > [1] -7.890603 > > optim(c(1,1), schwefel, method="BFGS")$value > [1] -7.890603 > > optim(c(1,1), schwefel, method="CG")$value > [1] -7.890603Why is it necessary over and over again to point to the Optimization Task View? This is a question about a global optimization problem, and the task view tells you to look at packages like 'NLoptim' with specialized routines, or use one of the packages with evolutionary algorithms, such as 'DEoptim' or'pso'. library(DEoptim) schwefel <- function(x) sum(-x * sin(sqrt(abs(x)))) de <- DEoptim(schwefel, lower = c(-500,-500), upper = c(500,500), control = list(trace = FALSE)) de$optim$bestmem # par1 par2 # 420.9687 420.9687 de$optim$bestval # [1] -837.9658> All trapped in local minima. I get the right answer when I pick a starting > point that's close: > > > optim(c(400,400), schwefel, lower=c(-500,-500), upper=c(500,500), > > method="L-BFGS-B")$value > [1] -837.9658 > > Of course I can always roll my own: > > r <- vector() > for(i in 1:1000) { > x <- runif(2, -500,500) > m <- optim(x, schwefel, lower=c(-500,-500), upper=c(500,500), > method="L-BFGS-B") > r <- rbind(r, c(m$par, m$value)) > } > > And this does fine. I'm just wondering if this is the right approach, > or if there is some other package that wraps this kind of multi-start > up so that the user doesn't have to think about it. > > Best, > > Ara
Patrick Burns
2012-Feb-11 17:55 UTC
[Rd] Task views (was: Re: [R] Schwefel Function Optimization)
On 11/02/2012 08:25, Hans W Borchers wrote:> Vartanian, Ara<aravart<at> indiana.edu> writes: > >> All, >> >> I am looking for...>>> > Why is it necessary over and over again to point to the Optimization Task > View?... Now it could be that people are not trying very hard to solve their own problems, but to be fair it is a pretty gruelling process to find the Task Views. May I suggest that there be a "Task Views" item on the left sidebar of the R website in the Documentation section? -- Patrick Burns pburns at pburns.seanet.com twitter: @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno')
On 12-02-11 01:10 PM, Uwe Ligges wrote:> On 11.02.2012 18:55, Patrick Burns wrote: >> >> On 11/02/2012 08:25, Hans W Borchers wrote: >>> Vartanian, Ara<aravart<at> indiana.edu> writes: >>> >>>> All, >>>> >>>> I am looking for >> ... >>> Why is it necessary over and over again to point to the Optimization >>> Task >>> View? >> ... >> Now it could be that people are not trying >> very hard to solve their own problems, but >> to be fair it is a pretty gruelling process >> to find the Task Views. >> >> May I suggest that there be a "Task Views" item >> on the left sidebar of the R website in the >> Documentation section? >> > It is in the left side bar of CRAN already. > > UweYes, on CRAN but not on the R Homepage. I do agree with Hans that people do not seem to find it easily. One reason may be the term "Task Views" is fine once you know what it is, but it is not completely self explanatory, so you have to look to see what it is. Thus, a bit like reading documentation, people do not always do it. Perhaps a bullet in "Getting Started" would help? Paul