模拟退火,归一化温度

Simulated annealing, normalized temperature

我有一个问题,我需要最大化给定函数的值 X:

这是公式的 python 代码:2 ** (-2 *((((x-0.1) / 0.9)) ** 2)) * ((math.sin(5*math.pi*x)) ** 6)

我正在对这项工作使用模拟退火算法,但我遇到了问题。

probability = pow(math.e, (actual_cost - best_cost) / temperature)

我的“成本”(我正在尝试优化的)是一个非常短的数字,通常在 0 到 0.1 之间,但我的另一侧温度大约为 100。

所以,当我应用概率函数时,我的结果总是大约 99%,这使得我的算法在所有迭代中都接受负值,而不是在整个迭代中降低这个概率。

如何调整我的温度值以通过迭代改变概率?

可以在 scipy.optimize.basinhopping 的文档中找到此问题的解决方案:

Choosing T: The parameter T is the “temperature” used in the Metropolis criterion. Basinhopping steps are always accepted if func(xnew) < func(xold). Otherwise, they are accepted with probability:

exp( -(func(xnew) - func(xold)) / T )

So, for best results, T should to be comparable to the typical difference (in function values) between local minima. (The height of “walls” between local minima is irrelevant.)

If T is 0, the algorithm becomes Monotonic Basin-Hopping, in which all steps that increase energy are rejected.