Solving the Travelling Salesman Problem in Ruby (50+ Locations)

Solving the Travelling Salesman Problem in ruby (50+ locations)

This might be what you are looking for:

Warning:

this site gets flagged by firefox as attack site - but I doesn't appear to be. In fact I used it before without a problem

[Check revision history for URL]

rubyquiz seems to be down ( has been down for a bit) however you can still check out WayBack machine and archive.org to see that page:
http://web.archive.org/web/20100105132957/http://rubyquiz.com/quiz142.html

Best way to implement a map for TSP

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

Travelling salesman with a few constraints

A traveling salesman problem can be formulated as a integer programming problem (this link gives a formulation) or a constraint programming problem, so you can use any MIP or CP solver such as CBC or Gecode to solve the TSP problem with any extra constraints you want to add. However, if you need to plot the results on Google Maps, you'll have to do it manually using the Google Maps API.

If you prefer a web-based solution then you can use NEOS server for optimization which provides access to a variety of solvers via XML-RPC API. As an additional advantage this method allows submitting problems in a high-level modeling language such as AMPL rather than dealing with low-level solver APIs directly.



Related Topics



Leave a reply



Submit