I am working with Time windowed vehicle routing problem.
My constraints are:
- I have customers (100) which have ready and due times.
- And vehicles (10) which also have ready and due times.
- Solver runs for 150 seconds.
The result respects the dueTime of customers, but not respecting the dueTime of Depot(or vehicle). I tried adding hard constraint for vehicle due time. But this lets many customers un-initialized though I have enough vehicle. Here is the hard constraint I used.
// TimeWindowedDept: extra hard constraints
rule "arrivalAfterDueTimeInDepot"
when
TimeWindowedCustomer($arrivalTime : arrivalTime, $vehicle : vehicle)
$customer : Customer(previousStandstill != null)
TimeWindowedDepot($vehicle != null && dueTime<($arrivalTime+$customer.getDistanceTo($vehicle)), $dueTime : dueTime)
then
scoreHolder.addHardConstraintMatch(kcontext, ($dueTime-($arrivalTime+$customer.getDistanceTo($vehicle))));
end
Please suggest if I have written incorrect rule. Or is there any other solution for this problem. Ask for any detail needed. Thank you.
EDIT 1 : I slightly changed the rule, but still same result.
// TimeWindowedDepot: extra hard constraints
rule "arrivalAfterDueTimeInDepot"
when
TimeWindowedDepot($dueTime : dueTime)
TimeWindowedCustomer(vehicle != null && $dueTime < arrivalTime+ getDistanceTo(vehicle), $arrivalTime : arrivalTime, $distance : getDistanceTo(vehicle))
then
scoreHolder.addHardConstraintMatch(kcontext, ($dueTime-$arrivalTime+$distance));
end