0

I was just looking at some TSP algorithms the other day and wondered how efficient a common TSP algorithm (like Christofides' algorithm) is compared to a random route for say a thousand points.

If I'd know the answer or, even better, knew a way to calculate it, it would simplify testing my own algorithms a lot.

Is there anyone who can help me with this?

EDIT: The x and y coords of the points must be integers and they are placed in a 1000*1000 area.

Mastrem
  • 225
  • 2
  • 9
  • With efficient i ment the length of the total route. For instance, Christofides' algorithm outputs a route with a length of 1000 and the random route is 10000. With efficient I mean that in that case Christofides' algorithm outputs something which is only 10% of the random route. – Mastrem Feb 04 '16 at 18:55
  • The average distance between two random points in a unit square is just over a half. So for n points in 1000x1000, just over 500*n. But that uses some sneaky assumptions. – harold Feb 04 '16 at 18:57
  • 1
    Usually quality is measured in the percent increase from the optimal route though. – harold Feb 04 '16 at 19:05
  • Yes, I know, but I wanted to test my algorithm for up to 2500 points. It would take a lot of time to compute the optimal route for so many points. – Mastrem Feb 04 '16 at 19:12
  • 1
    A random route will be very poor. As a very rough estimate, the average distance between uniform points in a square is Θ(1), while the average shortest distance will be like Θ(1/√N), i.e. orders of magnitude shorter. Why don't you consider a greedy solution ? –  Feb 04 '16 at 19:45
  • @Mastrem there are many optimal solutions already available that you could use, but even aside from that, a mature TSP solver usually has no trouble with 2500 points, unless the structure is annoying (like d2103) – harold Feb 04 '16 at 20:09
  • I'd suggest using a heuristic like nearest neighbor or farthest neighbor. They are simple to code, very fast to execute, and usually perform pretty well. Christofides is interesting from a theoretical perspective because it has a worst-case bound, but it often returns solutions that are worse than those from NN, etc. I'm still not clear on why you want to compare to a random route. Are you developing a new heuristic and want to compare it to something reasonable? If so, compare to NN or something like it. – LarrySnyder610 Feb 07 '16 at 03:35

1 Answers1

2

To give you a rough imagination: The solution space, i.e. the number of possible routes, for a round trip (TSP) of 1000 points is 999! (assuming asymetric travel distances). To compare, 50! is a figure with 63 digits. Since it is combinatorial problem the solution space explodes very fast with the number of locations. Thus, if you generate a random route, the propability to hit the optimal solution is 1/999!. So out of 1000 cases, I guess that the probability that Christophides yields better solutions than your random approach is 1. And to give you a concrete answer to your question, your random approach is grossly inefficient compared to Christophides.

Stefan Schröder
  • 1,037
  • 7
  • 13
  • I know the randomness is very inefficient, I was just searching for an alternative way to benchmark my algorithms. I understand know that using a random route isn't going to work. Thanks for your answer! – Mastrem Feb 05 '16 at 21:30