AnyLogic
Expand
Font size

Updating analysis data objects

Analysis data objects (Data set, Statistics, Histogram data, Histogram2D data) can be updated with new values in several ways:

  • Automatic update. New data samples are added automatically with the specified time period.
  • “Manual” update. New data samples are added “manually” by the user. The user calculates new values elsewhere and feeds it to a data object using the corresponding API.
  • Updating charts. Updates of data objects are caused by updates of charts displaying these data objects.
You can combine all these ways, e.g. you can use automatic update mode and also “manually” add some additional data samples in significant moments of time.

Automatic update

Use this mode if you wish to add new data samples periodically with the well-known recurrence. In this case the data object’s expression is evaluated dynamically with the specified time period and the resulting value is added to the data object.

To turn automatic update on

  1. Select the analysis data object in the graphical editor or in the  Projects view.
  2. Go to the Properties view.
  3. In the Data update section, choose Update data automatically option, and then enter the update rate in the Recurrence time box below.

If you do not want to update analysis data objects automatically, you can turn auto update off.

To turn automatic update off

  1. Select the analysis data object in the graphical editor or in the  Projects view.
  2. Go to the Properties view.
  3. In the Data update section, choose Do not update data automatically option.

“Manual” update

Use this mode if you wish to control the exact moments when the new data samples should be added to the chart, for example when those samples are generated by some specific events in the model.

To add new data sample “manually”, the user should calculate the value elsewhere and feed it to the data object using the corresponding API.

  • In case of one-dimensional data objects (Statistics, Histogram Data), you add new data samples by calling add(double value) function.
  • In case of two-dimensional data object (Data Set, Histogram 2D Data) you should provide two values by calling the function add (double xValue, double yValue).

In the following models data objects do not collect data automatically, but are set to manual update.

Here new samples are added to the dataset in the On enter action of the Sink block.

Demo model: Dataset for Cost Data Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).

In the following model, new samples are added to statistics in the event action.

Demo model: Statistics as Function of the Number of Observations Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).

Updating charts

In case when an analysis data object is displayed on a chart, updating this chart affects the data object also, namely, new data samples are added to the data object. See Updating charts for a more detailed discussion of how charts can be updated with new data samples.

How can we improve this article?