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:
parent
c2f7711923
commit
daa711d5a3
@ -17,11 +17,9 @@ public class SimulatedAnnealing {
|
|||||||
if (t > 0.1) {
|
if (t > 0.1) {
|
||||||
currentSolution.swapCities();
|
currentSolution.swapCities();
|
||||||
double currentDistance = currentSolution.getDistance();
|
double currentDistance = currentSolution.getDistance();
|
||||||
if (currentDistance == 0)
|
|
||||||
continue;
|
|
||||||
if (currentDistance < bestDistance) {
|
if (currentDistance < bestDistance) {
|
||||||
bestDistance = currentDistance;
|
bestDistance = currentDistance;
|
||||||
} else if (Math.exp((currentDistance - bestDistance) / t) < Math.random()) {
|
} else if (Math.exp((bestDistance - currentDistance) / t) < Math.random()) {
|
||||||
currentSolution.revertSwap();
|
currentSolution.revertSwap();
|
||||||
}
|
}
|
||||||
t *= coolingRate;
|
t *= coolingRate;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user