I thought I had Jsprit calculating routes correctly according to costs. This doesn’t seem to be the case.
When testing I set most distances between deliveries to 9,999,999 with a vehicle travel cost of 1.
In the cost matrix (just a snippet);
(0,1) → (0,1) - Distance =0.0
(0,1) → (2,3) - Distance =21.432049573869172
(0,1) → (4,5) - Distance =9999999.0
(0,1) → (6,7) - Distance =9999999.0
(0,1) → (8,9) - Distance =9999999.0(2,3) → (0,1) - Distance =9999999.0
(2,3) → (2,3) - Distance =0.0
(2,3) → (4,5) - Distance =16.632664426972926
(2,3) → (6,7) - Distance =9999999.0
(2,3) → (8,9) - Distance =9999999.0
(2,3) → (10,11) - Distance =9999999.0
This loops through all deliveries and builds the matrix.
I then solve it;
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addAllVehicles(vrpBuilder.getAddedVehicles()).setFleetSize(FleetSize.INFINITE).setRoutingCost(costMatrix).addAllJobs(vrpBuilder.getAddedJobs()).build();
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp)
.setProperty(Jsprit.Parameter.FAST_REGRET, "true")
.setProperty(Jsprit.Parameter.THREADS, "4").buildAlgorithm();
vra.setMaxIterations(250);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
SolutionPrinter.print(Solutions.bestOf(solutions));
SolutionPrinter.print(vrp, Solutions.bestOf(solutions), SolutionPrinter.Print.VERBOSE);
But it results in the following;
+--------------------------------------------------------------------------------------------------------------------------------+
| detailed solution |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| route | vehicle | activity | job | arrTime | endTime | costs |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 1 | vehicle | start | - | undef | 0 | 0 |
| 1 | vehicle | delivery | 1 | 0 | 0 | 0 |
| 1 | vehicle | delivery | 88 | 0 | 0 | 9999999 |
| 1 | vehicle | delivery | 22 | 0 | 0 | 19999998 |
| 1 | vehicle | delivery | 87 | 0 | 0 | 29999997 |
Why does it use such a high cost? I would expect it to use 1 → 2 → 3 as the distances are correctly calculated if they are sequential.
What am I doing wrong to make Jsprit not take the distance cost into account?
Thanks,