Phase 4. Collecting statistics

With AnyLogic, you can collect complicated statistics whenever you need them. The blocks of the Process Modeling Library are already capable of collecting the basic statistics. We can view the statistics collected for the flowchart blocks with charts.

We want to observe how mean ATM utilization and mean queue length change with time.

Collecting utilization statistics

 Add a bar chart to indicate mean ATM utilization

  1. Open the Analysis palette. This palette contains charts and data objects used for collecting data and performing various statistical analysis on them. Drag the Bar Chart  element from the stencil into the graphical editor.

  1. Go to the Data section of the chart properties. Click the  Add data item button to add data item to be displayed by this chart.
  2. Modify the data item's Title: ATM utilization.
  3. Type ATM.statsUtilization.mean() as the Value of the data item. ATM is the name of the Delay block we created. Each Delay block has statsUtilization data set that collects statistics on the object utilization. The mean() is the function that returns the mean value measured. You can use other functions to get statistical values, such as min() and max().

  4. Change the position of the chart's legend in the Legend properties section.

  5. Then resize the chart as shown in the figure below:

Add a bar chart to indicate mean queue length

  1. Add one more bar chart in the same way. Resize it to look like the one in the figure.

  2. Open the Appearance section of the Properties view and choose the last option from the Bars direction choice to make bars grow to the left and also change the position of the chart's legend in the section Legend (like it is shown in the figure below).

  3. Click the  Add data item button.
  4. Set Title: Queue length and Value: queue.statsSize.mean()
    Here statsSize is the data set of type StatisticsContinuous that collects the statistics on the Queue size.

Run the model and observe the ATM utilization and mean queue length with new created charts.


Collecting customer time statistics

We want to know how much time customer spends in a bank. We will collect time statistics using AnyLogic Process Modeling library blocks TimeMeasureStart and TimeMeasureEnd. To measure the time agents spend in a particular section of the flowchart, we have to place these blocks at the entry point and at the exit point of this section. TimeMeasureStart block stores the time when an agent passed through it, while TimeMeasureEnd block measures the time an agent spent inside the specified section of the flowchart after passing the corresponding TimeMeasureStart block. 

Add time measurement blocks to the flowchart.

  1. Adjust the flowchart to make space for a new block between source and selectOutput.
  2. Open the Process Modeling library in the Palette view and add the TimeMeasureStart block in the resulting space. Make sure that the ports of the block are properly connected.

  1. Move block sink to the right and rearrange the connection between service and sink to make space for a block after the connector.
  2. Drag TimeMeasureEnd block from the Process Modeling library in the Palette view into the graphical editor and place it before sink block. Name the block timeTotal.
  3. Make sure that the ports of the timeTotal block are properly connected both to ATM and service blocks.
  4. Every TimeMeasureEnd block must have at least one TimeMeasureStart block specified in its properties to calculate the time distribution for agents. Specify our timeMeasureStart block for its TimeMeasureStart blocks parameter.


Add a histogram to indicate the collected statistics

  1. Open the Analysis palette. Drag the Histogram element from the palette into the graphical editor.

  1. Go to the Data section in the histogram's Properties. Click the Add histogram data button to add data item to be displayed by this histogram.
  2. Modify the data item's Title: Time in system distribution.
  3. Type timeTotal.distribution in the Histogram field.
    timeTotal is the name of the TimeMeasureEnd block that collects the distribution of time agents spend in the system.


Run the model. Set virtual time mode and observe distribution of customer's time in system.


Reference model: Bank - Phase 4


          Phase 3, Adding tellers