| Forum | GitHub | Maps | Blog

Ensure no pickups before all deliveries in a vehicle's route


Hello everyone

It’s been a while since I started using Jsprit and recently stumbled upon a problem where I’m not able to figure out if there’s any way to ensure all deliveries before pickups.

So far I have used following approaches to achieve it:

  1. Setting ServiceDeliveriesFirstConstraint with CRITICAL priority-
ConstraintManager constraintManager = new ConstraintManager(problem, stateManager);
constraintManager.addConstraint(new ServiceDeliveriesFirstConstraint(), ConstraintManager.Priority.CRITICAL);
  1. Setting high priority for delivery shipment and low for pickup shipment-

shipmentBuilder.setPriority(1); // delivery shipment
shipmentBuilder.setPriority(3); // pickup shipment

But none of them seems to work.

I want to get a solution in which all deliveries are done before any pickup in the route of a vehicle. Is it possible to add this constraint somehow or is there any alternative?

P.S. Delivery and pickup time windows are overlapping and I can’t set delivery time window before pickup time window for all the nodes of my network.