I am currently using queue
- and delay
-blocks and I want the agents inside of them only to exit if certain conditions are true.
I have used certain if-else
blocks which did not work. I am using ANyLogic as stated in the question so it is basically Java.
You need to do this outside of flow blocks, for example with a cyclic event:
Put your if-else check in there. If the condition is met, call myQueueBlock.remove(theAgentToRemove)
or myDelayBlock.remove(theAgentToRemove)
NOTE that it is your responsibility to decide which agent to remove (hence the theAgentToRemove
). If you want to remove the i
th agent, you could use myQueueBlock.remove(myQueueBlock.get(i))
. But you must manage this
NOTE also that your agents will be outside of any flow chart block after calling these commands. If you need them to join another block somewhere, you need to use an "Enter" block and call myEnterBlock.take(theAgentToRemove)
from within the Event