The transition is executed when the condition becomes true. If the agent has continuously changing variables, the numeric engine constantly monitors the condition. In purely discrete models the condition is tested when something changes in the agent, i.e. when onChange() is called.
Condition triggered transition is depicted by the icon .
To define a condition triggered transition
A transition with such a trigger is enabled when the specified Boolean expression is true. If by the time the statechart comes to the source state of such transition the expression is true already, the transition becomes enabled immediately. Otherwise, it becomes enabled as soon as the expression becomes true – e.g., as a result of equation solving, as a change event may contain variables changing continuously according to a set of differential and algebraic equations. When the condition becomes true, AnyLogic determines the switch point – the moment when the expression becomes true – with the accuracy set by the user.
It is important to understand, when the transition's condition is checked by the model.
When specifying a change event, you should keep in mind the so-called sensitivity problem. Let the transition wait for the Boolean expression x>=5, and let x changes continuously in time as shown in the figure below:
As the numeric equation solver works by steps, it may happen that x will exceed the value 5 and get back in between the two steps. In this case the change event will not be detected. You should be aware of such situations when modeling systems where such error might be critical. If you encounter such a problem, you should make numerical method accuracies smaller.
Triggering a transition