1

I am faced with some real-world VRP optimization problems and would like to kick the tires of jsprit. I have a set of jobs with associated skill constraints; a set of users to service those jobs with skill constraints and time windows; and lat-lon based coordinates on all of the above.

I have been running some examples like the VRPWithBackhaulsExample, so I can see that I need to set up a set of ConstraintManagers but I am having trouble mapping my domain to jsprit concepts in these areas:

  • How do I express lat-lons in terms of JSprit inputs? It seems like the examples use points in two-dimensional space. It appears that I need to use VehicleRoutingTransportCosts, but I am unclear on how to do that.
  • Are there examples of using time windows in non-delivery models? I am aware of this post, but it does not seem like the same model as what I describe above.

I'm just looking to get pointed in the right direction, any guidance welcome.

icey502
  • 132
  • 2
  • 5

1 Answers1

3

How do I express lat-lons in terms of JSprit inputs?

You can use normal lat/long (e.g. 51.5287718, -0.2416806) inputs. Jsprit uses a Euclidean distance calculator if a distance matrix is not set explicitly. See the code here and here.

Besides the default Euclidean distance calculator, they also have a Great Circle Distance/Costs Calculator which uses the Haversine formula. You just need to call .setRoutingCost(new GreatCircleCosts()) before you build the problem, see here.

If you need road distances then you'll have to generate a distance matrix yourself. You can use something like Google Maps Distance Matrix API or Graphhopper Matrix API (We currently use the latter because of Google Maps API license restrictions) e.g. you could extend the AbstractForwardVehicleRoutingTransportCosts class, make API calls to a distance matrix service and then do something like vrpBuilder.setRoutingCost(instanceOfYourCustomDistanceMatrix)

Open Door Logistics (ODL) Studio works well for this type of thing if you don't want to work at the Java level. Look at the Vehicle Routing and Scheduling Tutorial to see how ODL can build the distance matrix using Graphhopper for you.

Are there examples of using time windows in non-delivery models?

Not sure what you are asking but time windows are honoured for service jobs too.

Shameless plug: you can use our web app at intelligentrouting.io if you don't want to write any Java and don't feel like setting up ODL.

He Huang
  • 136
  • 3
Heinrich Filter
  • 5,760
  • 1
  • 33
  • 34