0
我有一個程序實現模擬退火。我對接受概率存在問題,可能是由於我不瞭解爲什麼將歐拉數提高到(能量 - 能量)的能力是有用的。Java模擬退火驗收概率
即使溫度很低,概率總是超過1.0(100%),因此實際上這是隨機搜索。我如何將我的接受概率固定爲sA的正常速率(開始時接受更糟的解決方案的機會高,接近結束的機會低)?
下面是方法的代碼:
if (mutatedSolutionFitness > originalSolutionFitness) {
return 1.0;
} else {
System.out.println("Original solution fitness: "+originalSolutionFitness);
System.out.println("Mutated solution fitness: "+mutatedSolutionFitness);
System.out.println("Temperature: "+this.temperature);
final double chance = Math.exp((originalSolutionFitness - mutatedSolutionFitness)/this.temperature);
System.out.println("Math.exp((originalSolutionFitness - mutatedSolutionFitness)/this.temperature): "+chance);
System.out.println();
return chance;
}
而這裏的輸出幾次:
Original solution fitness: 0.6666666666666666
Mutated solution fitness: 0.5555555555555556
Temperature: 999998.000001
Math.exp((originalSolutionFitness - mutatedSolutionFitness)/this.temperature): 1.0000001111113395
Original solution fitness: 0.6666666666666666
Mutated solution fitness: 0.6666666666666666
Temperature: 999997.000003
Math.exp((originalSolutionFitness - mutatedSolutionFitness)/this.temperature): 1.0
Original solution fitness: 0.6666666666666666
Mutated solution fitness: 0.6666666666666666
Temperature: 999996.000006
Math.exp((originalSolutionFitness - mutatedSolutionFitness)/this.temperature): 1.0
Original solution fitness: 0.6666666666666666
Mutated solution fitness: 0.5555555555555556
Temperature: 999995.00001
Math.exp((originalSolutionFitness - mutatedSolutionFitness)/this.temperature): 1.0000001111116728
Original solution fitness: 0.6666666666666666
Mutated solution fitness: 0.4444444444444444
Temperature: 999994.0000149999
Math.exp((originalSolutionFitness - mutatedSolutionFitness)/this.temperature): 1.0000002222235802
Original solution fitness: 0.6666666666666666
Mutated solution fitness: 0.5555555555555556
Temperature: 999993.0000209998
Math.exp((originalSolutionFitness - mutatedSolutionFitness)/this.temperature): 1.000000111111895