模拟退火算法SA()
1 choose an initial solution X0 randomly //随机的选择一个初始解X02 give an initial temperature T0 , X ← X0, T ← T0 //初始化温度T0
3 while the stop criterion is not yet satisfied do //停止准则不满足则
4 { for i ← 1 to L do //Markov 链的长度 L
5 { pick a solution X'∈N(X) randomly //随机选择临域内一个解X'
6 Δf ← f(X')-f(X)
7 if Δf<0 then X ← X'
8 else X ← X' with probability exp(- Δf/T) } // 以exp(- Δf/T)的接受概率接受X'
9 T← g(T) //generally, T ← aT } //温度下降
10 return X
Generic choices for annealing schedule
*initial temperature
T
0
(example: based on statistics of evaluation function)
*Cooling schedule-how to change temperature over time
(example: geometric cooling,
T ←
aT)
*L
: number of iterations at each temperature
(example :multiple of the neighborhood size
*Stopping criterion
(example: no improved solution found for a number of temperature values)
代码C++实现 ,解决旅行商问题:
http://download.csdn.net/detail/zhoubin1992/6982573