Search code examples
jsprit

Use time between locations instead of distance to optimize VRP


I'm trying to use jsprit for my VRP problem. The problem is as follows:

  1. I have multiple locations (services), and a matrix of transit times between them
  2. I have a finite number of vehicles
  3. I need to model a problem with jsprit such that it uses the transit times, instead of the coordinate distance between the locations.

Solution

  • See the example.

    matrixBuilder.addTransportTime(from, to, time);

    Above code is used to add time. If you don't want to add distance constraints just remove

    matrixBuilder.addTransportDistance(from, to, distance);