In this assignment you will code two different ways of solving the traveling salesman problem. First you read in a file of 100 cities that will be posted in a masterhit file for the course. Each line of the file will contain two integers, separated by a blank, that represent the position of a city. This list of cities represents 100 problems where problem n is to find a route through all the cities from 1 to n.

  1. Write an exhaustive search algorithm to solve TSP. Your program probably will not be able to solve problems much beyond 10. For each problem that your program can solve in less than 1 minute (approximately) of cpu time, report the cost of path that your problem solver finds. So the output of your program is a table where each row is number of cities followed by cost of tour.
  2. Write an two iterative improvement problem solvers for TSP. Report the results of these algorithm for each problem that the exhaustive problem solver could solve. Also report how well iterative improvement problem solvers do do on problems of size 10, 20, up to 100 cities. So in this case the output of the program is two tables.
Algorithm Notes:

For the exhaustive search I recommend using depth first search or simply writing a program to compute all permutations. Breadth first search algorithms will likely use too much memory although a use of A* may work. You can find Java programs for permutations on the web. If you use such a program, you should credit the original authors. In any case you will need to modify the algorithm to suit this problem.

The iterative improvement algorithms differ by the heuristics they use. One algorithm uses the "move" heuristic while the other algorithm uses the "uncross" heuristic. The "move" heuristic moves a city into a new position in the tour if it improves the tour length. The "uncross" reverses a subpath of the tour if that operation improves the tour length.

Extra Credit: No extra credit is allowed on late homework. Provide a graphical user interface that allows you to see the tours. This is non-trivial. The graphical interface should display the route, the cost of the route, allow the user to choose the search method, and show some of the improved paths (under user control).