CSCI 280 - Algorithms and Problem Solving Paradigms
Spring 2010
Project 3: Traveling Salesman Problem (TSP)
Overview
One of the most important problems in Computer Science is the Traveling
Salesman Problem (TSP). Each instance of the TSP is a weighted, undirected,
complete graph, one of whose nodes is designated to be the start.
A solution to a TSP instance is a cycle that begins and ends with the start
vertex and includes every other vertex exactly once. An optimal
solution is a solution for which the sum of the weights of the edges in the
cycle is the minimum across all possible cycles for the problem instance.
A TSP solution is often called a tour.
An important category of TSP instances is metric TSP instances.
In a metric TSP instance, the weights of the three edges connecting any three
cities meet the triangle inequality.
No polynomial-time algorithm has yet been discovered that is capable of always
finding an optimal tour for an arbitrary TSP instance. However, it has not
yet been proven that no such algorithm exists.
Implementation
For this project, you will implement the following:
- Create a class representing a metric map in floating-point Euclidean space. Each map can contain some number of "cities", each of which is a point on
this map. You should create code that can generate a map with an arbitrary number of randomly-placed cities.
- Create a class representing a complete, weighted, undirected graph whose weights are floating-point values. You should create code that can generate a graph from one of your metric maps.
- Implement the dynamic-programming algorithm from the textbook (pages 173-175) for finding optimal tours of a TSP graph. The algorithm is a bit tricky to implement. In particular, be sure to think very carefully about what kind of data structure to use for the table. Also think carefully about how to generate all subsets of a given size, as required by line 3 of the algorithm on page 175.
- Read section 5.1 of the textbook ("Minimum Spanning Trees"). Implement
either Kruskal's algorithm or Prim's algorithm (your choice) to produce a minimum spanning tree for an instance of your TSP graph.
- Read section 9.2.3 of the textbook ("TSP"). This section describes an algorithm for finding non-optimal TSP tours that are bounded to be no worse than twice the optimum. The algorithm only works for metric TSP instances (such as ours). Implement this algorithm.
- Implement one additional TSP algorithm. You may invent your own, or implement one described elsewhere.
Experiments
- The dynamic programming algorithm requires exponential time and uses
exponential space. We know, therefore, that there exists a relatively problem size for which the algorithm becomes impractical, either because of excessive running time or insufficient heap space. Experimentally determine the largest problem size that your implementation can solve in five minutes or less without exhausting the heap.
- Run all three of your algorithms 30 times apiece on instances of this problem size, and record the results.
- Run the MST algorithm and your additional algorithm on problems of size 10, 20, 50, 100, 200, 500, and 1000 cities. For each problem size, test each algorithm 30 times and record the results.
- Be careful to make sure that, for each run, each algorithm is run on the same problem instances as the others.
Analysis
- For the largest problem size for which the dynamic programming algorithm runs:
- What is the maximum ratio of the MST result to the DP result across all instances? Is it less than 2.0, as promised?
- What is the minimum ratio?
- What is the average ratio? As the denominators will differ, be sure to calculate it properly; that is, divide the sum of the MST scores by the sum of the DP scores. Also give the standard deviation.
- For each non-DP algorithm, graph its average performance (x-axis) vs. problem size (y-axis). With one curve per algorithm, these can be combined into a single graph. Ideally, your graph should indicate two standard deviations above and below each curve.
- Make two similar graphs of the best and worst
performance of the algorithms. As the numbers are not averages, there is no need to show the standard deviations.
- Write a text document that includes:
- Descriptions of each of the three implementations.
- All three graphs.
- Discussion and analysis of your results.
- Some conclusions about effective approaches to the TSP, as well as a
discussion of other ideas that might be worth investigating.