VRP - Calculating distances with google maps

314 views
Skip to first unread message

pedrosi...@gmail.com

unread,
Jun 8, 2018, 7:03:08 AM6/8/18
to or-tools-discuss
Hello.

I would like to know if it is hard to change the VRP code to calculate distance between two locations with google maps API instead of úsing the manhattan distance.
Sorry but my knowledge of Python is really limited.
Í would like to change this to something that would me allow to calculate distance between position_1 and position_2 using googlemaps :

 def manhattan_distance(position_1, position_2):
    """Computes the Manhattan distance between two points"""
   
return (abs(position_1[0] - position_2[0]) +
            abs
(position_1[1] - position_2[1]))

Thanks!

core...@google.com

unread,
Jun 13, 2018, 4:36:09 AM6/13/18
to or-tools-discuss
You should take a look at https://developers.google.com/maps/documentation/distance-matrix/intro (Seems they also provide a python client also)

Please not you can be charged for doing lot of requests to the service...
Message has been deleted

core...@google.com

unread,
Jul 16, 2018, 3:31:44 AM7/16/18
to or-tools-discuss
ERRATUM: link is https://developers.google.com/optimization/routing/tsp#or-tools

On Saturday, July 14, 2018 at 6:39:51 PM UTC+2, Paul Trow wrote:
Take a look at this example: https://devsite.googleplex.com/optimization/routing/tsp#or-tools

Just calculate the distances between locations using the Distance Matrix API, enter them into a matrix, and pass the matrix to the distance function as in the example.

Hope this helps.
Reply all
Reply to author
Forward
0 new messages