I have an industrial simulation with 2 agent types, operators and machines. Each agent type has statecharts controlling different aspects of their logic, like production, idle, etc. And while entering and exiting each single one of the states of the statecharts, times are calculated to determine how long each operator or machine spends in each state. So by the end of the simulation, I would print them or plot them using histograms to see the percentage of each step/state.
The problem that I'm having is the simulation's length is 480 minutes or 28800 seconds, but the sum of the time I calculate are different between runs and between agents (because I have 9 machines (from the agent type machine) and 6 operators (from the agent type operator)). For example, I would have 28750 seconds for operator#1 and 29000 seconds for operator#2 and so on.
I thought the reason the time was under 28800s was because sometimes the simulation is over before the agent leaves the current state, so the function wouldn't update because it didn't start the exist action. This make sense to me. But what makes no sense is the agents that exceed the length of the simulation (>28800s), some agents' time sums exceed the whole duration of the simulation, and I don't understand why.
Is there any way to know if the problem comes from a mistake I made while modeling or is this a problem with AnyLogic itself? I had a similar issue some while ago with the way AnyLogic calculate distance and got in contact with support, so I'm guessing maybe this time again it is some issue in the way AnyLogic handles time.
Edit, more details for @Artem P.:
Here is an example of the code used to calculate time elapsed, and the sum of codes, plus an example of the statechart:
This is the statechart of the machine, for example.
In the entry action and exit action of each of these states (the lowest level states, not the higher levels ones) there is code to calculate entry time, then exist time, and the subtraction, for example these are the entry and exit actions for the waiting state:
Waiting state entry and exit actions
I then add each time to its own DataSet so that I can plot them in a histogram and have a percentage view of all the times, hence the TnPAttente_DS.update();
If you need more detail, I'm happy to share!