Traveling Salesman Problem (aka The Bicycle Thief)

Goals

Submission

Submit Tour.java and your readme_tsp.txt file, and answer the questions. You may also submit an extra.zip file containing your extra credit implementation and any additional files it requires.

End-of-Semester Evaluation

Please take a few minutes to fill out our anonymous end-of-semester evaluation. While the University's evaluation gives limited (but helpful) feedback to your fellow students through Penn Course Review, to the Dean's office, and to our chair, this survey is a way to quickly give more directed feedback to us and to your TAs.

Background

Given N cities, the goal of a traveling salesman is to visit each of them exactly once (and arrive back home) while keeping the total distance traveled as short as possible. Stated more abstractly, the goal is to find a path connecting N points in a plane that passes through each point exactly once. Implement three greedy heuristics to find good (but not optimal) solutions to the traveling salesman problem (TSP). In doing this assignment, You should (i) learn about the notorious traveling salesman problem, (ii) get more practice with linked lists, and (iii) learn to adapt them to your problem.

          1000 points in the plane                          optimal tour (we think) - 15476.51924889754
1,000 points optimal tour

Perspective. The importance of the TSP does not arise from an overwhelming demand of salespeople to minimize their travel distance, but rather from a wealth of other applications such as vehicle routing, circuit board drilling, VLSI design, robot control, X-ray crystallography, machine scheduling, and computational biology.

Greedy heuristics. The traveling salesman problem is a notoriously difficult combinatorial optimization problem, In principle, one can enumerate all possible tours and pick the shortest one; in practice, the number of tours is so staggeringly large (roughly N factorial) that this approach is useless. For large N, no one knows an efficient method that can find the shortest possible tour for any given set of points. However, many methods have been studied that seem to work well in practice, even though they are not guaranteed to produce the best possible tour. Such methods are called heuristics. Your main task is to implement the in-order, nearest neighbor and smallest detour insertion heuristics for building a tour incrementally. Start with a one-point tour (from the first point back to itself), and iterate the following process until there are no points left.

Getting Started:

Part I: Tour Data Type

Your task is to create a Tour data type that represents the sequence of points visited in a TSP tour. It must implement the TourInterface interface.

Part II: Creating the Tour

Part III: Analysis

Estimate the running times of your programs as a function of the number of points N.

Contest and extra credit.

Implement a better heuristic in a class TourEC.java. For example, observe that any tour with paths that cross can be transformed into a shorter one with no crossing paths: add that improvement to your program. Here are some other ideas. The speed of your program may vary depending on your computer, but in general it should be at most five minutes for tsp1000.txt. You are also not required to use the Tour data type or TourInterface interface for you extra credit solution.

Any code beyond TourEC.java necessary to run your extra credit should be included in extra.zip. You do not have to use Point.java or any of your code from the main part of the assignment. (You may also modify Point.java in any way you wish for the extra credit.) However, if you do use any of that code, you should include it in your extra.zip file or your TA may not be able to compile your program.

Be warned that this is a relatively difficult extra credit, although it gives an opportunity to learn a great deal about an extremely important problem. Answer the relevant questions in the readme_tsp.txt file. We will award a special prize to the student who finds the shortest tour around the 1,000-point set.

Enrichment



This assignment was originally developed by Bob Sedgewick and Kevin Wayne, and adapted by Benedict Brown.
Copyright © 2000 - 2014