I have another approach to implement in this case. But I don't know if is there any problem with it.
define the value range provider in the planning entity, and filter it in the getter method, such as:
@ValueRangeProvider
public List<Vehicle> getPossibleVehicleList() {
return possibleVehicleList;
}
// Save the vehicles that can access this customer.public void setPossibleVehicleList(List<Vehicle> possibleVehicleList) {
this.possibleVehicleList = possibleVehicleList;
}
About the value range provider in planning entity, see this chapter:
https://docs.optaplanner.org/9.37.0.Final/optaplanner-docs/html_single/index.html#valueRangeProviderOnPlanningEntityIn some cases, the solver needs to get some solutions that break hard constraints temporarily to escape local optima. So this approach may have an impact on the quality of the solution.
Best regards.
Kent