Multiple trips by vehicle in case of drops / Need of depot class?

When we define packages as drops only, a vehicle does not make multiple trips.
i.e. If vehicle has starting location A and there are 4 drop points (P,Q,R,S) following route is not possible A-P-Q-A-R-S
Vehicle delivers to P and Q then stops.

Also starting point of each vehicle is considered as depot and a vehicle is associated with that depot.
i.e: If there are two depots (A,B) and 4 drop points (P,Q,R,S) following route is not possible : A-P-Q-B-R-S.

Above two routes are possible is we define packages as shipments with pickup location A or B, but that limits the solution space.

Is there any work around this?

Do we need another class for depot with properties like, capacity, time windows etc?


If I correctly understand, you want to Pickup some materials from A or B and deliver those to P, Q, R and S whatever the source.
Then A and B must be defined as PickUp and P,Q,R and S as Delivery, which are both extends from Service. You’ll need to define at least one Capacity to limit the number of loads.

If you want your vehicle start from A or B, if you’re using a matrix, you can use a fake point which have 0 for each incoming or outgoing vertex. Furthermore, there is a branch which can do it in the general case :

If you encounter some trouble with the capacity management particularly with the PickUp and Delivery Services, have a look to this one :

It allows initial loads from vehicles too. You will need to update the objective function, if you don’t want to load every PickUp

The problem here is, I don’t know which depot will serve which demand.

i.e. It is possible that all P,Q,R,S are served by A only or B only or some mixture of A and B. I want algorithm to decide which demand will be served by which depot so as to minimize total cost.