Phase 4. Adding Statistics Collection

With AnyLogic, you can collect complicated statistics whenever you need them. The objects of the Process Modeling Library are already capable of collecting the basic statistics. All you need is to turn the statistics collection for the object on, as it is disabled by default to speed up the model execution. We can view the statistics collected for the flowchart objects 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 of the Palette view. 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 in Properties of the chart. Click  Add data item 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 object we created. Each Delay object 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. Add a data item to be displayed by the chart. 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 just created charts.


Collecting customer time statistics

We want to know how much time customer spends waiting in ATM queue and the whole time he spends in the bank. We will collect time statistics using AnyLogic analysis data objects and observe the resulting time distributions using histograms. We will use the agent type Customer we have created on the step 2.

First we need to add two parameters into our model.

Add parameters

  1. Switch to the Projects view. Double-click the agent type Customer to open its diagram. We need to create parameteres for the agent type Customer if we want to collect customer statistics.
  2. Open the Agent palette of the Palette view. 
  3. Drag the element Parameter into the diagram of Customer.
  4. Leave the type double as it stands by default and name the parameters startWaiting and enteredSystem.

  5. We will continue developing our model in the Main diagram.

Add histogram data objects to store statistics on customer's waiting time and time in system. Histogram data objects support standard statistical analysis on the data values being added (calculate mean, minimum, maximum, deviation, variance and mean confidence interval).

 Add histogram data objects to collect time statistics

  1. To add histogram data object on the diagram, drag the Histogram Data from the Analysis palette of the Palette onto the Main diagram.

  2. Set up the properties of the element. 
  3. Create one more histogram data object. Ctrl+drag histogram data object to create its copy. Change the Name to timeInSystemDistr

Now we will modify properties of our flowchart objects.  

 Modify the properties of the flowchart objects

  1. Modify source properties:
  2. Modify queue properties:
  3. Modify sink properties:

Run the model and view the statistics using inspect window of the data set. Open inspect window for data set by clicking on it. Here you can see standard statistical analysis on the data values being added to this data object.


Now we want to display the collected statistics using standard histograms.

 Add two histograms to display distributions of customer's waiting time and time in system

  1. To add histogram on the diagram, drag the Histogram element from the Analysis palette of the Palette onto the diagram where you want to place the histogram. Resize it if needed.

  2. Define the data object to be displayed by this histogram. Click the Add histogram data button in Data section and change the Title to Waiting time distribution.
    Specify the Histogram to be displayed: waitTimeDistr

  3. Add one more histogram below the existing one. 
    Change the Title of the displayed data to Time in system distribution
    Choose the data object to be displayed: timeInSystemDistr

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


Reference model: Bank - Phase 4


          Phase 3, Adding tellers