AnyLogic AnyLogic
Font size

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.

  2. Go to the Data section of the chart's properties. Click the  Add data item button to add data item to be displayed by this chart.
  3. Set the data item's Title: ATM utilization.
  4. 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 a 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().

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

  6. Now resize the chart as shown in the figure below:

Add a bar chart to indicate mean queue length

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

  2. Open the Appearance section of the  Properties view and choose the last option in the Bars direction property to make bars grow to the left. 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 the 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.

  3. Move block sink to the right and rearrange the connection between service and sink to make space for a block after the connector.
  4. Drag the  TimeMeasureEnd block from the  Process Modeling Library in the  Palette view into the graphical editor and place it before the sink block. Name the block timeTotal.
  5. Make sure that the ports of the timeTotal block are properly connected both to ATM and service blocks.
  6. 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 in 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.

  2. 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.
  3. Modify the data item's Title: Time in system distribution.
  4. 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.

How can we improve this article?