Hi,
I am trying to implement a constraint to make sure that, for some (if not all) shipments, the time gap between the end time of their PickupShipment and the start time of the corresponding DeliverShipment (or maybe some other definition, such as start-start time gap, or start-end time gap, or end-arrival time gap, etc.) must not exceed some threshold.
This could be practically useful as, for some goods (say, frozen food, fresh fruit/seafood, etc.), the on-the-road time should not exceed some threshold (say, 4 hours).
As far as I see, it requires hard activity constraint and involves two parts:
-
when newAct is the DeliverShipment of one such shipment, obtain the end time of corresponding PickupShipment via jobInsertionContext.getRelatedActivityContext(), calculate the start time of newAct via prevActDepTime and routingCosts.getTransportTime(), and compare the gap against the threshold.
-
when the route already serves one (or multiple) such shipment(s), for each of them, calculate the new time gap assuming newAct is inserted, and compare against the threshold.
The second part will be time-consuming, as it will require looping through part of (if not all of) the tourActivity list of the route.
Next step I might want to generalize it to a constraint on the time gap between any two activities (say, a Service and a DeliverShipment), whether they are in the same route or not.
What do you think? Please let me know. Thanks.
Best regards,
He