CS 3343 Assignment 5

Euclidean Travelling Salesman Problem in 3-Space

The Travelling Salesman Problem is this: A travelling salesman needs to plan tour of n cities, beginning and ending at city #1. He knows the distances between each pair of cities (in terms of miles, gallons of gasoline, cost of jet-lag medicine, etc.). He wants to find the best possible tour, i.e., the tour costing the least.

The Euclidean Travelling Salesman Problem is the problem of finding an optimal tour through n vertices in a Euclidean space, beginning and ending at the first vertex. A Euclidean space is simply one using the Euclidean metric for determining the distance between points, i.e., the square root of the sum of the square of the difference in corresponding coordinates. For the salesman, Euclidean distance means distance "as the crow flies" (assuming the Earth is flat, which it isn't, but flatness is a good approximation to reality for short distances and non-mathematical travelling salesmen).

The Euclidean Travelling Salesman Problem in 3-space is the same problem, only in three dimensions. Our travelling salesman in this case is travelling from station to station, possibly in outer space (which also isn't flat, but is close enough for sufficiently slow travelling salesmen and sufficiently small masses of destinations). The Euclidean distance between two points P1 = (x1, y1, z1) and P2 = (x2, y2, z2) is sqrt( (x1-x2)2 + (x1-x2)2 + (x1-x2)2).

Your assignment is to find the shortest tours you can for some sets of data. The input data files begin with a single integer, n, followed by n rows, each with three numbers; these are the x, y, and z coordinates of points in 3-space. All tours start at the first point, numbered 0. A tour is represented as a sequence of integers, beginning with 0, from 0..n-1. It is understood that the tour will continue from the last point to the #0 point, so 0 is only listed once per tour.

For example, here is a data file with 5 points:

5
38 58 13
15 51 27
10 19 12
86 49 67
84 60 25
One tour through the points is 0 4 3 2 1, with a length of about 253.05. Another tour is 0 3 2 4 1, with a length of about 354.33.

Here is another data file, this one with 12 points:

12
349 124 541
978 457 565
942 313 583
288 21 225
307 246 197
505 303 392
414 516 596
413 544 448
35 401 363
207 908 249
220 257 373
114 588 183
It turns out that 0 5 2 1 6 7 9 11 8 10 4 3 is an optimal tour for this data file. I found this out by feeding the numbers into a little C program, etsp.c , which gave me a tour. Then I verified the length of this tour with another little C program, checktour.c , which accepts the name of the data file on the command line and the tour on standard input; it told me the length of the tour is 3696.345703. You may use these programs for any purpose you wish. I suggest you look through etsp.c for ideas about how to represent the points, tours, code for the Euclidean distance, etc.

Here are the data files:

To turn in your assignment, simply send in your best tours for each of the data files. Send the tours, all at once, to the instructor through e-mail from the ringer system. Don't send me the lengths of the tours, I can calculate them with my program. Just send the name of the data file followed by your tour, for each file, e.g.:
tour10.txt: 0 1 2 3 4 5 6 7 8 9
tour20.txt: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
and so forth. Make sure all of the vertices for each tour are listed on the same line. i.e., one line per tour. This will make for very long lines for some tours; that's OK, my e-mail program can handle it and your program should be able to generate it.

Your grade will be on a scale of 1..10, with extra credit up to 15. Your assignment will only be graded if it is submitted in the proper format described above, so be very careful that you follow it; if you have any questions, please ask them. Assuming your assignment is submitted on time and in the proper format, your score will start at 5. You will get one more point for each tour of yours whose length is less than the class average (less than, not less than or equal to) for that tour.

For this assignment, you may work together if you like. That means you may share code, talk in explicit detail about the problem, trade results, all the stuff you're not normally supposed to do. You may form cliques or gangland-style syndicates (no intimidation or sabotage, please). You may use any resource you can find on the World Wide Web, in the library, or anywhere else. You may shamelessly rip off someone elses program you found on the Web if you can hack it to solve this problem. You may compute your solutions using any computing hardware you can get your hands on, or completely by hand if you wish (I just require that you submit the final results from ringer in the proper format). Lots of research has been done and programs written to solve the general and Euclidean travelling salesman problems with varying degrees of efficiency and much of it is available on the Web.

Note that 19! = 121,645,100,408,832,000, so my brute-force C code won't get you very far beyond the 10-point file; you'll have to go to a different method or wait for the heat death of the universe (the assignment is due before then).

This assignment is due through e-mail by midnight, Tuesday, April 28, 1998.