Simulated Annnealing fixes (#907)
* @Async and Spring Security * @Async with SecurityContext propagated * Spring and @Async * Simulated Annealing algorithm * Simulated Annealing algorithm * Rebase * Rebase
This commit is contained in:
parent
3d60f5cc7a
commit
39cc3511ad
@ -45,3 +45,4 @@
|
|||||||
- [Getting Started with Java Properties](http://www.baeldung.com/java-properties)
|
- [Getting Started with Java Properties](http://www.baeldung.com/java-properties)
|
||||||
- [Grep in Java](http://www.baeldung.com/grep-in-java)
|
- [Grep in Java](http://www.baeldung.com/grep-in-java)
|
||||||
- [Java - Combine Multiple Collections](http://www.baeldung.com/java-combine-multiple-collections)
|
- [Java - Combine Multiple Collections](http://www.baeldung.com/java-combine-multiple-collections)
|
||||||
|
- [Simulated Annealing for Travelling Salesman Problem](http://www.baeldung.com/java-simulated-annealing-for-traveling-salesman)
|
||||||
|
@ -25,6 +25,8 @@ public class SimulatedAnnealing {
|
|||||||
currentSolution.revertSwap();
|
currentSolution.revertSwap();
|
||||||
}
|
}
|
||||||
t *= coolingRate;
|
t *= coolingRate;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (i % 100 == 0) {
|
if (i % 100 == 0) {
|
||||||
System.out.println("Iteration #" + i);
|
System.out.println("Iteration #" + i);
|
||||||
@ -34,7 +36,7 @@ public class SimulatedAnnealing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("Optimized distance for travel: " + simulateAnnealing(10, 10000, 0.9));
|
System.out.println("Optimized distance for travel: " + simulateAnnealing(10, 10000, 0.9995));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,10 @@ public class Travel {
|
|||||||
int a = generateRandomIndex();
|
int a = generateRandomIndex();
|
||||||
int b = generateRandomIndex();
|
int b = generateRandomIndex();
|
||||||
previousTravel = travel;
|
previousTravel = travel;
|
||||||
travel.set(a, travel.get(b));
|
City x = travel.get(a);
|
||||||
|
City y = travel.get(b);
|
||||||
|
travel.set(a, y);
|
||||||
|
travel.set(b, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void revertSwap() {
|
public void revertSwap() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user