Simulated Annealing fix (#910)

* @Async and Spring Security

* @Async with SecurityContext propagated

* Spring and @Async

* Simulated Annealing algorithm

* Simulated Annealing algorithm

* Rebase

* Rebase

* SA further fixes
This commit is contained in:
maibin 2016-12-19 22:38:56 +01:00 committed by GitHub
parent c2f7711923
commit daa711d5a3
1 changed files with 1 additions and 3 deletions

View File

@ -17,11 +17,9 @@ public class SimulatedAnnealing {
if (t > 0.1) {
currentSolution.swapCities();
double currentDistance = currentSolution.getDistance();
if (currentDistance == 0)
continue;
if (currentDistance < bestDistance) {
bestDistance = currentDistance;
} else if (Math.exp((currentDistance - bestDistance) / t) < Math.random()) {
} else if (Math.exp((bestDistance - currentDistance) / t) < Math.random()) {
currentSolution.revertSwap();
}
t *= coolingRate;