1

I'm working on a project for a transport company. Essentially I get, let's say , 200 city's and 7 trucks and I need to compute best weight distribution over the 7 trucks and the shortest path overall (km).

Before I actually communicate with Google Maps API I do my own computation. For 7 trucks I can compute about 30 milion routes in about 2 hours. ( weight distribution is done with backtracking / dynamic programing and "next city" is chosed with some math formulas )

I need to compare those routes and remember the best one ( smallest km over the 7 trucks ).

I get something like this :

Truck 1
    City 1 (x,y)
    City 2 (x,y)
    City 3 (x,y)
    City 4 (x,y)
    .....

Truck 2
    City 1 (x,y)
    City 2 (x,y)
    City 3 (x,y)
    City 4 (x,y)
    .....

Truck 3
    City 1 (x,y)
    City 2 (x,y)
    City 3 (x,y)
    City 4 (x,y)
    .....

etc ...

Where (x,y) are longitude and latitude. I can compute the distance between each city with the Euclidean distance d = sqrt((x1 - x2)^2 + (y1 - y2)^2) so I end up with a graph.

I was thinking to use A* algorithm to order the city's of each truck and after get the distance between the ordered city's. The problem is that in real life the trucks are going to return to the starting point ... can A* take that in to account ?

I am aware that the shortest path in longitude/latitude will not always be the shortest in km , but is OK, let's say 90% accuracy will do.

Any idea how I can compute a "score" for each route ( all 7 trucks ) so it can map as close as possible to the actual km ?

( I can do limited calls to Google Maps API and I want to rule out the worst options locally )

doremifasolasido
  • 428
  • 5
  • 17
  • Have a look at the breadth-first and depth-first algorithms. – Abion47 Oct 25 '16 at 06:47
  • If Google Maps licens pricing is a problem, why not have a look at OpenStreetMap.org. – Thomas K Oct 25 '16 at 07:05
  • 1
    The Euclidean distance isn't correct because longitude degrees are not equal to latitude degrees except near the equator. You will do better with a great circle calculation. http://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-haversine-formula – JerryM Nov 04 '16 at 20:36
  • Thank you . Now I realize that I really needed this – doremifasolasido Nov 04 '16 at 22:32

0 Answers0