Each vehicle can carry max of 3 orders simultaneously.
How to assign an initial load to some vehicles that are already on their way to deliver an order?
final int capacityIndex =
routing.registerUnaryTransitCallback((long index) -> {
int nodeId = manager.indexToNode(index);
for(int[] pds : data.pickupsDeliveries) {
if(nodeId == pds[0]) return 1; // Increase on pickup
if(nodeId == pds[1]) return -1; // Decrease on delivery
}
return 0;
});
routing.addDimension(capacityIndex,
0,
1,
false,
"OrderCapacity");
RoutingDimension ordersDimension = routing.getMutableDimension("OrderCapacity");