Determine if route is empty method

Lately I have been spotting many constraint code samples that check the emptiness of the route determining if the previous activity is the start and the next one is the end. Initially, I thought that it was simple convention.

Now I’ve bumped into the source code of MaxDistanceConstraint which uses both methods. What i would like to know is what is the difference between these two cases.

I’ve tried running certain samples but, every time I have start and end as my previous and next activity the route is also empty. Is there a case when this does not hold true?


Hi @aj1310,

Do you mean (1)


vs. (2)

prevAct instanceof Start && nextAct instanceof End


The two are different when the insertion is to insert a shipment into an empty route and when

newAct instanceof DeliverShipment 

Under such circumstance, (1) is true while (2) is false, because prevAct is the corresponding PickupShipment.

You can refer to the ShipmentInsertionCalculator for details.

Best regards,

Thank you very much for the clarification