Search code examples
jsprit

Do the jsprit TSP and VRP solvers allow provided time and distance constraints between points?


Does anyone know if the jsprit solvers use a 'as the crow flies' geometric distance between two points in a route by default? And if so, is it possible to constrain this by providing to jsprit as parameters pre-calculated times/distance between adjacent points, as provided by e.g. a Google Directions calculation?

This is to allow for classic problems such as the true distance between two points could be much further than the straight-line distance if the real world journey was from one side of an estuary without a bridge being available etc?


Solution

  • By default jsprit uses euclidean distances or as you put it 'as the crow fly' distances. If you want to consider your own distance measure, just implement VehicleRoutingTransportCosts. Assign it when building your vehicle routing problem with .setRoutingCosts(..). If you have a time and/or distance matrix, you can also use this.