aws-samples / aws-last-mile-delivery-hyperlocal

AWS Last Mile Delivery Hyperlocal
Other
42 stars 11 forks source link

Implement Mixed Pickup-Dropoff in Dispatcher #8

Open sperka opened 2 years ago

rodrigokestler commented 1 year ago

Hi @sperka Are you planning on implementing penalization for drivers that have rejected orders previously? In other words, penalize driver scores for orders that they have rejected. I see a commented-out code for this, but it is using a class that does not exist

protected Constraint hasDriverCancelledThisOrderBefore(ConstraintFactory factory) {

       return factory.from(PlanningVisit.class)
         .penalizeLong(
           "hasDriverCancelledThisOrderBefore",
           HardMediumSoftLongScore.ONE_SOFT,
           PlanningVisit::hasDriverCancelledThisOrderBefore
         );
   }
sperka commented 1 year ago

Hi @rodrigokestler

We added these constraints as examples. If your business use-case requires such a thing, you can introduce it to your system. As far as I can imagine, assigning the same driver that already rejected the order can happen if..

  1. using one provider: order assigned -> driver rejected -> order back in queue -> order assigned again to same driver
  2. using multiple providers: order assigned -> driver rejected -> order lifecycle manager cycles through all other providers and gets back to the "original" that assigned that driver -> order gets assigned to the same driver again.

In both cases you can maintain a list in the PlanningDelivery object which drivers were assigned to that delivery item with what status (Accepted, Rejected, etc) and from which provider, or just simply which provider's which driver rejected the order. (I'd say in a prod environment you'd be maintaining already all the events that happen to an order, so you'd have this information already). Then hasDriverCancelledThisOrderBefore is a simple lookup.

Make sure that the information is accessible in-memory (i.e: pull the order data from a DB before kicking off the optimization phase).

Hope this helps!