AnyLogic simulates the model as a sequence of time steps and event steps.
During a time step:
- The model clock is advanced.
- The "discrete" state of the model (the statechart, port, event, etc. states) remains unchanged.
- Active equations, if any, are being solved numerically and the variables are changed correspondingly.
- Awaited change events are tested for occurrence.
During an event step:
- No model time elapses.
- The actions of states, transitions, events, ports, etc. corresponding to this event are executed.
- The state of the model may change.
- Some scheduled events may be deleted, and the new events may be scheduled in the AnyLogic Engine event queue.
AnyLogic engine events are events that occur at runtime. Please do not confuse them with static/dynamic events that are a part of AnyLogic modeling language. There are several types of engine events:
- current – events that can be executed at the time now
- chosen – one of the enabled events that is chosen to be executed next
- enabled – other current events (those that potentially could be executed next)
- scheduled – events scheduled at some particular known time in the future
- pending – events that may occur in the future, but the time is not known
Engine events reside in the engine event queue. Any event present in the engine event queue may be associated with:
- an active static/dynamic event
- a transition triggered by rate or on a timeout or expiry
In addition, current events may be associated with something that has just happened as a result of other event execution:
- a transition being triggered by a port, or by message or condition event.
If there are no current events, AnyLogic makes a time step to the nearest event (or events) in the queue, i.e., advances its clock. During a time step a condition event may occur. The discrete part of AnyLogic engine does not know when a condition event associated with a transition occurs: it depends on the equation set being solved numerically by a continuous part of the engine. Once this happens, the clock is advanced to the time reported by the continuous-time equation solver, and the event step is executed.
Several events may be scheduled to occur at the same moment of time. If there are several current events, AnyLogic chooses one and executes it. This is repeated until there are no current events. Thus, several event steps may be made in succession, whereas a time step is always followed by an event step. Simultaneous events may depend on each other or be truly concurrent. The serialization of concurrent events is called interleaving a model.
The execution of a timer event is actually the execution of the timer’s action code. The execution of a transition event is the execution of a set of actions associated with the transition. As a result of the event execution, the discrete state of the model may change: statecharts may change their states, other transitions may begin waiting, and other timers may be activated. Thus, some events may be deleted from the event queue and other events may be added to it.
The example of AnyLogic event queue processing is shown in the figure below.
Using AnyLogic Events panel, you can check the event queue of AnyLogic simulation engine to see what is happening at the simulation engine at the lowest level of detail.
The Events panel displays the event queue of AnyLogic simulation engine for the launched model. You can use the events panel for debugging purposes to see what is happening at the simulation engine at the lowest level of detail. The user often works with the events panel using the Step command.
To open the Events panel
- Launch the model.
- In the model window, click the Toggle Developer panel button and click the Events tab.
The Events panel itself consists of two tabs:
- Event queue - displays currently executed events and events scheduled for execution at a particular time.
- Monitored conditions - displays events that do not have a scheduled execution time, since the execution of such an event is triggered by a condition.
Both tabs can display no more than 50 events at a time. The events displayed are updated every 0.5 second.
Each event in the Events panel is displayed in the following form:
- Event number – The sequential number of this event in the event queue.
- Event originator – model path to the object that is associated with this event.
- Time left – the countdown until the moment when the event is scheduled to be executed.
The event that is going to be executed next is highlighted in blue. The system events, e.g. auto-generated chart update, are grayed-out. Events that occur at the same time are grouped together and the time left until these events are executed is displayed only for the first event in the group.
Depending on the type of the event, they are marked by different icons. The image on the left side of the icon indicates the source of event:
events scheduled by statecharts
The image on the right side of the icon indicates how the event is scheduled to occur:
timeout triggered event
condition triggered event
rate triggered event
To open the presentation of the agent that contains an event
- Click Pause button to pause the model execution.
- Click the event originator of the intended event.
To pause the model execution directly before particular event execution
- Click Pause button to pause the model execution.
Click the countdown of the intended event. The model execution will start again, run for the given time and then pause. While the model execution proceeds to the requested time of pause, the Events panel displays the following message:
How can we improve this article?