This is how I would do it.
- obviously you will have agent types: passenger and bag
- you will create a connection between these 2 agents:
passenger will have a link 1 to many to your bags… let’s call it bagsLink
and bag will have a link 1 to 1 with a passenger… let’s call it passengerLink
If you have no idea what connections are, check this article:
benjamin-schumann.com/blog/2017/10/21/anylogic-agent-links-a-hidden-gem-for-your-connections
and learn how to use connections - you will replace queue and queue1 with wait blocks (passengerWait and bagsWait)
- On the passengerWait, on the onEnter action you will check if all the bags connected to the passenger are on the bagWait block… if they are… then you will free (wait.free(agent)) the passenger and the bags
- On the bagsWait, on the onEnter action you will check if the passenger connected to the bag is in the passengerWait block and if all the bags connected to the passenger are on the bagsWait block… if they are… then you will free (wait.free(agent)) the passenger and the bags
- add a small delay after the passenger block that represents the time it takes for the passenger to pick up the bags
- Use a pick up block after the delay on the passenger side (you will need a new queue after bagsWait in the bags side)
- Use the following condition to pick up the bags…
agent.passengerLink.getConnectedAgent().equals(container)
A lot to do, but it should work because I have done this before like this 🙂
4
solved Anylogic – Combined multiple items back to original owner [closed]