Search code examples
simulationanylogic

suspend(agent) is not working in AnyLogic


I have a SERVICE block which i want to stop working for two hours when 10th agent enter the service. So I used agent suspend and resume function for that. The image of implementation is given below.

enter image description here

MyDynamicEvent Properties section: enter image description here

Now when i run the model and 10th agent enter the SERVICE, traceln("reparing") gets print on console but MyDynamicEvent does not work which means SERVICE block does not stop working and agents keep passing the SERVICE block. It suppose to stop for 2 hours when 10th agent enters the service.


Solution

  • You understand Dynamic Events wrong. In your code, you are creating the DE when the 10th agent enters, but you schedule it to start 2 hrs later. So it will trigger, but 2 hrs after the 10th agent arrived.

    So the problem does not lie with the DE, but with the self.suspend(), imo