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 statisticcs 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 <>
template<>
struct DataModInfo<data::Archive>
#include <DataNode.h>

Public Types

template<>
using reqs = ModPack<data::Log>
template <>
template<>
struct DataModInfo<data::FullRange>
#include <DataNode.h>

Public Types

template<>
using reqs = ModPack<data::Range>
template <>
template<>
struct DataModInfo<data::Stats>
#include <DataNode.h>

Public Types

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

== 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Current, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Info, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== 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.

Parameters
  • _in:

void SetDescription(const std::string &_in)

Set this DataNode’s description to.

Parameters
  • _in:

void SetKeyword(const std::string &_in)

Set this DataNode’s keyword to.

Parameters
  • _in:

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

Set this DataNode’s name to.

Parameters
  • _ndescription: to
  • _dand: keyword to
  • _k:

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

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

Protected Types

template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Log, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== 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.

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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Log, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Archive, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Archive, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Range, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== 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 calucluations 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Range, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::FullRange, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== data::FullRange == This module makes the DataNode store a history of distributional information measured by data::Range beteen 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::FullRange, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Stats, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== data::Stats == Note: These statistics are calculated with the assumption that the data this node has recieved 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Stats, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Histogram, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== 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.

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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Histogram, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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.

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

== 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Pull, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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.

This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.

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
2018

This file contains functions for adding additional data files to Worlds.

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
2018

Typedefs

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

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

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

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

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

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

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

A node that stores all data it recieves in an archive (vector of vectors). The inner vectors are groups of data that were recieved 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:

Current

Track most recent value.

Info

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

Log

Track all values since last Reset()

Archive

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

Range

Track min, max, mean, total.

FullRange

Track Range data over time.

Histogram

Keep a full histogram.

Stats

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

Pull

Enable data collection on request.

Various signals are possible:

SignalReset

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

SignalData

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

SignalDatum

Include a signal when each datum is added.

SignalRange

Include a signal for data in a range.

SignalLimits

Include a signal for data OUTSIDE a range.

UNKNOWN

Unknown modifier; will trigger error.

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

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

Public Types

template<>
using reqs = ModPack<>
template <>
template<>
struct DataModInfo<data::Archive>
#include <DataNode.h>

Public Types

template<>
using reqs = ModPack<data::Log>
template <>
template<>
struct DataModInfo<data::FullRange>
#include <DataNode.h>

Public Types

template<>
using reqs = ModPack<data::Range>
template <>
template<>
struct DataModInfo<data::Stats>
#include <DataNode.h>

Public Types

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

Public Types

template<>
using next_type = typename DataModuleRequisiteAdd<MODS...>::type
template<>
using this_req = typename DataModInfo<CUR_MOD>::reqs
using emp::DataModuleRequisiteAdd< CUR_MOD, MODS... >::type = typename next_type::template append<this_req>
template <>
template<>
struct DataModuleRequisiteAdd<>
#include <DataNode.h>

Public Types

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

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
void PrintDebug(std::ostream &os = std::cout)

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

Private Types

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

Outermost interface to all DataNode modules.

Private Types

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

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

Public Functions

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

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

Public Types

template<>
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
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>
template<>
class DataNodeModule<VAL_TYPE, data::Archive, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Archive, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Current, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Current, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::FullRange, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== data::FullRange == This module makes the DataNode store a history of distributional information measured by data::Range beteen 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::FullRange, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Histogram, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== 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.

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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Histogram, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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.

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

== 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.

Parameters
  • _in:

void SetDescription(const std::string &_in)

Set this DataNode’s description to.

Parameters
  • _in:

void SetKeyword(const std::string &_in)

Set this DataNode’s keyword to.

Parameters
  • _in:

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

Set this DataNode’s name to.

Parameters
  • _ndescription: to
  • _dand: keyword to
  • _k:

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

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

Protected Types

template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Log, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== 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.

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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Log, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Pull, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Pull, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Range, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== 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 calucluations 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Range, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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>
template<>
class DataNodeModule<VAL_TYPE, data::Stats, MODS...> : public emp::DataNodeModule<VAL_TYPE, MODS...>
#include <DataNode.h>

== data::Stats == Note: These statistics are calculated with the assumption that the data this node has recieved 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

template<>
using this_t = DataNodeModule<VAL_TYPE, data::Stats, MODS...>
template<>
using parent_t = DataNodeModule<VAL_TYPE, MODS...>
template<>
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.h>

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

Public Types

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

Identify requisites.

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

Requisites + originals.

template<>
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.

This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.

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
2018

This file contains functions for adding additional data files to Worlds.

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
2018

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

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

Public Functions

DataManager()
~DataManager()
size_t GetSize() const

Returns the number of DataNodes in this DataManager.

auto &GetNodes() const

Returns 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, with the name specified in.

Parameters
  • name.:

void Delete(const std::string &name)

Deletes the DataNode with the name

Parameters
  • name.: Throws an error if there is no node with that name in this manager.

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

Returns a const reference to the node named

Parameters
  • name.: Throws an error if there is no node with that name in this manager

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

Returns a reference to the node named

Parameters
  • name.: Throws an error if there is no node with that name in this manager

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

Adds data to a node in the DataManager. Example:

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

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);

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

template<>
using data_t = VAL_TYPE
template<>
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.

This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.

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
2018

This file contains functions for adding additional data files to Worlds.

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
2018

Functions

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

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

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

Public Types

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

Public Functions

DataInterface_Impl()
DataInterface_Impl(node_t *n)
DataInterface_Impl(const DataInterface_Impl&)
DataInterface_Impl(DataInterface_Impl&&)
~DataInterface_Impl()
DataInterface_Impl &operator=(const DataInterface_Impl&)
DataInterface_Impl &operator=(DataInterface_Impl&&)
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 recieve 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.

This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.

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
2018

This file contains functions for adding additional data files to Worlds.

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
2018

Functions

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

Convenience function for building a container data file.

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

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

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 derefeferencing it appropriately.

Public Functions

ContainerDataFile(const std::string &filename, const std::string &b = "", const std::string &s = ",")
~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()

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.

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

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

void Update(size_t update)

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.

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.

Parameters
  • _in: at the beginning of each line.

void SetSpacer(const std::string &_in)

Print.

Parameters
  • _in: between elements (i.e. make
  • _in: the delimeter).

void SetLineEnd(const std::string &_in)

Print.

Parameters
  • _in: at the end of each line.

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

Set line begin character (.

Parameters
  • b)column: delimeter (
  • s)and: line end character (
  • e):

size_t Add(const std::function<void(std::ostream&)> &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 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.

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.

Parameters
  • var.:

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

Parameters
  • node.: Requires that
  • node: have the data::Current modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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

Parameters
  • node.: Requires that
  • node: have the data::Range or data::FullRange modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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

Parameters
  • node.: Requires that
  • node: have the data::Range or data::FullRange modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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

Parameters
  • node.: Requires that
  • node: have the data::Range or data::FullRange modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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

Parameters
  • node.: Requires that
  • node: have the data::Range or data::FullRange modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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

Parameters
  • node: Requires that
  • node: have the data::Stats or data::FullStats modifier.

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

Parameters
  • node: Requires that
  • node: have the data::Stats or data::FullStats modifier.

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

Parameters
  • node: Requires that
  • node: have the data::Stats or data::FullStats modifier.

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

Parameters
  • node: Requires that
  • node: have the data::Stats or data::FullStats modifier.

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

Parameters
  • 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

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

Parameters
  • 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

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

Parameters
  • bin_id: ‘th bin of the histogram from
  • node.: Requires that
  • node: have the data::Histogram modifier and at least bins. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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 DataNode

Parameters
  • node.: Requires that
  • node: have the data::Range or data::FullRange modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

Protected Types

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

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
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.

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?

class DataFile
#include <DataFile.h>

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< CONTAINER >

Public Functions

DataFile(const std::string &in_filename, const std::string &b = "", const std::string &s = ",")
DataFile(std::ostream &in_os, const std::string &b = "", const std::string &s = ",")
DataFile(const DataFile&)
DataFile(DataFile&&)
virtual ~DataFile()
DataFile &operator=(const DataFile&)
DataFile &operator=(DataFile&&)
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.

Parameters
  • _in: at the beginning of each line.

void SetSpacer(const std::string &_in)

Print.

Parameters
  • _in: between elements (i.e. make
  • _in: the delimeter).

void SetLineEnd(const std::string &_in)

Print.

Parameters
  • _in: at the end of each line.

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

Set line begin character (.

Parameters
  • b)column: delimeter (
  • s)and: line end character (
  • e):

virtual void PrintHeaderKeys()

Print a header containing the name of each column.

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

Print a header containing comments describing all of the columns.

virtual void Update()

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

virtual void Update(size_t update)

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

size_t Add(const std::function<void(std::ostream&)> &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 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.

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.

Parameters
  • var.:

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

Parameters
  • node.: Requires that
  • node: have the data::Current modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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

Parameters
  • node.: Requires that
  • node: have the data::Range or data::FullRange modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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

Parameters
  • node.: Requires that
  • node: have the data::Range or data::FullRange modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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

Parameters
  • node.: Requires that
  • node: have the data::Range or data::FullRange modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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

Parameters
  • node.: Requires that
  • node: have the data::Range or data::FullRange modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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

Parameters
  • node: Requires that
  • node: have the data::Stats or data::FullStats modifier.

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

Parameters
  • node: Requires that
  • node: have the data::Stats or data::FullStats modifier.

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

Parameters
  • node: Requires that
  • node: have the data::Stats or data::FullStats modifier.

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

Parameters
  • node: Requires that
  • node: have the data::Stats or data::FullStats modifier.

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

Parameters
  • 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

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

Parameters
  • 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

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

Parameters
  • bin_id: ‘th bin of the histogram from
  • node.: Requires that
  • node: have the data::Histogram modifier and at least bins. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

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 DataNode

Parameters
  • node.: Requires that
  • node: have the data::Range or data::FullRange modifier. If
  • reset: is set true, we will call Reset on that DataNode after pulling the current value from the node

Protected Types

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

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.

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?

namespace internal
template <typename container_t>
struct update_impl
#include <DataFile.h>

Public Functions

void Update(ContainerDataFile<container_t> *df)
template <typename container_t>
template<>
struct update_impl<container_t *>
#include <DataFile.h>

Public Functions

void Update(ContainerDataFile<container_t *> *df)
template <typename container_t>
template<>
struct update_impl<Ptr<container_t>>
#include <DataFile.h>

Public Functions

void Update(ContainerDataFile<Ptr<container_t>> *df)