In anylogic, I have modelled trucks to go to multiple delivery locations. The trucks moves to the first location in the collection using the code
moveTo(order.orderLocation.getFirst());
After the truck went to the first location, the first agent is removed using the code:
order.orderLocation.removeFirst();
The process iterates until the collection is empty (see figure).
I am trying to make the truck go to the nearest agent instead of just the first in the collection. However, I don't know what the code will be to remove the agent that it moved to. I also tried to sort the list based on the distance but didn't succeed. Does anyone know how to model this?