Skip to content

Commit daa711d

Browse files
authored
Simulated Annealing fix (eugenp#910)
* @async and Spring Security * @async with SecurityContext propagated * Spring and @async * Simulated Annealing algorithm * Simulated Annealing algorithm * Rebase * Rebase * SA further fixes
1 parent c2f7711 commit daa711d

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

‎core-java/src/main/java/com/baeldung/algorithms/SimulatedAnnealing.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ public static double simulateAnnealing(double startingTemperature, int numberOfI
1717
if (t > 0.1) {
1818
currentSolution.swapCities();
1919
double currentDistance = currentSolution.getDistance();
20-
if (currentDistance == 0)
21-
continue;
2220
if (currentDistance < bestDistance) {
2321
bestDistance = currentDistance;
24-
} else if (Math.exp((currentDistance - bestDistance) / t) < Math.random()) {
22+
} else if (Math.exp((bestDistance - currentDistance) / t) < Math.random()) {
2523
currentSolution.revertSwap();
2624
}
2725
t *= coolingRate;

0 commit comments

Comments
 (0)