Data Collection and Recording Tools

Empirical includes a variety of tools for gathering and recording data. The core of these tools is the DataNode class. DataNodes are containers that you can pass as much data as you like into. When DataNodes are built, they can be given various modifiers (specified as template arguments) which control how much information they will collect about the data they are passed. For instance, the data::Current modifier gives the DataNode the power to remember the last value it was passed, whereas the data::Stats modifier keeps track of a variety of statistics about the distribution of data that the node has been passed. Except where otherwise noted, modifiers can be combined freely. Some also have dependencies on simpler modifiers. On the whole, DataNodes are designed to be as light-weight as possible while still keeping track of the desired information.

DataNodes that accept the same type of data and have the same modifiers can be grouped together using a DataManager.

The DataInterface class provides a general interface for interacting with DataNodes of any type. This is useful in cases where you have a collection of different types of DataNodes and want to operate on them without casting.

The DataFile class provides an interface for recording data at regular intervals. This data can come from DataNodes, the return of a specified function, or the contents of a specified variable. DataFiles are useful for collecting data over the course of a computational experiment.

Data Tools API

DataNodes

DataNode objects track a specific type of data over the course of a run.

Collection: New data can be pushed or pulled. Add(VAL… v) pushes data to a node AddDatum(VAL v) pushes just one datum, but can be used as an action for a signal.

Note

This file is part of Empirical, https://github.com/devosoft/Empirical

Copyright

Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md

Date

2016-2018

Process: What should happen on Reset() ?

  • Trigger an action to process the prior update’s data stored.

  • Clear all data.

  • Send data to a stream (or stats automatically have a stream that, if non-null data is sent to?)

template<>
struct emp::DataModInfo<data::Archive>

Public Types

using reqs = ModPack<data::Log>
template<>
struct emp::DataModInfo<data::FullRange>

Public Types

using reqs = ModPack<data::Range>
template<>
struct emp::DataModInfo<data::Stats>

Public Types

using reqs = ModPack<data::Range>
template<typename VAL_TYPE, emp::data... MODS>
class emp::DataNodeModule<VAL_TYPE, data::Current, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.hpp>

== data::Current == This module lets you track the current (i.e. most recently added) value

Public Functions

DataNodeModule()
const VAL_TYPE &GetCurrent() const

Return the current (most recently added) value.

void AddDatum(const VAL_TYPE &val)

Add.

Parameters

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Current, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

VAL_TYPE cur_val

Most recent value passed to this node.

template<typename VAL_TYPE, emp::data... MODS>
class emp::DataNodeModule<VAL_TYPE, data::Info, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.hpp>

== data::Info == This module adds information such as a name, description, and keyword for this node.

Public Functions

DataNodeModule()
const std::string &GetName() const

Get this DataNode’s name.

const std::string &GetDescription() const

Get this DataNode’s description.

const std::string &GetKeyword() const

Get this DataNode’s keyword.

void SetName(const std::string &_in)

Set this DataNode’s name to specified value.

void SetDescription(const std::string &_in)

Set this DataNode’s description to specified value.

void SetKeyword(const std::string &_in)

Set this DataNode’s keyword to specified value.

void SetInfo(const std::string &_n, const std::string &_d = "", const std::string &_k = "")

Set this DataNode’s information

Parameters
  • _n: value to set name to

  • _d: value to set description to

  • _k: value to set keyword to

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using parent_t = DataNodeModule<VAL_TYPE, MODS...>

Protected Attributes

std::string name

Name of this data category.

std::string desc

Description of this type of data.

std::string keyword

Short keyword.

template<typename VAL_TYPE, emp::data... MODS>
class emp::DataNodeModule<VAL_TYPE, data::Log, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.hpp>

== data::Log == This module lets you log all of the values that have been added since the last re-set

Public Functions

DataNodeModule()
const emp::vector<VAL_TYPE> &GetData() const

Get a vector of all data added since the last reset.

double GetMedian() const

Calculate the median of observed values.

double GetPercentile(const double pct) const

Calculate a percentile of observed values.

void AddDatum(const VAL_TYPE &val)

Add.

Parameters

void Reset()

Reset this DataNode (clear the current log of data)

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Log, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

emp::vector<VAL_TYPE> val_set

All values saved since last reset.

template<typename VAL_TYPE, emp::data... MODS>
class emp::DataNodeModule<VAL_TYPE, data::Archive, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.hpp>

== data::Archive == This module keeps track of historical values in addition to those added since the last re-set. Every time Reset() is called, all values that have been added since the previous time Reset() are stored in a vector in the archive.

Public Functions

DataNodeModule()
const auto &GetArchive() const

Get all data ever added to this DataNode. Returns a vector of vectors; each vector contains all data from a single time point (interval between resets)

const emp::vector<VAL_TYPE> &GetData(size_t update) const

Get a vector of all data that was added during the.

Parameters
  • update: ‘th interval between resets.

const emp::vector<VAL_TYPE> &GetData() const

Get a vector of all data that has been added since the last reset.

size_t GetResetCount() const

Get the number of time intervals recorded in this DataNode. Note that this is one more than the number of times it has been reset

void Reset()

Reset this DataNode, starting a new grouping of values in the archive. Resetting is useful for tracking data from different time points, such as per update or generation.

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Archive, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

emp::vector<emp::vector<VAL_TYPE>> archive

Data archived from before most recent reset.

template<typename VAL_TYPE, emp::data... MODS>
class emp::DataNodeModule<VAL_TYPE, data::Range, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.hpp>

== data::Range == This module allows this DataNode to store information (min, max, mean, count, and total) about the distribution of the values that have been added since the last call to Reset().

Public Functions

DataNodeModule()
double GetTotal() const

Get the sum of all values added to this DataNode since the last reset.

double GetMean() const

Get the mean of all values added to this DataNode since the last reset.

double GetMin() const

Get the min of all values added to this DataNode since the last reset.

double GetMax() const

Get the max of all values added to this DataNode since the last reset.

void AddDatum(const VAL_TYPE &val)

Add.

Parameters

void Reset()

Reset DataNode, setting the running calculations of total, min, mean, and max to 0.

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Range, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

double total

Total of all data since last reset.

double min

Smallest value passed in since last reset.

double max

Largest value passed in since last reset.

template<typename VAL_TYPE, emp::data... MODS>
class emp::DataNodeModule<VAL_TYPE, data::FullRange, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.hpp>

== data::FullRange == This module makes the DataNode store a history of distributional information measured by data::Range between calls to Reset(). Series of historical values are stored in vectors (except mean, which is calculated from total and count).

Public Functions

DataNodeModule()
double GetTotal() const

Get the sum of all values added to this DataNode since the last reset.

double GetMean() const

Get the mean of all values added to this DataNode since the last reset.

double GetMin() const

Get the minimum of all values added to this DataNode since the last reset.

double GetMax() const

Get the maximum of all values added to this DataNode since the last reset.

double GetTotal(size_t update) const

Get the sum of all values added to this DataNode during the.

Parameters
  • update: specified.

double GetMean(size_t update) const

Get the mean of all values added to this DataNode during the.

Parameters
  • update: specified.

double GetMin(size_t update) const

Get the minimum of all values added to this DataNode during the.

Parameters
  • update: specified.

double GetMax(size_t update) const

Get the maximum of all values added to this DataNode during the.

Parameters
  • update: specified.

size_t GetResetCount() const

Get the number of time intervals recorded in this DataNode. Note that this is one more than the number of times it has been reset

void Reset()

Store the current range statistics in the archive and reset for a new interval.

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::FullRange, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

emp::vector<double> total_vals

Totals from previous resets.

emp::vector<size_t> num_vals

Value counts from previous resets.

emp::vector<double> min_vals

Minimums from previous resets.

emp::vector<double> max_vals

Maximums from previous resets.

template<typename VAL_TYPE, emp::data... MODS>
class emp::DataNodeModule<VAL_TYPE, data::Stats, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.hpp>

== data::Stats == Note: These statistics are calculated with the assumption that the data this node has received is the entire population of measurements we’re interested in, not a sample.

Note 2: Kurtosis is calculated using Snedecor and Cochran (1967)’s formula. A perfect normal distribution has a kurtosis of 0.

Public Functions

DataNodeModule()
double GetVariance() const

Get the variance (squared deviation from the mean) of values added since the last reset.

double GetStandardDeviation() const

Get the standard deviation of values added since the last reset.

double GetSkew() const

Get the skewness of values added since the last reset. This measurement tells you about the shape of the distribution. For a unimodal distribution, negative skew means that the distribution has a longer/thicker tail to the left. Positive skew means that ths distribution has a longer/thicker tail to the right.

double GetKurtosis() const

Get the kurtosis of the values added since the last reset. This is another measurement that describes the shape of the distribution. High kurtosis means that there is more data in the tails of the distribution (i.e. the tails are “heavier”), whereas low kurtosis means that there is less data in the tails. We use Snedecor and Cochran (1967)’s formula to calculate kurtosis. Under this formula, a normal distribution has kurtosis of 0.

void AddDatum(const VAL_TYPE &val)

Add.

Parameters

void Reset()

Reset this node (resets current stats to 0)

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Stats, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

double M2

The second moment of the distribution.

double M3

The third moment of the distribution.

double M4

The fourth moment of the distribution.

template<typename VAL_TYPE, emp::data... MODS>
class emp::DataNodeModule<VAL_TYPE, data::Histogram, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.hpp>

== data::Histogram == Make the DataNode track a histogram of values observed since the last reset.

Public Functions

DataNodeModule()
VAL_TYPE GetHistMin() const

Returns the minimum value this histogram is capable of containing (i.e. the minimum value for the first bin)

VAL_TYPE GetHistMax() const

Returns the maximum value this histogram is capable of containing (i.e. the maximum value for the last bin)

size_t GetHistCount(size_t bin_id) const

Return the count of items in the.

Parameters
  • bin_id: ‘th bin of the histogram

double GetHistWidth(size_t bin_id) const

Return the width of the.

Parameters
  • bin_id: ‘th bin of the histogram

const emp::vector<size_t> &GetHistCounts() const

Return a vector containing the count of items in each bin of the histogram.

int GetOverflow() const

Return the count of numbers added to this histogram that were above the upper bound on the histogram

int GetUnderflow() const

Return the count of numbers added to this histogram that were belowed the allowed lower bound

emp::vector<double> GetBinMins() const

Return a vector containing the lowest value allowed in each bin.

void SetupBins(VAL_TYPE _min, VAL_TYPE _max, size_t num_bins)

Sets up the ranges of values that go in each bin of the histogram.

Parameters
  • _min: - the lowest value allowed in the histogram

  • _max: - the largest value allowed in the histogram

  • num_bins: - The number of bins the histogram should have. The distance between min and max will be easily divided among this many bins.

void AddDatum(const VAL_TYPE &val)

Add.

Parameters

void Reset()

Reset the DataNode (empties the historgram)

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Histogram, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

VAL_TYPE offset

Min value in first bin; others are offset by this much.

VAL_TYPE width

How wide is the overall histogram?

IndexMap bins

Map of values to which bin they fall in.

emp::vector<size_t> counts

Counts in each bin.

size_t overflow
size_t underflow
template<typename VAL_TYPE, emp::data... MODS>
class emp::DataNodeModule<VAL_TYPE, data::Pull, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.hpp>

== data::Pull == This module makes it possible to give the DataNode a function that it can call to calculate new values or sets of values that it will then track. These functions are called every time the PullData method is called on this node, and the values they return are measured as specified by the other modules in this node.

Public Functions

DataNodeModule()
void AddPull(const std::function<VAL_TYPE()> &fun)
void AddPullSet(const std::function<emp::vector<VAL_TYPE>()> &fun)
void PrintDebug(std::ostream &os = std::cout)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Pull, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Functions

void PullData_impl()

Protected Attributes

emp::FunctionSet<VAL_TYPE()> pull_funs

Functions to pull data.

emp::FunctionSet< emp::vector< VAL_TYPE >)> pull_set_funs

Functions to pull sets of data.

namespace emp

If we are in emscripten, make sure to include the header.

Typedefs

using ModPack = emp::ValPack<(int)MODS...>

A shortcut for converting DataNode mod ID’s to ValPacks.

using DataMonitor = DataNode<T, data::Current, data::Info, data::Range, data::Stats, MODS...>

A node that stores data about the most recent value it received, as well as the distribution (min, max, count, total, and mean) of values it has received since the last reset. It also allows you to give it a name, description, and keyword.

using DataLog = DataNode<T, data::Current, data::Info, data::Log, MODS...>

A node that stores data about the most recent value it received, as well as all values it has received since the last reset. It also allows you to give it a name, description, and keyword.

using DataArchive = DataNode<T, data::Info, data::Archive, data::FullRange, MODS...>

A node that stores all data it receives in an archive (vector of vectors). The inner vectors are groups of data that were received between resets. This node also keeps a record of the min, max, count, and total of each vector, so you don’t have to recalculate it later. Additionally, it allows you to give it a name, description, and keyword.

Enums

enum data

A set of modifiers are available do describe DataNode.

Values:

enumerator Current

Track most recent value.

enumerator Info

Include information (name, keyword, description) for each instance.

enumerator Log

Track all values since last Reset()

enumerator Archive

Track Log + ALL values over time (with purge options)

enumerator Range

Track min, max, mean, total.

enumerator FullRange

Track Range data over time.

enumerator Histogram

Keep a full histogram.

enumerator Stats

Track Range + variance, standard deviation, skew, kurtosis.

enumerator Pull

Enable data collection on request.

Various signals are possible:

enumerator SignalReset

Include a signal that triggers BEFORE Reset() to process data.

enumerator SignalData

Include a signal when new data is added (as a group)

enumerator SignalDatum

Include a signal when each datum is added.

enumerator SignalRange

Include a signal for data in a range.

enumerator SignalLimits

Include a signal for data OUTSIDE a range.

enumerator UNKNOWN

Unknown modifier; will trigger error.

template<emp::data MOD>
struct DataModInfo
#include <DataNode.hpp>

Extra info about data modules that we need to know before actually building this DataNode. (for now, just REQUISITES for each module.)

Public Types

using reqs = ModPack<>
template<> Archive >

Public Types

using reqs = ModPack<data::Log>
template<> FullRange >

Public Types

using reqs = ModPack<data::Range>
template<> Stats >

Public Types

using reqs = ModPack<data::Range>
template<emp::data... MODS>
struct DataModuleRequisiteAdd
template<emp::data CUR_MOD, emp::data... MODS>
struct DataModuleRequisiteAdd<CUR_MOD, MODS...>

Public Types

using next_type = typename DataModuleRequisiteAdd<MODS...>::type
using this_req = typename DataModInfo<CUR_MOD>::reqs
using type = typename next_type::template append<this_req>
template<>
struct DataModuleRequisiteAdd<>

Public Types

using type = ValPack<>
template<typename VAL_TYPE, emp::data... MODS>
class DataNode : public emp::DataNode_Interface<VAL_TYPE, FormatDataMods<MODS...>::sorted>

Public Functions

void Add()
template<typename ...Ts>
void Add(const VAL_TYPE &val, const Ts&... extras)

Methods to provide new data.

void PullData()

Method to retrieve new data.

void Reset()

Methods to reset data.

void PrintCurrent(std::ostream &os = std::cout) const

Methods to Print the templated values that a DataNode can produce.

void PrintLog(std::ostream &os = std::cout, const std::string &spacer = ", ", const std::string &eol = "\) const
void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Private Types

using parent_t = DataNode_Interface<VAL_TYPE, typename FormatDataMods<MODS...>::sorted>
template<typename VAL_TYPE, typename MOD_PACK>
class DataNode_Interface
template<typename VAL_TYPE, int... IMODS>
class DataNode_Interface<VAL_TYPE, ValPack<IMODS...>> : public emp::DataNodeModule<VAL_TYPE, (emp::data)IMODS...>
#include <DataNode.hpp>

Outermost interface to all DataNode modules.

Private Types

using parent_t = DataNodeModule<VAL_TYPE, (emp::data)IMODS...>
template<typename VAL_TYPE, emp::data... MODS>
class DataNodeModule
#include <DataNode.hpp>

Generic form of DataNodeModule (should never be used; trigger error!)

Public Functions

DataNodeModule()
template<typename VAL_TYPE>
class DataNodeModule<VAL_TYPE>
#include <DataNode.hpp>

Base form of DataNodeModule (available in ALL data nodes.)

Public Types

using value_t = VAL_TYPE

Public Functions

DataNodeModule()
size_t GetCount() const

Return the number of values that have been added to this node since the last reset.

size_t GetResetCount() const

If reset count not tracked, always return 0. If any modifier causes history to be saved, it will override this function and indicate how much history is stored.

double GetTotal() const
double GetMean() const
double GetMin() const
double GetMax() const
double GetVariance() const
double GetStandardDeviation() const
double GetSkew() const
double GetKurtosis() const
double GetMedian() const

Calculate the median of observed values.

double GetPercentile(const double pct) const

Calculate a percentile of observed values.

const std::string &GetName() const
const std::string &GetDescription() const
const std::string &GetKeyword() const
void SetName(const std::string&)
void SetDescription(const std::string&)
void SetKeyword(const std::string&)
void SetInfo(const std::string&, const std::string &_d = "", const std::string &_k = "")
void AddDatum(const VAL_TYPE &val)
void Reset()
void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Functions

void PullData_impl()

Protected Attributes

size_t val_count

How many values have been loaded?

emp::vector<VAL_TYPE> in_vals

What values are waiting to be included?

template<typename VAL_TYPE, emp::data... MODS> Archive, MODS... > : public emp::DataNodeModule< VAL_TYPE, MODS... >
#include <DataNode.hpp>

== data::Archive == This module keeps track of historical values in addition to those added since the last re-set. Every time Reset() is called, all values that have been added since the previous time Reset() are stored in a vector in the archive.

Public Functions

DataNodeModule()
const auto &GetArchive() const

Get all data ever added to this DataNode. Returns a vector of vectors; each vector contains all data from a single time point (interval between resets)

const emp::vector<VAL_TYPE> &GetData(size_t update) const

Get a vector of all data that was added during the.

Parameters
  • update: ‘th interval between resets.

const emp::vector<VAL_TYPE> &GetData() const

Get a vector of all data that has been added since the last reset.

size_t GetResetCount() const

Get the number of time intervals recorded in this DataNode. Note that this is one more than the number of times it has been reset

void Reset()

Reset this DataNode, starting a new grouping of values in the archive. Resetting is useful for tracking data from different time points, such as per update or generation.

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Archive, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

emp::vector<emp::vector<VAL_TYPE>> archive

Data archived from before most recent reset.

template<typename VAL_TYPE, emp::data... MODS> Current, MODS... > : public emp::DataNodeModule< VAL_TYPE, MODS... >
#include <DataNode.hpp>

== data::Current == This module lets you track the current (i.e. most recently added) value

Public Functions

DataNodeModule()
const VAL_TYPE &GetCurrent() const

Return the current (most recently added) value.

void AddDatum(const VAL_TYPE &val)

Add.

Parameters

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Current, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

VAL_TYPE cur_val

Most recent value passed to this node.

template<typename VAL_TYPE, emp::data... MODS> FullRange, MODS... > : public emp::DataNodeModule< VAL_TYPE, MODS... >
#include <DataNode.hpp>

== data::FullRange == This module makes the DataNode store a history of distributional information measured by data::Range between calls to Reset(). Series of historical values are stored in vectors (except mean, which is calculated from total and count).

Public Functions

DataNodeModule()
double GetTotal() const

Get the sum of all values added to this DataNode since the last reset.

double GetMean() const

Get the mean of all values added to this DataNode since the last reset.

double GetMin() const

Get the minimum of all values added to this DataNode since the last reset.

double GetMax() const

Get the maximum of all values added to this DataNode since the last reset.

double GetTotal(size_t update) const

Get the sum of all values added to this DataNode during the.

Parameters
  • update: specified.

double GetMean(size_t update) const

Get the mean of all values added to this DataNode during the.

Parameters
  • update: specified.

double GetMin(size_t update) const

Get the minimum of all values added to this DataNode during the.

Parameters
  • update: specified.

double GetMax(size_t update) const

Get the maximum of all values added to this DataNode during the.

Parameters
  • update: specified.

size_t GetResetCount() const

Get the number of time intervals recorded in this DataNode. Note that this is one more than the number of times it has been reset

void Reset()

Store the current range statistics in the archive and reset for a new interval.

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::FullRange, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

emp::vector<double> total_vals

Totals from previous resets.

emp::vector<size_t> num_vals

Value counts from previous resets.

emp::vector<double> min_vals

Minimums from previous resets.

emp::vector<double> max_vals

Maximums from previous resets.

template<typename VAL_TYPE, emp::data... MODS> Histogram, MODS... > : public emp::DataNodeModule< VAL_TYPE, MODS... >
#include <DataNode.hpp>

== data::Histogram == Make the DataNode track a histogram of values observed since the last reset.

Public Functions

DataNodeModule()
VAL_TYPE GetHistMin() const

Returns the minimum value this histogram is capable of containing (i.e. the minimum value for the first bin)

VAL_TYPE GetHistMax() const

Returns the maximum value this histogram is capable of containing (i.e. the maximum value for the last bin)

size_t GetHistCount(size_t bin_id) const

Return the count of items in the.

Parameters
  • bin_id: ‘th bin of the histogram

double GetHistWidth(size_t bin_id) const

Return the width of the.

Parameters
  • bin_id: ‘th bin of the histogram

const emp::vector<size_t> &GetHistCounts() const

Return a vector containing the count of items in each bin of the histogram.

int GetOverflow() const

Return the count of numbers added to this histogram that were above the upper bound on the histogram

int GetUnderflow() const

Return the count of numbers added to this histogram that were belowed the allowed lower bound

emp::vector<double> GetBinMins() const

Return a vector containing the lowest value allowed in each bin.

void SetupBins(VAL_TYPE _min, VAL_TYPE _max, size_t num_bins)

Sets up the ranges of values that go in each bin of the histogram.

Parameters
  • _min: - the lowest value allowed in the histogram

  • _max: - the largest value allowed in the histogram

  • num_bins: - The number of bins the histogram should have. The distance between min and max will be easily divided among this many bins.

void AddDatum(const VAL_TYPE &val)

Add.

Parameters

void Reset()

Reset the DataNode (empties the historgram)

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Histogram, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

VAL_TYPE offset

Min value in first bin; others are offset by this much.

VAL_TYPE width

How wide is the overall histogram?

IndexMap bins

Map of values to which bin they fall in.

emp::vector<size_t> counts

Counts in each bin.

size_t overflow
size_t underflow
template<typename VAL_TYPE, emp::data... MODS> Info, MODS... > : public emp::DataNodeModule< VAL_TYPE, MODS... >
#include <DataNode.hpp>

== data::Info == This module adds information such as a name, description, and keyword for this node.

Public Functions

DataNodeModule()
const std::string &GetName() const

Get this DataNode’s name.

const std::string &GetDescription() const

Get this DataNode’s description.

const std::string &GetKeyword() const

Get this DataNode’s keyword.

void SetName(const std::string &_in)

Set this DataNode’s name to specified value.

void SetDescription(const std::string &_in)

Set this DataNode’s description to specified value.

void SetKeyword(const std::string &_in)

Set this DataNode’s keyword to specified value.

void SetInfo(const std::string &_n, const std::string &_d = "", const std::string &_k = "")

Set this DataNode’s information

Parameters
  • _n: value to set name to

  • _d: value to set description to

  • _k: value to set keyword to

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using parent_t = DataNodeModule<VAL_TYPE, MODS...>

Protected Attributes

std::string name

Name of this data category.

std::string desc

Description of this type of data.

std::string keyword

Short keyword.

template<typename VAL_TYPE, emp::data... MODS> Log, MODS... > : public emp::DataNodeModule< VAL_TYPE, MODS... >
#include <DataNode.hpp>

== data::Log == This module lets you log all of the values that have been added since the last re-set

Public Functions

DataNodeModule()
const emp::vector<VAL_TYPE> &GetData() const

Get a vector of all data added since the last reset.

double GetMedian() const

Calculate the median of observed values.

double GetPercentile(const double pct) const

Calculate a percentile of observed values.

void AddDatum(const VAL_TYPE &val)

Add.

Parameters

void Reset()

Reset this DataNode (clear the current log of data)

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Log, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

emp::vector<VAL_TYPE> val_set

All values saved since last reset.

template<typename VAL_TYPE, emp::data... MODS> Pull, MODS... > : public emp::DataNodeModule< VAL_TYPE, MODS... >
#include <DataNode.hpp>

== data::Pull == This module makes it possible to give the DataNode a function that it can call to calculate new values or sets of values that it will then track. These functions are called every time the PullData method is called on this node, and the values they return are measured as specified by the other modules in this node.

Public Functions

DataNodeModule()
void AddPull(const std::function<VAL_TYPE()> &fun)
void AddPullSet(const std::function<emp::vector<VAL_TYPE>()> &fun)
void PrintDebug(std::ostream &os = std::cout)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Pull, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Functions

void PullData_impl()

Protected Attributes

emp::FunctionSet<VAL_TYPE()> pull_funs

Functions to pull data.

emp::FunctionSet< emp::vector< VAL_TYPE >)> pull_set_funs

Functions to pull sets of data.

template<typename VAL_TYPE, emp::data... MODS> Range, MODS... > : public emp::DataNodeModule< VAL_TYPE, MODS... >
#include <DataNode.hpp>

== data::Range == This module allows this DataNode to store information (min, max, mean, count, and total) about the distribution of the values that have been added since the last call to Reset().

Public Functions

DataNodeModule()
double GetTotal() const

Get the sum of all values added to this DataNode since the last reset.

double GetMean() const

Get the mean of all values added to this DataNode since the last reset.

double GetMin() const

Get the min of all values added to this DataNode since the last reset.

double GetMax() const

Get the max of all values added to this DataNode since the last reset.

void AddDatum(const VAL_TYPE &val)

Add.

Parameters

void Reset()

Reset DataNode, setting the running calculations of total, min, mean, and max to 0.

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Range, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

double total

Total of all data since last reset.

double min

Smallest value passed in since last reset.

double max

Largest value passed in since last reset.

template<typename VAL_TYPE, emp::data... MODS> Stats, MODS... > : public emp::DataNodeModule< VAL_TYPE, MODS... >
#include <DataNode.hpp>

== data::Stats == Note: These statistics are calculated with the assumption that the data this node has received is the entire population of measurements we’re interested in, not a sample.

Note 2: Kurtosis is calculated using Snedecor and Cochran (1967)’s formula. A perfect normal distribution has a kurtosis of 0.

Public Functions

DataNodeModule()
double GetVariance() const

Get the variance (squared deviation from the mean) of values added since the last reset.

double GetStandardDeviation() const

Get the standard deviation of values added since the last reset.

double GetSkew() const

Get the skewness of values added since the last reset. This measurement tells you about the shape of the distribution. For a unimodal distribution, negative skew means that the distribution has a longer/thicker tail to the left. Positive skew means that ths distribution has a longer/thicker tail to the right.

double GetKurtosis() const

Get the kurtosis of the values added since the last reset. This is another measurement that describes the shape of the distribution. High kurtosis means that there is more data in the tails of the distribution (i.e. the tails are “heavier”), whereas low kurtosis means that there is less data in the tails. We use Snedecor and Cochran (1967)’s formula to calculate kurtosis. Under this formula, a normal distribution has kurtosis of 0.

void AddDatum(const VAL_TYPE &val)

Add.

Parameters

void Reset()

Reset this node (resets current stats to 0)

void PrintDebug(std::ostream &os = std::cout)

Print debug information (useful for figuring out which modifiers you included)

Protected Types

using this_t = DataNodeModule<VAL_TYPE, data::Stats, MODS...>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
using base_t = DataNodeModule<VAL_TYPE>

Protected Attributes

double M2

The second moment of the distribution.

double M3

The third moment of the distribution.

double M4

The fourth moment of the distribution.

template<emp::data... MODS>
struct FormatDataMods
#include <DataNode.hpp>

A template that will determing requisites, sort, make unique the data mods provided. The final, sorted ValPack of the requisites plus originals is in ‘sorted’.

Public Types

using reqs = typename DataModuleRequisiteAdd<MODS...>::type

Identify requisites.

using full = typename ModPack<MODS...>::template append<reqs>

Requisites + originals.

using sorted = pack::RUsort<full>

Unique and in order.

DataManagers

DataManager handles a set of DataNode objects with the same tracking settings.

Note

This file is part of Empirical, https://github.com/devosoft/Empirical

Copyright

Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md

Date

2017-2018

namespace emp

If we are in emscripten, make sure to include the header.

template<typename VAL_TYPE, emp::data... MODS>
class DataManager
#include <DataManager.hpp>

DataManagers handle sets of DataNode objects that all have the same tracking settings.

Public Functions

DataManager()
~DataManager()
auto begin() -> decltype(std::begin(node_map))
auto end() -> decltype(std::end(node_map))
auto begin() const -> const decltype(std::begin(node_map))
auto end() const -> const decltype(std::end(node_map))
size_t GetSize() const

Return

the number of DataNodes in this DataManager

auto &GetNodes() const

Return

the std::map mapping node names (strings) to DataNodes

bool HasNode(const std::string &name)
node_t &New(const std::string &name)

Creates and adds a new DataNode

Parameters

void Delete(const std::string &name)

Deletes the DataNode with the specified name. Throws an error if there is no node with that name in this manager.

Parameters
  • name: the name of the DataNode to delete

const node_t &Get(const std::string &name) const

Return

a const reference to the DataNode with the specified name Throws an error if there is no node with that name in this manager

Parameters

node_t &Get(const std::string &name)

Return

a reference to the node with the specified name Throws an error if there is no node with that name in this manager

Parameters

template<typename ...Ts>
void AddData(const std::string &name, Ts... extra)

Adds data to a node in the DataManager.

Example:

DataManager<int, data::Current, data::Range> my_data_manager;
my_data_manager.Add("my_node_name");
my_data_manager.AddData("my_node_name", 1, 2, 3, 4, 5);
Parameters
  • name: the node to add the data to.

  • extra: All subsequent arguments are the data to add to that node, and should be of whatever type all of the nodes in this manger expect.

void ResetAll()

Resets all nodes in this manager. For nodes without the data::Archive attribute, this clears all of their data except current. For nodes with the data::Archive attribute, this creates a new vector to start storing data, retaining the old one in the archive.

Private Types

using data_t = VAL_TYPE
using node_t = DataNode<data_t, MODS...>

Private Members

std::map<std::string, node_t*> node_map

DataInterfaces

DataInterface is a generic interface to a DataNode.

Note

This file is part of Empirical, https://github.com/devosoft/Empirical

Copyright

Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md

Date

2016-2018

namespace emp

If we are in emscripten, make sure to include the header.

Functions

template<typename VAL_TYPE, emp::data... EXTRA>
DataInterface *MakeDataInterface()
class DataInterface
#include <DataInterface.hpp>

A generic interface to a DataNode (so that you don’t need to know the node’s exact type)

Subclassed by emp::DataInterface_Impl< VAL_TYPE, EXTRA >

Public Functions

~DataInterface()
size_t GetCount() const = 0
size_t GetResetCount() const = 0
double GetTotal() const = 0
double GetMean() const = 0
double GetMin() const = 0
double GetMax() const = 0
double GetVariance() const = 0
double GetStandardDeviation() const = 0
double GetSkew() const = 0
double GetKurtosis() const = 0
void PullData() = 0
void Reset() = 0
void PrintDebug(std::ostream &os = std::cout) = 0
void GetName() = 0
void GetDescription() = 0
void GetKeyword() = 0
template<typename VAL_TYPE, emp::data... EXTRA>
class DataInterface_Impl : public emp::DataInterface

Public Types

using node_t = DataNode<VAL_TYPE, EXTRA...>

Public Functions

DataInterface_Impl()
DataInterface_Impl(node_t *n)
DataInterface_Impl(const DataInterface_Impl&) = delete
DataInterface_Impl(DataInterface_Impl&&) = delete
~DataInterface_Impl()
DataInterface_Impl &operator=(const DataInterface_Impl&) = delete
DataInterface_Impl &operator=(DataInterface_Impl&&) = delete
size_t GetCount() const

Returns the number values added to this node since the last reset.

size_t GetResetCount() const

Returns the number of times this node has been reset.

double GetTotal() const

Returns the sum of values added since the last reset. Requires that the data::Range or data::FullRange be added to the DataNode

double GetMean() const

Returns the mean of the values added since the last reset. Requires that the data::Range or data::FullRange be added to the DataNode

double GetMin() const

Returns the minimum of the values added since the last reset. Requires that the data::Range or data::FullRange be added to the DataNode

double GetMax() const

Returns the maximum of the values added since the last reset. Requires that the data::Range or data::FullRange be added to the DataNode

double GetVariance() const

Returns the variance of the values added since the last reset. Requires that the data::Stats or data::FullStats be added to the DataNode

double GetStandardDeviation() const

Returns the standard deviation of the values added since the last reset. Requires that the data::Stats or data::FullStats be added to the DataNode

double GetSkew() const

Returns the skewness of the values added since the last reset. Requires that the data::Stats or data::FullStats be added to the DataNode

double GetKurtosis() const

Returns the kurtosis of the values added since the last reset. Requires that the data::Stats or data::FullStats be added to the DataNode

void PullData()

Runs the Pull function for this DataNode and records the resulting values. Requires that the data::Pull module was added to this DataNode, and that a pull function was specified.

void Reset()

Reset this node. The exact effects of this depend on the modules that this node has, but in general it prepares the node to receive a new set of data.

void PrintDebug(std::ostream &os = std::cout)

Print debug information about this node to

Parameters
  • os: Useful for tracking which modifiers are included.

void GetName()

Returns this node’s name. Requires that the data::Info module was added to this DataNode, and that a name was set.

void GetDescription()

Returns this node’s description. Requires that the data::Info module was added to this DataNode, and that a description was set.

void GetKeyword()

Returns this node’s keyword. Requires that the data::Info module was added to this DataNode, and that a keyword was set.

Private Members

node_t *node
bool owner

DataFiles

DataFile objects use DataNode objects to dynamically fill out file contents.

Note

This file is part of Empirical, https://github.com/devosoft/Empirical

Copyright

Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md

Date

2016-2018

namespace emp

If we are in emscripten, make sure to include the header.

Functions

template<typename CONTAINER>
ContainerDataFile<CONTAINER> MakeContainerDataFile(std::function<CONTAINER(void)> fun, const std::string &filename, const std::string &b = "", const std::string &s = ",", const std::string &e = "\, )

Convenience function for building a container data file.

Parameters
  • fun: is the function to call to update the container

  • filename: is the name of the file to output to

  • b: character to print at the beggininning of each line

  • s: delimeter (i.e. what character to print between entries on each line)

  • e: character to print at the end of each line

template<typename CONTAINER>
class ContainerDataFile : public emp::DataFile
#include <DataFile.hpp>

Sometimes you may want a data file where a set of functions is run on every item in a container every time you write to the file. ContainerDataFiles do that.

Note: CONTAINER type can be a pointer to a container and the datafile will handle dereferencing it appropriately.

Public Functions

template<typename ...ARGS>
ContainerDataFile(ARGS&&... arguments)
~ContainerDataFile()
void SetUpdateContainerFun(const fun_update_container_t fun)

Tell this file what function to run to update the contents of the container that data is being calculated on.

void PrintHeaderKeys() override

Print a header containing the name of each column.

void PrintHeaderComment(const std::string &cstart = "# ") override

Print a header containing comments describing all of the columns.

const container_t GetCurrentRows() const
void OutputLine(const data_t d)
void Update() override

Run all of the functions and print the results as a new line in the file.

void Update(size_t update) override

Update the file with an additional set of lines.

size_t Add(const std::function<void(std::ostream&, data_t)> &fun, const std::string &key, const std::string &desc, )

If a function takes an ostream, pass in the correct one. Generic function for adding a column to the DataFile. In practice, you probably want to call one of the more specific ones.

template<typename T>
size_t AddContainerFun(const std::function<T(const data_t)> &fun, const std::string &key = "", const std::string &desc = "", )

Add a function that returns a value to be printed to the file.

Protected Types

using container_t = typename std::remove_reference<CONTAINER>::type
using raw_container_t = typename remove_ptr_type<container_t>::type
using data_t = typename raw_container_t::value_type
using container_fun_t = void(std::ostream&, data_t)
using fun_update_container_t = std::function<container_t(void)>

Protected Attributes

fun_update_container_t update_container_fun
container_t current_rows
FunctionSet<container_fun_t> container_funs
emp::vector<std::string> container_keys
emp::vector<std::string> container_descs
class DataFile
#include <DataFile.hpp>

Keep track of everything associated with periodically printing data to a file. Maintain a set of functions for calculating the desired measurements at each point in time that they are required. It also handles the formating of the file.

Subclassed by emp::ContainerDataFile< logbuffer_t >, emp::ContainerDataFile< CONTAINER >

Public Functions

DataFile(const std::string &in_filename, const std::string &b = "", const std::string &s = ",", const std::string &e = "\)
DataFile(std::ostream &in_os, const std::string &b = "", const std::string &s = ",", const std::string &e = "\)
DataFile(const DataFile&) = default
DataFile(DataFile&&) = default
~DataFile()
DataFile &operator=(const DataFile&) = default
DataFile &operator=(DataFile&&) = default
const std::string &GetFilename() const

Get the filename used for this file.

const std::string &GetLineBegin() const

Returns the string that is printed at the beginning of each line.

const std::string &GetSpacer() const

Returns the string that is printed between elements on each line (i.e. the delimeter).

const std::string &GetLineEnd() const

Returns the string that is printed at the end of each line.

void SetTiming(time_fun_t fun)

Provide a timing function with a bool(size_t update) signature. The timing function is called with the update, and returns a bool to indicate if files should print this update.

void SetTimingOnce(size_t print_time)

Setup this file to print only once, at the specified update. Note that this timing function can be replaced at any time, even after being triggered.

void SetTimingRepeat(size_t step)

Setup this file to print every ‘step’ updates.

void SetTimingRange(size_t first, size_t step, size_t last)

Setup this file to print only in a specified time range, and a given frequency (step).

void SetLineBegin(const std::string &_in)

Print a string at the beginning of each line.

Parameters
  • _in: the string to print

void SetSpacer(const std::string &_in)

Print a string between elements.

Parameters
  • _in: the string (i.e. the delimeter).

void SetLineEnd(const std::string &_in)

Print a string at the end of each line.

Parameters
  • _in: the string to print

void SetupLine(const std::string &b, const std::string &s, const std::string &e)

Set line begin, delimeter, and line end characters.

Parameters
  • b: line-begin character.

  • s: column delimeter

  • e: line end character

void PrintHeaderKeys()

Print a header containing the name of each column.

void PrintHeaderComment(const std::string &cstart = "# ")

Print a header containing comments describing all of the columns.

void Update()

Run all of the functions and print the results as a new line in the file.

void Update(size_t update)

If Update is called with an update number, the full version of update is called only if the update value passes the timing function (that is, the timing function returns true).

Parameters
  • update: the current time step

void AddPreFun(pre_fun_t fun)

Add a function to run before each time data is calculated. You can add as many functions as you want.

Parameters
  • fun: the function to add

size_t Add(const std::function<void(std::ostream&)> &fun, const std::string &key, const std::string &desc, )

Generic function for adding a column to the DataFile. In practice, you probably want to call one of the more specific ones.

Parameters
  • fun: function to call to get the value to print

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

template<typename T>
size_t AddFun(const std::function<T()> &funconst std::string &key = "", const std::string &desc = "", )

Add a function that returns a value to be printed to the file.

Parameters
  • fun: function to call to get the value to print

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

template<typename T>
size_t AddVar(const T &var, const std::string &key = "", const std::string &desc = "")

Add a function that always prints the current value of var.

Parameters
  • var: variable to print value of

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

template<typename VAL_TYPE, emp::data... MODS>
size_t AddCurrent(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the current value from the DataNode node. Requires that node have the data::Current modifier.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
size_t AddMean(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the mean value from the DataNode node. Requires that node have the data::Range or data::FullRange modifier.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated? template <typename VAL_TYPE, emp::data… MODS>

template<typename VAL_TYPE, emp::data... MODS>
size_t AddMedian(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the median value from the DataNode node. Requires that node have the data::Range or data::FullRange modifier.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
size_t AddPercentile(DataNode<VAL_TYPE, MODS...> &node, const double pct = 100.0, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the Percentile value from the DataNode node. Requires that node have the data::Range or data::FullRange modifier.

Parameters
  • node: DataNode to get data from

  • pct: the percentile value to return

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
size_t AddTotal(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the total value from the DataNode node. Requires that node have the data::Range or data::FullRange modifier.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
size_t AddMin(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the minimum value from the DataNode node. Requires that node have the data::Range or data::FullRange modifier.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
size_t AddMax(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the maximum value from the DataNode node. Requires that node have the data::Range or data::FullRange modifier.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
size_t AddVariance(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the variance from the DataNode node Requires that node have the data::Stats or data::FullStats modifier.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
size_t AddStandardDeviation(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the standard deviation from the DataNode node Requires that node have the data::Stats or data::FullStats modifier.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
size_t AddSkew(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the skewness from the DataNode node Requires that node have the data::Stats or data::FullStats modifier.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
size_t AddKurtosis(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the kurtosis from the DataNode node Requires that node have the data::Stats or data::FullStats modifier.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
void AddStats(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add multiple functions that pull common stats measurements (mean, variance, min, and max) from the DataNode node. Requires that node have the data::Stats or data::FullStats modifier. key and desc will have the name of the stat appended to the beginning. Note: excludes standard deviation, because it is easily calculated from variance Note: Setting pull and/or reset to true only pulls on first statistic calculated and only resets on the last. Otherwise there would be a risk of data loss or at least massive replication of computational effort. Even still, think carefully before setting either of these to true when you’re drawing varied information from the same node.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
void AddAllStats(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add multiple functions that pull all stats measurements (mean, variance, min, max, skew, and kurtosis) from the DataNode node Requires that node have the data::Stats or data::FullStats modifier. key and desc will have the name of the stat appended to the beginning. Note: excludes standard deviation, because it is easily calculated from variance Note: Setting pull and/or reset to true only pulls on first statistic calculated and only resets on the last. Otherwise there would be a risk of data loss or at least massive replication of computational effort. Even still, think carefully before setting either of these to true when you’re drawing varied information from the same node.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
size_t AddHistBin(DataNode<VAL_TYPE, MODS...> &node, size_t bin_id, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the count of the bin_id ‘th bin of the histogram from node. Requires that node have the data::Histogram modifier and at least bin_id bins.

Parameters
  • node: DataNode to get data from

  • bin_id: id of bin to log data from (0-indexed)

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
void AddAllHistBins(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a set of functions that always pull the count of each bin of the histogram from node. Requires that node have the data::Histogram modifier. Note: Setting pull and/or reset to true only pulls on first statistic calculated and only resets on the last. Otherwise there would be a risk of data loss or at least massive replication of computational effort. Even still, think carefully before setting either of these to true when you’re drawing varied information from the same node.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

template<typename VAL_TYPE, emp::data... MODS>
size_t AddInferiority(DataNode<VAL_TYPE, MODS...> &node, const std::string &key = "", const std::string &desc = "", const bool &reset = false, const bool &pull = false)

Add a function that always pulls the inferiority (mean divided by max) from the specified DataNode. Requires that node have the data::Range or data::FullRange modifier.

Parameters
  • node: DataNode to get data from

  • key: Keyword associated with this column (gets used as a column name for this data)

  • desc: Full description of this data (used by PrintHeaderComment)

  • reset: If this parameter is set true, we will call Reset on that DataNode after pulling the current value from the node

  • pull: Should the node pull data before this statistic is calculated?

Protected Types

using fun_t = void(std::ostream&)
using time_fun_t = std::function<bool(size_t)>
using pre_fun_t = std::function<void()>

Protected Attributes

std::string filename

Name of the file that we are printing to (if one exists)

std::ostream *os

Stream to print to.

FunctionSet<fun_t> funs

Set of functions to call, one per column in the file.

FunctionSet<void()> pre_funs

Set of functions to call before calculating data.

emp::vector<std::string> keys

Keywords associated with each column.

emp::vector<std::string> descs

Full description for each column.

time_fun_t timing_fun

Function to determine updates to print on (default: all)

std::string line_begin

What should we print at the start of each line?

std::string line_spacer

What should we print between entries?

std::string line_end

What should we print at the end of each line?