Search code examples
simulationanylogic

AnyLogic wait-block, block condition available?


In my simulation I have different types of resources. At the start of my simulation I define several parameters to the different resources (machines). I want a predefined number of agents (e.g. 50) to run through my resource, so I chose to use a wait block inside my resources. So if there are more than 50 agents inside this resource, the wait block should release all 50 agents at once and block afterwards immediately. The code in the wait block looks like this: Code

So if an agent with the attribute machine1 comes into the resource and if the condition self.size() == 50 isn't true yet, the program jumps to the default case instead of staying in case machine1 until this condition is true. Is there some code for an possible else-Block, something like "self.stayInWaitBlockUntilIfConditionIsTrue"? Or another solution for my problem maybe with hold blocks? Didn't find something on AnyLogic help page.


Solution

  • Inside case machine1:, if you put an else statement saying else {break;}, it should work.