Reputation: 389
I'm interested to know the different methods the AnyLogic community uses to record time in state statistics. To explain what I mean, I'll give you an example:
Say I am modelling a movie theatre with multiple cinemas. Each cinema is modelled as an agent with a state chart in which the cinema can be in one of a number of states:
Suppose I now want to record and output statistics on the time and count of states that each cinema is in along the lines of:
Cinema 1 States:
+-----------+-------------+--------------+--------------+
| State | Occurrences | Average Time | % Total Time |
+-----------+-------------+--------------+--------------+
| Idle | 25 | 60 | 20% |
+-----------+-------------+--------------+--------------+
| Filling | 50 | 20 | 10% |
+-----------+-------------+--------------+--------------+
| InSession | 50 | 90 | 40% |
+-----------+-------------+--------------+--------------+
| Etc. | ... | ... | ... |
+-----------+-------------+--------------+--------------+
Please share the techniques that you use to achieve this in AnyLogic.
Upvotes: 1
Views: 1226
Reputation: 9421
No matter what you do, you need to create a variable that collects the info...
Occurrences:
You have a variable called occurrences starts with 0 and increments 1 each time the agent enters the state. You can calculate the average for all the agents later doing average(cinemas,c->c.occurrences)
AverageTime:
you can use either a collection from the agents palette or data set or statistics from the analysis.. there are so many ways to do this that I won't list them here, but data sets a stastics objects have their own average (getYmean and mean respectively) functions that you can use.
In the case of the state idle, You would have to have a variable timeIdle for instance that you increment every time unit whenever the state is idle
if(inState==idle) timeIdle+=timeUnit
And when the agent exits the state, or at the end of the simulation, or when you want to measure the value you can do data.add(timeIdle) if you are using a data set, and when you need to retrieve the average time you can do data.getYmean() if it's a data set object, or data.mean() if it's a statistics object
%total time:
same thing having a variable called percTotalTime... doing percTotalTime=timeIdle/time()
whenever you need to read the value.
You would have to do the same thing for each state.
Upvotes: 2