3
votes

I'm using google's directions API to solve TSP. Is there any way to take advantage of google's route optimization without providing an origin AND destination. For my purposes, I only care to set the origin. The destination can be whatever is best fit for the waypoints given.

i.e.

https://maps.googleapis.com/maps/api/directions/xml?origin=A&destination=""&waypoints=optimize:true|C|D|E|F&key=XXXX

1
Did you ever find a solution to this?Clint

1 Answers

1
votes

No, the destination must be set according to Google API Docs

The example given in the Optimize section lists the destination being the same as the origin.

If this isn't acceptable, you could remove the last few sections of the returned route (i.e. back to the origin) so that you terminate at the last point. However, the route would be optimised based on returning home, which may not be optimal when the weighting of the links are functions of time of day.

The more accurate approach would be to iterate through using each of the waypoints as destination (removing from list of waypoints), doing a new request for each graph. This would be a better theoretical answer, although for a large amount of stops would be practically infeasible at scale because of the API quota limits.