Shipments and Services together

hi…

i was experimenting with services and shipments… ive found that if i intermix the two, jsprit comes up with an invalid solution…

here’s the issue… ive defined a VehicleType with a capacity of 1… ive created some random Shipments and Services (each with size of 1 as well) and added them to the problem… when solved, one of the route comes out as follows:

+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| route   | vehicle              | activity              | job             | arrTime         | endTime         | costs           |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 1       | VEHICLE_1            | start                 | -               | undef           | 0               | 0               |
| 1       | VEHICLE_1            | pickupShipment        | SHP_6           | 4               | 14              | 4               |
| 1       | VEHICLE_1            | deliverShipment       | SHP_6           | 23              | 33              | 13              |
| 1       | VEHICLE_1            | pickupShipment        | SHP_8           | 35              | 45              | 15              |
| 1       | VEHICLE_1            | deliverShipment       | SHP_8           | 51              | 61              | 21              |
| 1       | VEHICLE_1            | service               | SVC_5           | 64              | 74              | 24              |
| 1       | VEHICLE_1            | end                   | -               | 81              | undef           | 31              |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+

how is this possible? the vehicle had a capacity of 1… how can it deliver the service SVC_5 after the shipments?

I would assume that if the vehicle has to handle SVC_5, it would need to load 1 unit of goods when leaving the depot… that would fill its capacity and hence this vehicle cannot pickup any more shipments en route till it has serviced SVC_5… in this case, it would NEED to handle SVC_5 before it can handle any shipments…

activity | job   | total capacity | capacity used
---------+-------+----------------+--------------
start    | -     | 1              | 1
pickup   | SHP_6 | 1              | 2 ???
deliver  | SHP_6 | 1              | 1
pickup   | SHP_8 | 1              | 2 ???
deliver  | SHP_8 | 1              | 1
service  | SVC_5 | 1              | 0

alternatively, if the vehicle leaves the depot without any goods, it can pick the shipments en route and deliver them as it goes… but in this case, it CANNOT handle SVC_5 as it would not have any goods to deliver…

activity | job   | total capacity | capacity used
---------+-------+----------------+--------------
start    | -     | 1              | 0
pickup   | SHP_6 | 1              | 1
deliver  | SHP_6 | 1              | 0
pickup   | SHP_8 | 1              | 1
deliver  | SHP_8 | 1              | 0
service  | SVC_5 | 1              | -1????

am i missing something? is this not how shipments and services are meant to work?

Asim

Have you specified the size to be 1 by .addSizeDimention()? If not, they are 0 size, and, if you print the size of them, you will get [noDimensions=1][[dimIndex=0][dimValue=0]].

The Service is modelled as Pickup (not Delivery). If you want to mix Shipments and Services, use either Pickup or Delivery.
Does this solve your issue?

yes… i made sure the size is 1…

Ah! This is it! You’re right. Looking thru the source code, I can verify that Services are indeed modelled as Pickups. Hence, the service SVC_5 is handled at the end of the route when the vehicle’s capacity is empty. =) Thanks for the insight mate. =)

Here’s what I got when I modelled Services as Deliveries instead…

+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| route   | vehicle              | activity              | job             | arrTime         | endTime         | costs           |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 2       | VEHICLE_1            | start                 | -               | undef           | 0               | 0               |
| 2       | VEHICLE_1            | delivery              | SVC_2           | 2               | 12              | 2               |
| 2       | VEHICLE_1            | pickupShipment        | SHP_6           | 16              | 26              | 6               |
| 2       | VEHICLE_1            | deliverShipment       | SHP_6           | 33              | 43              | 13              |
| 2       | VEHICLE_1            | end                   | -               | 47              | undef           | 17              |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+

Here, the SVC_2 is correctly at the start of the route (since it is a delivery now)… =)

1 Like

@stefan… as a suggestion, wouldnt it be better if Services were internally modeled as Deliveries instead of Pickups? this would ensure that mixing services and shipments would work right out-of-the-box… was there a special reason that Services are internally modeled as Pickups instead?

1 Like

@awesim It might be a good idea. Thanks. Maybe we should also think about removing the “general” service definition since if one needs exactly this service, one can model it with pickups.