Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TSP (Traveling Salesman Problem) solver Using GoogleMap

We are developing an application, in which we will show some available houses for sale in google map. User can select any houses from the map and can find the shortest driving route between all the houses he/she selected.

Can any one please tell me how we can find the shortest route and can show that on the map? Is there any PHP based TSP library, that can help us to achieve what we are trying?

like image 442
jose Avatar asked Dec 24 '10 10:12

jose


People also ask

Does Google Maps use TSP?

Google now supports TSP problem. Free version of google map includes start, end and 8 middle points.

What is TSP problem what are the methods to solve TSP problem?

To solve the TSP using the Brute-Force approach, you must calculate the total number of routes and then draw and list all the possible routes. Calculate the distance of each route and then choose the shortest one—this is the optimal solution. This method breaks a problem to be solved into several sub-problems.

Which algorithm is best for TSP?

New hybrid cultural algorithm with local search (HCALS) is introduced to solve traveling salesman problem (TSP).

What is the difference between TSP and VRP?

TSP considers a single vehicle visiting multiple customer locations before returning to the depot, and we want to minimize the total travel time or vehicle distance. VRP differs from TSP because VRP can generate multiple routes to pass through all customer locations 2 .


2 Answers

A Google search shows many results.

  • http://scrivna.com/blog/travelling-salesman-problem/ - Brute force PHP implementation guaranteed to get the optimal answer. Only suitable for a limited number of nodes.

  • http://www.renownedmedia.com/blog/genetic-algorithm-traveling-salesperson-php/ - Genetic algorithm PHP implementation which will approximate the answer. Suitable for large numbers of nodes.

You could probably combine the two, choosing which to run based on the size of the graph.

As @Barbar points out in the comments, there is an existing app that does what you're attempting. There is a blog post explaining how it works.

like image 149
moinudin Avatar answered Oct 03 '22 06:10

moinudin


Its old but it may be useful to people: https://developers.google.com/maps/documentation/javascript/v2/services#RoutesAndSteps

just create waypoints for each house and let google do the math for you...

like image 43
Feras Avatar answered Oct 03 '22 07:10

Feras