Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulated Annealing in R: GenSA running time

I am using simulated annealing, as implemented in R's package GenSa (function GenSA), to search for values of input variables that result in "good values" (compared to some baseline) of a highly dimensional function. I noticed that setting maximum number of calls of the objective function has no effect on the running time. Am I doing something wrong or is this a bug?

Here is a modification of the example given in GenSA help file.

library(GenSA)

Rastrigin <- local({ 
  index <- 0  
  function(x){    
    index <<- index + 1    
    if(index%%1000 == 0){
      cat(index, "   ")
    }    
    sum(x^2 - 10*cos(2*pi*x)) + 10*length(x)    
  }  
})

set.seed(1234)
dimension <- 1000
lower <- rep(-5.12, dimension)
upper <- rep(5.12, dimension)
out <- GenSA(lower = lower, upper = upper, fn = Rastrigin, control = list(max.call = 10^4))

Even though the max.call is specified to be 10,000, GenSA calls the objective function more than 46,000 times (note that the objective is called within a local environment in order to track the number of calls). The same problem rises when trying to specify the maximum running time via max.time.

like image 463
Jebus Avatar asked Aug 03 '15 13:08

Jebus


1 Answers

This is an answer by the package maintainer :

max.call and max.time are soft limits that do not include local searches that are performed before reaching these limits. The algorithm does not stop the local search strategy loop before its end and this may exceed the limitation that you have set but will stop after that last search. We have designed the algorithm that way to make sure that the algorithm isn't stopped in the middle of searching valley. Such an option to stop anywhere will be implemented in the next release of the package.

like image 102
Jebus Avatar answered Nov 03 '22 03:11

Jebus