I have a event that triggers by the condition linesSorted == totalLines. Which are 2 int variables. totalLines increases to about 200 when the model is just starting (within the first second), while linesSorted increases slowly as the simulation progresses.
However, even when the 2 variables are equal, the event is not triggered. The event, 2 variables, and the process blocks are in the same agent, a single agent created inside main.
Why is the event not triggering?
I tried moving the event and variables into main and it does trigger. Why does it only trigger if they are in main?
I have a event that triggers by the condition linesSorted == totalLines. Which are 2 int variables. totalLines increases to about 200 when the model is just starting (within the first second), while linesSorted increases slowly as the simulation progresses.
However, even when the 2 variables are equal, the event is not triggered. The event, 2 variables, and the process blocks are in the same agent, a single agent created inside main.
Why is the event not triggering?
I tried moving the event and variables into main and it does trigger. Why does it only trigger if they are in main?
Share Improve this question asked Mar 13 at 10:57 XanderWXanderW 131 silver badge5 bronze badges1 Answer
Reset to default 1Just because you define a condition does NOT mean that it is evaluated upon any change in the model.
This would make your models very slow as any condition would constantly check if it triggers.
Instead, it is your responsibility to "tell" the event about it.
In general, you should avoid condition-based events, transitions, etc. They lure you into a false sense of security.
You can replace ANY condition with a safer setup. In your case, whenever you change the 2 int variables, you would check if the condition is now met. If so, you trigger the code of the event (delete the event and put the code into a function)