Data Recorder

 Data Recorder

The Data Recorder component is used to record and save data from a model. A Data Recorder produces a comma delimited tabular file. Each column is a Data Source (see below), and each row records the result of executing the code in those Data Sources.

Appropriate Parent Component

Data Recorder can be added to any model.

Properties

Properties are the items that appear in the property pane when you click on a component in the project tree. For more information of properties, see here.

Name     Description
Data Sources Add data sources for the data you want to record. Each piece of data you want to record is represented by a Data Source. A Data Source is basically an Action that defines the data that you want to record. When you click on Edit button of the Data Source property, you bring up the Data Source editor, which looks very similar to the Action editor (see Actions. However, here you add python code (see Not Quite Python) that computes and returns the data that you are interested in recording. The drop down box that showed the Actions in the Action editor holds the names of the various Data Sources in the Data Source editor. The name of the Data Source becomes the name of the column in the produced data file. You add a data source in the same way that you add an Action. Underneath the drop down box, you see a set of options that allow you to define the type of data that you will be recording. On the left hand side you have the option to define your data as either Object or Numeric. If the data is a number choose numeric, otherwise choose object. For example, if you want to record a piece of text like 'Agent 1', you should choose Object. If you choose Numeric, you also have a couple of other options. On the right hand side, you see Max Integer Digits and Max Fractional Digits. This allows you to specify the precision of your data. If left empty, they both default to infinite. The Variables and Java Imports sections behave exactly as they do in the Action Editor (Actions). The nqpy section is slightly different with a data source than it is with the actions. For a data source, the code section must return some value where some value is the actual data that you want to record. For example:

counter = 0
for agent as MyAgent in self.agentGroup:
  if(agent.type == 0):
    counter = counter + 1
return counter

This data source returns the number of agents that are of type 0. In this way you can calculate averages standard deviations and other statistics easily.

File Name This is the name of the data file that will be produced by this data recorder. Make sure that you have permission to write to the file before choosing one.
Header Comment This is an optional piece of text that will be recorded as a comment at the top of your data file. This can be useful for clearly identifying the contents of a data file.
Name This is a unique name that identifies this Data Recorder.
Schedule See the schedule help and tutorial 3 for more information on the schedule property. The schedule property defines the execution schedule of any actions defined in your Data Recorder.

Although there are no user-definable actions associated with the Data Recorder component, Data Recorder implicitly defines two actions:

  1. record. This records the values of the data sources. In effect, it executes the code in each data source and stores the return value. Note, it does not write the data to a file, it just saves it.

  2. write. This actually writes the data to a file, until this action is executed the data file does not exist.

The record action should be scheduled at any interval necessary to the model. The write action should be scheduled at a minimum as the last action in the simulation, but possibly more often. There is a performance penalty for writing the data to a file, so the frequency with which you schedule the write action will largely depend on your particular model.