Using jsprit to solve VRP with trailers

Hey everybody! I’ve got a routing problem that I’m trying to solve with jsprit. Essentially, I’m trying to solve a container haulage problem where prime movers need to pick up a trailer before being able to pick up a container.

This is pretty easy to solve with capacity constraints if the trailers and prime movers are in the same area but generally, they aren’t.

How I was thinking of modelling it as a VRP so that it can be solved with jsprit is that the trailers are considered jobs as well, but instead of decreasing a vehicle’s capacity, it would increase the capacity (since now the vehicle can pick up a container).

On the implementation front, I was thinking of putting a hard constraint to prevent visiting a trailer “job” when a vehicle already has a trailer to prevent the capacity from increasing past one. As for the real jobs, I was intending on using shipments since it will be a simple A -> B type job.

Any ideas on how to implement an increase in capacity? Or if you have a better way of modelling the problem using what jsprit already has available, I’m all ears.

P.S. I know this current algorithm will be horribly inefficient since the vehicles will attempt to visit all the trailers as well despite there being no other shipments but I’m looking to get it working first and optimise from there.

Hi @kneekill,

a trick for the increasing capacity thing: you can model the trailer job as a Delivery.

suppose your vehicle has capacity as 1, you have a trailer job which is a Delivery with size as 1, and some shipments, each with size 1. a Delivery job means that the loading of the job is done at the very beginning of the route, so the capacity is taken up at the beginning and thus the vehicle has to do the trailer job before it can do any of the shipments. once it has done the trailer job, it has a spare capacity of 1 and can do the shipments one by one.

is this what you want?

Best regards,
He

1 Like

Hey @jie31best,

Thanks for the quick reply. That works actually, but I missed out one further constraint in my initial explanation. The vehicles will leave the trailer with the container after the job (i.e., after reaching the destination) so to do another job they would have to get another trailer.

Would there be any way to decrement the capacity again after reaching the destination? I’m thinking using a pickup at the destination of the shipment would do this. After a pickup does the algorithm look for a delivery location which would be another trailer location or do pickups result in heading back to the depot?

If the former is the case, then this would be a solution to my problem!

Cheers,
Nik

EDIT: I just tested whether pickups -> deliveries and it does not. Pickups result in returning to the depot by default. Is there any other way I can change reduce the capacity?