Hi OptaPlanner experts,
I'm new to OptaPlanner and I ask you some help.
As far as I find out from this thread that in the OptaPlanner's CVRPTW example (version CR4), the entity Vehicle
(here) represents a vehicle's trip (rather than a vehicle), I would like to ask how to manage a real situation, that is with a limited number of vehicles that cannot have overlapping trips.
In the mentioned thread the suggestion was to replace entity Vehicle with VehicleTrip, and create a new Vehicle entity. I suppose the new Vehicle has a list of VehicleTrip objects (since a vehicle can do several trips in a day - e.g.). But how to configure the planner in order to minimize the number of VehicleTrip s per Vehicle?
How should the example need to be modified? (I don't care about Swing part, only the model and the planner's configuration - listeners/DRL/XML)
EDIT
I modified the model as described above and created the method int getOverlappingTime()
in class VrpTimeWindowedVehicleRoutingSolution
, that returns the the quantity of overlapping time of different VehicleTrip
s of a same Vehicle
. Then I created the following rule:
rule "vehicleTripsOverlapping"
when
$solution : VrpTimeWindowedVehicleRoutingSolution()
then
scoreHolder.addHardConstraintMatch(kcontext, - $solution.getOverlappingTime());
end
The method works correctly (tested), but the score doesn't change (it seems the rule is not fired). Is there anybody who can help me please?