-1

I am working with Time windowed vehicle routing problem.

My constraints are:

  1. I have customers (100) which have ready and due times.
  2. And vehicles (10) which also have ready and due times.
  3. 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

1 Answers1

1

After lots of iterations, here is the rule that solves my problem/use case.

// TimeWindowedDepot: extra hard constraints
rule "arrivalAfterDueTimeInDepot"
when
    TimeWindowedDepot($dueTime : dueTime)
    TimeWindowedCustomer(vehicle != null && previousStandstill!=null && previousStandstill==vehicle && $dueTime < arrivalTime + serviceDuration + getDistanceTo(vehicle), $arrivalTime : arrivalTime, $distance : getDistanceTo(vehicle), $serviceDuration : serviceDuration)
then
    scoreHolder.addHardConstraintMatch(kcontext, ($dueTime-$arrivalTime+$serviceDuration+$distance));
end

I think this may help someone in future.