Shipment with single pickup and multiple delivery

Based on my question on stackoverflow

Is it possible to make a shipment that has a single pickup point but has multiple delivery point?

An example case I have is a bike messenger that has to distribute letters from a single point of pickup to many addresses, the messenger has to go to the pickup point first, then deliver the letters. I tried making multiple Shipments for this (one Shipment per address), but then the pickup service time doesn’t make sense, because there’s not much difference in picking up one letter vs 100 letters for example.

Then, I tried to make separate Pickup and Delivery jobs. I made constraints that lets Pickup jobs to be done first before the other Delivery jobs. Then I read the documentation of Delivery class, it states that the job implies pickup at vehicle starting point (or depot), so this approach doesn’t make sense too.

Is there any other way?

Hi @Alvin_Megatroika,

Regarding your first approach, you can take a look at the following related post on dealing with service time of a bunch of activities at same location:

Regarding your second approach, you are right that it would be problematic if vehicle capacity is tight in your problem. For example, if your vehicle capacity is 1, assuming all job size is also 1, then, with shipments, you can do multiple jobs like pdpdpdpdpd… but with separate pickup and delivery jobs, together with the constraint, assuming pickup jobs are not combined, you can only do one pickup job (i.e., half job in the original shipment context). On the contrary, if your vehicle capacity is redundantly large, say, 1000, this would not be an issue.

Meanwhile, there is a discussion on job refactoring. This is just for your reference, because a proposed refactored job will be a list of activities with predefined order, so it might not be so useful for your problem.

Best regards,

I’ve been reading the post by @amit_ak from yesterday, I think he’s having the same problem as me, as I also found his stackoverflow post from a long time ago, it’s nice to think that I’m not alone. Thanks for your suggestion @jie31best, I think the first one is the most promising. I will try to combine your approach and the ones that are suggested by @stefan. Thank you so much, I will report back if the implementation works

@jie31best I implemented your suggestion in the first post along with @stefan’s suggestion. I manipulated the travel time before I build my cost matrix by duplicating locations that are related to shipments with multiple deliveries. So essentially in my cost matrix, I have the normal transport time that’s calculated by graphhopper and a duplicate one whose value has been added with the service time.

So far it works perfectly.