My problem can be thought of as a floodgate: I want a predefined number of agents (e.g. 50) to run through this delay block at the same time. Since this is not possible in AnyLogic, I have divided the delay time by the number of desired agents. General Model.
The startHold should be open until the 50 agents have passed. The holdEnd should be blocked. When the queue contains the 50 agents, holdEnd should be opened, so that all agents can get out at once. Meanwhile startHold is still blocked, because otherwise more agents will come in. When there are no more agents in the queue, holdEnd is blocked again and startHold is opened.
My approach is the following: code
Let a counting variable, which was initialized in the class, count up when the queue is entered. Unfortunately the variable counts over the runtime and the code doesn't quite work as expected. Does anyone have a better approach? I would appreciate any idea or help.
use a wait block only and nothing else
and on the wait block on enter you do this:
if(self.size()==50){
self.freeAll();
}