Best way to implement a map for TSP

282 views Asked by At

What is the best way to implement a map for solving the travelling salesman (tour) problem in ruby with about 25 cities? Is it best to use a graph and add each distance to each city as a vertex? Or does ruby have a better method for accomplishing this?

1

There are 1 answers

0
joelparkerhenderson On BEST ANSWER

This is well-traveled territory. :)

"Itinerary for a Traveling Salesman (#142) - by Morton Goldberg

A salesman wants to call on his customers, each of which is located in a different city. He asks you to prepare an itinerary for him that will minimize his driving miles. The itinerary must take him to each city exactly once and return him to his starting point. Can you write a Ruby program to generate such an itinerary?

This problem is famous and known to be NP-complete. So how can you be expected to solve it as a weekend Ruby Quiz project? It's unreasonable isn't it? Yes, it is, unless the conditions are relaxed somewhat."

See the complete page plus multiple solutions in the sidebar on rubyquiz