anylogic

Separation of agents from their population


I really need help with a problem of mine. I have a population of 100 agents (cows) and i want to separate the 8 of them at some point at the main.

I create a selectOutput block and after i connect it with a hold block and i set the mode at "Block automatically after N agents" and i set the "N agents for self-block" to 8 and i create an cyclic event to unblock the hold block. enter image description here

enter image description here

I expected the hold block after the arrival of the 8 agents to block the entrance and the rest of the agents to pass through the selectOutput block but my simulation crashed and said that an agent couldn't leave from the selectOutput block.


Solution

  • Remove the hold and event.

    Instead, add a variable of type int, initial value 0.

    in the SelectOutput's true exit, write myCounterVar++;

    In the SelectOutput's condition, write myCounterVar<7

    Now, the first 8 will exit via true, the rest via false