Search code examples
optimizationmapsor-toolsvehicle-routing

Need help in solving Vehicle Routing in a production environment


I am working on a problem for my startup where I have to assign locations to delivery trucks based on an optimal route from a distribution center.

I am using ortools right now but I am working with gps coordinates unlike given example which is using a grid structure.

Right now I've figured out a way to calculate distance between coordinates and modified their demo python code but as far as I know there is no way to define gps coordinates as home depot and I am struggling there to get optimal routes from my home depot.

Any help would be appreciated.
Thank You


Solution

  • Actually, by providing a Distance callback function (cf. https://developers.google.com/optimization/routing/tsp/vehicle_routing#distance_callback) you can provide whatever you want as distance function...

    Thus, you could see 2D location as an id (e.g. GPS location of your addresses) then create a distance callback which calculate the shortest distance between two locations using road etc... (e.g. you can use the GMap Direction API)

    For the depot, it's just a node like others (i.e. has a location), then you can set this node as the depot in the RoutingModel Ctor...

    note: You should create a Distance cost matrix first then use it as a look up table to return distance in constant time during iteration cf example in the doc