Search code examples
droolsoptaplannerdrools-planner

How to force some customer to be serviced by a specific vehicle in VRP examples of the OptaPlanner?


In the VRP examples of Optaplanner, I would like to force some customer to be serviced by a specific vehicle in VRP.

How to do this? Can anyone help me?


Solution

  • There are several ways. The easiest is probably just to add a hard constraint

    when
        Customer(forcedVehicleIsNotVehicle == true)
    then
        scoreHolder.addHardConstraint...
    end
    
    class Customer {
    
        public boolean isForcedVehicleIsNotVehicle() {
             return forcedVehicle != null
                  && vehicle != null && forcedVehicle != vehicle;
        }
    
    }