6
我使用R的包GenSa
(函数GenSA
)中执行的模拟退火来搜索导致“良好值”(与某些基线相比)的输入变量的值高维度的功能。我注意到设置目标函数的最大调用次数对运行时间没有影响。我做错了什么或者这是一个错误?模拟退火在R:GenSA运行时间
这是对GenSA
帮助文件中给出的示例的修改。
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))
即使max.call
被指定为10000,GenSA
调用目标函数超过46000倍(注意,目的是为了将来电的号码从本地环境中调用)。尝试通过max.time
指定最大运行时间时,同样的问题会增加。