Output data

class DataDict(*args, **kwargs)[source]

Dictionary for recorded simulation data.

Generated by Model, Experiment, or load(). Dictionary items can be defined and accessed like attributes. Attributes can differ from the standard ones listed below.

Variables
  • log (dict) – Meta-data of the simulation (e.g. name, time-stamps, settings, etc.).

  • parameters (dict, pandas.DataFrame, or DataDict) – Parameters that have been used for the simulation.

  • variables (pandas.DataFrame or DataDict)) – Dynamic variables, seperated per object type, which can be recorded once per time-step with record().

  • measures (pandas.DataFrame) – Evaluation measures, which can be recorded once per run with measure().

arrange(variables=None, measures=None, parameters=None, obj_types='all', scenarios='all', index=False)[source]

Combines and/or filters data based on passed arguments.

Parameters
  • variables (str or list of str, optional) – Variables to include in the new dataframe (default None). If ‘all’, all are selected.

  • measures (str or list of str, optional) – Measures to include in the new dataframe (default None). If ‘all’, all are selected.

  • parameters (str or list of str, optional) – Parameters to include in the new dataframe (default None). If ‘fixed’, all fixed parameters are selected. If ‘varied’, all varied parameters are selected. If ‘all’, all are selected.

  • obj_types (str or list of str, optional) – Agent and/or environment types to include in the new dataframe. Note that the selected object types will only be included if at least one of their variables is declared in ‘variables’. If ‘all’, all are selected (default).

  • scenarios (str or list of str, optional) – Scenarios to include in the new dataframe. If ‘all’, all are selected (default).

  • index (bool, optional) – Whether to keep original multi-index structure (default False).

Returns

The arranged dataframe

Return type

pandas.DataFrame

arrange_measures(variables=None, measures='all', parameters='varied', obj_types='all', scenarios='all', index=False)[source]

Returns a dataframe with measures and varied parameters. See DataDict.arrange() for further information.

arrange_variables(variables='all', measures=None, parameters='varied', obj_types='all', scenarios='all', index=False)[source]

Returns a dataframe with variables and varied parameters. See DataDict.arrange() for further information.

save(exp_name=None, exp_id=None, path='ap_output', display=True)[source]

Writes data to directory {path}/{exp_name}_{exp_id}/. Works only for entries that are of type DataDict, pandas.DataFrame, or serializable with JSON (int, float, str, dict, list). Numpy objects will be converted to standard objects, if possible.

Parameters
  • exp_name (str, optional) – Name of the experiment to be saved. If none is passed, self.log[‘name’] is used.

  • exp_id (int, optional) – Number of the experiment. If none is passed, a new id is generated.

  • path (str, optional) – Target directory (default ‘ap_output’).

  • display (bool, optional) – Display saving progress (default True).

load(exp_name=None, exp_id=None, path='ap_output', display=True)[source]

Reads output data from directory {path}/{exp_name}_{exp_id}/.

Parameters
  • exp_name (str, optional) – Experiment name. If none is passed, the most recent experiment is chosen.

  • exp_id (int, optional) – Id number of the experiment. If none is passed, the highest available id used.

  • path (str, optional) – Target directory (default ‘ap_output’).

  • display (bool, optional) – Display loading progress (default True).

Returns

The loaded data from the chosen experiment.

Return type

DataDict