Hi there,
Unfortunately it seems I cannot avoid looping over some (if not all) activities when newAct instanceof DeliverShipment.
The issue is not about calculating the change in the route duration as a result of the insertion of the corresponding PickupShipment. Instead, it is about the insertion of the DeliverShipment (i.e., newAct) itself. When I try to obtain the future waiting of nextAct using the internal state:
Double futureWaiting = this.stateManager.getActivityState(
nextAct, iFacts.getRoute().getVehicle(),
InternalStates.FUTURE_WAITING, Double.class);
it is the value before PickupShipment is inserted. But what I need is the value after PickupShipment is inserted, because the endTimeDelay_nextAct, which is calculated based on depTimeAtPrevAct, is the value after PickupShipment is inserted. It means that, in the calculation, there is a gap which is the change in the end time of nextAct (or the future waiting of it) caused by the insertion of PickupShipment.
However, it seems there is no easy way to get the new (after insertion of PickupShipment) future waiting of nextAct or the old (before insertion of PickupShipment) end time of nextAct. I tried to use nextAct.getEndTime() or calculate from nextAct.getArrTime(), but it seems it does not work. Maybe I’d try to calculate from prevAct.getEndTime()? But then it will get even more complicated, because I might need to distinguish whether prevAct is the corresponding PickupShipment.
If there is indeed no easy way to get that, it seems I will have to loop over the activities in the route.
@stefan what do you think? Please kindly let me know your comments. Meanwhile I wonder if LocalActivityInsertionCostsCalculator should also cater for this?
Best regards,
He