Hello guys,
Hi guys, I’m trying to use this constraint to limit routes to a certain distance. Ex. 200km
However, the solution is not respecting the constraint.
tks
StateManager stateManager3 = new StateManager(vehicleRoutingProblem);
ConstraintManager constraintManager3 = new ConstraintManager(vehicleRoutingProblem, stateManager3);
Map<Vehicle, Double> maxDistancePerVehicleMap = new HashMap<>();
for (Vehicle vehicle : vehicleRoutingProblem.getVehicles()) {
maxDistancePerVehicleMap.put(vehicle, 200000); // distance in meters
}
StateId distanceStateId = stateManager3.createStateId("distance");
stateManager3.addStateUpdater(new DistanceUpdater2(stateManager3, routingCosts, distanceStateId));
constraintManager3.addConstraint(new MaxDistanceConstraint(stateManager3, distanceStateId, vehicleRoutingProblem.getTransportCosts(), maxDistancePerVehicleMap), ConstraintManager.Priority.CRITICAL);
vra.setStateAndConstraintManager(stateManager3, constraintManager3);