190 likes | 353 Views
Willy’s Bane. A simulated annealing approach to the travelling salesman problem. Brian Babcock Trevor Blanarik. Travelling Salesman. We need to visit a set of cities, each only once, using the shortest path possible.
E N D
Willy’s Bane A simulated annealing approach to the travelling salesman problem Brian BabcockTrevor Blanarik
Travelling Salesman • We need to visit a set of cities, each only once, using the shortest path possible. • There are several approaches to this problem, we chose to use simulated annealing.
Simulated Annealing • Named after metallurgic annealing • Metal is heated until glowing and then gradually cooled. • Randomly switches two cities • ‘Temperature’ slowly reduces toward zero • May accept a worse solution, depends on current temperature • A high temperature will accept a very large uphill change – a low temperature will not
Sequential • Set up a single simulated annealing run using a single temperature and cooling rate • Simulated annealing ends when a better result has not been found after 100 iterations • Resulting path is printed to a Drawing file
Parallel • SMP, sizeup • Same as the sequential version, except each thread uses a different temperature. • After a run of SA, each thread checks to see if its new path is shorter than the current best path. • Shared variable • Threads exit when every thread has failed at least three times in a row • Acts like several SAs wrapped in a hill-climbing algorithm
Metrics Inputs: 50 Cities on a grid 500 x 1000 units. A fixed initial configuration is created with a seed of 1 for the random number generator. Initial length = 20038.51133626955
Metrics Varying cooling schedules
Metrics Varying cooling schedules
Initial Random Tour Length = 20038
Sequential Result Length = 5861
SMP 1 Thread Length = 5988.244
SMP 2 Threads Length = 5749.68
SMP 4 Threads Length = 5526.10
SMP 8 Threads Length = 4802.435
What We Learned • A group of parallel threads acts like a ‘search party’ – they keep each other on the right track, toward the optimal answer. • Sometimes 2 threads will arrive at the very same solution, independently of each other. • Choosing 2 cities to swap at random, rather than choosing 2 neighboring cities is much faster and gets much better answers.
What We Learned • Time can be pretty unpredictable with an algorithm like this – since every move is random, the algorithm could end up in a local optimum early on, and end quickly. • Or, it could gradually find better answers and take a very long time. • Having more threads tends to help it converge to a much better solution, but often at the expense of time.
Future Work • Cluster version • Communication required to keep shared ‘best path’ variable updated. • Different cooling rates • A speedup version which parallelizes the SA loop
Sources • Nourani, Yaghout, and Bjarne Andresen. "A comparison of simulated annealing cooling strategies." J. Phys. A: Math 31 (1998): 8373–8385. • SREENIVAS, T H, K GANAPATHY SUBRAMANIAM, and D. JANAKI RAM. "Parallel Simulated Annealing Algorithms." JOURNAL OF PARALLEL AND DISTRIBUTED COMPUTING 37 (1996): 207-212.