anylogic

stop event triggered by rate in some states of my simulation


I’ve created four events in my AnyLogic model, each triggered by a rate (using the “rate” trigger type). In some specific states of my statechart, I need to temporarily stop these events from triggering and resume them in other states.

Previously, when I used events with a "timeout" trigger, I could simply call myevent.suspend() to stop the event and myevent.resume() to restart it. However, this approach doesn’t seem to work with events triggered by rate, and I’m struggling to find an alternative solution.

Here’s my specific issue:

I want to know how to stop an event triggered by rate in one state and restart it in another state. Currently, I don’t know how to properly suspend the event, and as a result, it continues to occur in states where it shouldn’t. Can anyone guide me on the correct way to suspend and resume events triggered by rate in a statechart?

Thanks in advance for your help!

I initially tried using myevent.suspend() and myevent.resume() as I did with timeout events, expecting it would work similarly for events triggered by rate. Specifically, I was hoping that calling myevent.suspend() would stop the rate-based event from occurring in a particular state, and myevent.resume() would restart it in a later state.

However, this didn’t seem to have any effect on the rate-triggered events—they continued to execute, even in states where I expected them to be suspended. I’m not sure if suspend() and resume() are applicable for rate-triggered events or if I need a different approach for managing these types of events.


Solution

  • However, this approach doesn’t seem to work with events triggered by rate, and I’m struggling to find an alternative solution.

    myEvent.reset(); stops the event until you call myEvent.restart(). It will then pickup the usual rate. Try it in a simple example model, it works

    PS: Use code-complete to see which methods you can use on objects: enter image description here

    As you can see, there is no suspend() or resume() method for rate-based events :)