Empirical
DataNode.h
Go to the documentation of this file.
1 
24 #ifndef EMP_DATA_NODE_H
25 #define EMP_DATA_NODE_H
26 
27 #include "../base/vector.h"
28 #include "../base/assert.h"
29 #include "../meta/IntPack.h"
30 #include "../tools/FunctionSet.h"
31 #include "../tools/IndexMap.h"
32 #include "../tools/string_utils.h"
33 #include "../tools/math.h"
34 
35 namespace emp {
36 
38  enum class data {
39  Current,
40 
41  Info,
42 
43  Log,
44  Archive,
45 
46  Range,
47  FullRange,
48  Histogram,
49  Stats,
50  // FullStats, // Track States + ALL values over time (with purge/merge options)
51 
52  Pull,
53 
55  SignalReset,
56  SignalData,
57  SignalDatum,
58  SignalRange,
59  SignalLimits,
60 
61  UNKNOWN
62  };
63 
64 
66  template <emp::data... MODS> using ModPack = emp::IntPack<(int) MODS...>;
67 
70  template <emp::data MOD> struct DataModInfo { using reqs = ModPack<>; };
71  template <> struct DataModInfo<data::Archive> { using reqs = ModPack<data::Log>; };
72  template <> struct DataModInfo<data::FullRange> { using reqs = ModPack<data::Range>; };
73  template <> struct DataModInfo<data::Stats> { using reqs = ModPack<data::Range>; };
74  //template <> struct DataModInfo<data::FullStats> { using reqs = ModPack<data::Range, data::Stats>; };
75 
76 
77  // A set of structs to collect and merge data module requisites.
78  template <emp::data... MODS> struct DataModuleRequisiteAdd { };
79  template <> struct DataModuleRequisiteAdd<> { using type = IntPack<>; };
80  template <emp::data CUR_MOD, emp::data... MODS> struct DataModuleRequisiteAdd<CUR_MOD, MODS...> {
81  using next_type = typename DataModuleRequisiteAdd<MODS...>::type;
83  using type = typename next_type::template append<this_req>;
84  };
85 
86 
88  template <typename VAL_TYPE, emp::data... MODS> class DataNodeModule {
89  public:
90  DataNodeModule() { emp_assert(false, "Unknown module used in DataNode!"); }
91  };
92 
94  template <typename VAL_TYPE>
95  class DataNodeModule<VAL_TYPE> {
96  protected:
97  size_t val_count;
99 
100  void PullData_impl() { ; }
101 
102  public:
103  DataNodeModule() : val_count(0), in_vals() { ; }
104 
105  using value_t = VAL_TYPE;
106 
108  size_t GetCount() const { return val_count; }
109 
112  size_t GetResetCount() const { return 0; }
113 
114  double GetTotal() const {emp_assert(false, "Calculating total requires a DataNode with the Range or FullRange modifier"); return 0;}
115  double GetMean() const {emp_assert(false, "Calculating mean requires a DataNode with the Range or FullRange modifier"); return 0;}
116  double GetMin() const {emp_assert(false, "Calculating min requires a DataNode with the Range or FullRange modifier"); return 0;}
117  double GetMax() const {emp_assert(false, "Calculating max requires a DataNode with the Range or FullRange modifier"); return 0;}
118  double GetVariance() const {emp_assert(false, "Calculating variance requires a DataNode with the Stats or FullStats modifier"); return 0;}
119  double GetStandardDeviation() const {emp_assert(false, "Calculating standard deviation requires a DataNode with the Stats or FullStats modifier"); return 0;}
120  double GetSkew() const {emp_assert(false, "Calculating skew requires a DataNode with the Stats or FullStats modifier"); return 0;}
121  double GetKurtosis() const {emp_assert(false, "Calculating kurtosis requires a DataNode with the Stats or FullStats modifier"); return 0;}
122 
123  const std::string & GetName() const { return emp::empty_string(); }
124  const std::string & GetDescription() const { return emp::empty_string(); }
125  const std::string & GetKeyword() const { return emp::empty_string(); }
126 
127  void SetName(const std::string &) { emp_assert(false, "Invalid call for DataNode config."); }
128  void SetDescription(const std::string &) { emp_assert(false, "Invalid call for DataNode config."); }
129  void SetKeyword(const std::string &) { emp_assert(false, "Invalid call for DataNode config."); }
130 
131  void SetInfo(const std::string &, const std::string & _d="", const std::string & _k="") {
132  (void) _d; (void) _k;
133  emp_assert(false, "Invalid call for DataNode config.");
134  }
135 
136  void AddDatum(const VAL_TYPE & val) { val_count++; }
137 
138  void Reset() { val_count = 0; }
139 
141  void PrintDebug(std::ostream & os=std::cout) {
142  os << "BASE DataNodeModule.\n";
143  }
144  };
145 
146  // Specialized forms of DataNodeModule
147 
150  template <typename VAL_TYPE, emp::data... MODS>
151  class DataNodeModule<VAL_TYPE, data::Current, MODS...> : public DataNodeModule<VAL_TYPE, MODS...> {
152  protected:
153  VAL_TYPE cur_val;
154 
155  using this_t = DataNodeModule<VAL_TYPE, data::Current, MODS...>;
156  using parent_t = DataNodeModule<VAL_TYPE, MODS...>;
158 
159  public:
160  DataNodeModule() : cur_val() { ; }
161 
163  const VAL_TYPE & GetCurrent() const { return cur_val; }
164 
166  void AddDatum(const VAL_TYPE & val) { cur_val = val; parent_t::AddDatum(val); }
167 
169  void PrintDebug(std::ostream & os=std::cout) {
170  os << "DataNodeModule for data::Current. (level " << (int) data::Current << ")\n";
171  parent_t::PrintDebug(os);
172  }
173  };
174 
175 
178  template <typename VAL_TYPE, emp::data... MODS>
179  class DataNodeModule<VAL_TYPE, data::Info, MODS...> : public DataNodeModule<VAL_TYPE, MODS...> {
180  protected:
181  std::string name;
182  std::string desc;
183  std::string keyword;
184 
185  using parent_t = DataNodeModule<VAL_TYPE, MODS...>;
186  public:
187  DataNodeModule() : name(), desc(), keyword() { ; }
188 
190  const std::string & GetName() const { return name; }
192  const std::string & GetDescription() const { return desc; }
194  const std::string & GetKeyword() const { return keyword; }
195 
197  void SetName(const std::string & _in) { name = _in; }
199  void SetDescription(const std::string & _in) { desc = _in; }
201  void SetKeyword(const std::string & _in) { keyword = _in; }
202 
204  void SetInfo(const std::string & _n, const std::string & _d="", const std::string & _k="") {
205  name = _n; desc = _d; keyword = _k;
206  }
207 
209  void PrintDebug(std::ostream & os=std::cout) {
210  os << "DataNodeModule for data::Info. (level " << (int) data::Info << ")\n";
211  parent_t::PrintDebug(os);
212  }
213  };
214 
215 
218  template <typename VAL_TYPE, emp::data... MODS>
219  class DataNodeModule<VAL_TYPE, data::Log, MODS...> : public DataNodeModule<VAL_TYPE, MODS...> {
220  protected:
222 
223  using this_t = DataNodeModule<VAL_TYPE, data::Log, MODS...>;
224  using parent_t = DataNodeModule<VAL_TYPE, MODS...>;
226 
227  using base_t::val_count;
228  public:
229  DataNodeModule() : val_set() { ; }
230 
232  const emp::vector<VAL_TYPE> & GetData() const { return val_set; }
233 
235  void AddDatum(const VAL_TYPE & val) {
236  val_set.push_back(val);
237  parent_t::AddDatum(val);
238  }
239 
241  void Reset() {
242  val_set.resize(0);
243  parent_t::Reset();
244  }
245 
247  void PrintDebug(std::ostream & os=std::cout) {
248  os << "DataNodeModule for data::Log. (level " << (int) data::Log << ")\n";
249  parent_t::PrintDebug(os);
250  }
251  };
252 
257  template <typename VAL_TYPE, emp::data... MODS>
258  class DataNodeModule<VAL_TYPE, data::Archive, MODS...> : public DataNodeModule<VAL_TYPE, MODS...> {
259  protected:
261 
262  using this_t = DataNodeModule<VAL_TYPE, data::Archive, MODS...>;
263  using parent_t = DataNodeModule<VAL_TYPE, MODS...>;
265 
266  using base_t::val_count;
267  using parent_t::val_set;
268  public:
269  DataNodeModule() : archive(0) { ; }
270 
273  const auto & GetArchive() const { return archive; }
274 
276  const emp::vector<VAL_TYPE> & GetData(size_t update) const { return archive[update]; }
277 
279  const emp::vector<VAL_TYPE> & GetData() const { return val_set; }
280 
283  size_t GetResetCount() const { return archive.size(); }
284 
285  // NOTE: Ignoring AddDatum() since new value will be added to val_set.
286 
289  void Reset() {
290  archive.push_back(val_set);
291  parent_t::Reset();
292  }
293 
295  void PrintDebug(std::ostream & os=std::cout) {
296  os << "DataNodeModule for data::Archive. (level " << (int) data::Archive << ")\n";
297  parent_t::PrintDebug(os);
298  }
299  };
300 
304  template <typename VAL_TYPE, emp::data... MODS>
305  class DataNodeModule<VAL_TYPE, data::Range, MODS...> : public DataNodeModule<VAL_TYPE, MODS...> {
306  protected:
307  double total;
308  double min;
309  double max;
310 
311  using this_t = DataNodeModule<VAL_TYPE, data::Range, MODS...>;
312  using parent_t = DataNodeModule<VAL_TYPE, MODS...>;
314 
315  using base_t::val_count;
316  public:
317  DataNodeModule() : total(0.0), min(0), max(0) { ; }
318 
320  double GetTotal() const { return total; }
321 
323  double GetMean() const { return total / (double) base_t::val_count; }
324 
326  double GetMin() const { return min; }
327 
329  double GetMax() const { return max; }
330 
332  void AddDatum(const VAL_TYPE & val) {
333  total += (double) val;
334  if (!val_count || min > (double) val) min = (double) val;
335  if (!val_count || max < (double) val) max = (double) val;
336  parent_t::AddDatum(val);
337  }
338 
340  void Reset() {
341  total = 0.0;
342  min = 0.0;
343  max = 0.0;
344  parent_t::Reset();
345  }
346 
348  void PrintDebug(std::ostream & os=std::cout) {
349  os << "DataNodeModule for data::Range. (level " << (int) data::Range << ")\n";
350  parent_t::PrintDebug(os);
351  }
352  };
353 
358  template <typename VAL_TYPE, emp::data... MODS>
359  class DataNodeModule<VAL_TYPE, data::FullRange, MODS...> : public DataNodeModule<VAL_TYPE, MODS...> {
360  protected:
365 
366  using this_t = DataNodeModule<VAL_TYPE, data::FullRange, MODS...>;
367  using parent_t = DataNodeModule<VAL_TYPE, MODS...>;
369 
370  using base_t::val_count;
371  using parent_t::total;
372  using parent_t::min;
373  using parent_t::max;
374  public:
376  : total_vals(), num_vals(), min_vals(), max_vals() { ; }
377 
379  double GetTotal() const { return total; }
380 
382  double GetMean() const { return total / (double) val_count; }
383 
385  double GetMin() const { return min; }
386 
388  double GetMax() const { return max; }
389 
391  double GetTotal(size_t update) const { return total_vals[update]; }
392 
394  double GetMean(size_t update) const { return total_vals[update] / (double) num_vals[update]; }
395 
397  double GetMin(size_t update) const { return min_vals[update]; }
398 
400  double GetMax(size_t update) const { return max_vals[update]; }
401 
404  size_t GetResetCount() const { return total_vals.size(); }
405 
406  // NOTE: Ignoring AddDatum() since Range values track current information.
407 
409  void Reset() {
410  total_vals.push_back(total);
411  num_vals.push_back(val_count);
412  min_vals.push_back(min);
413  max_vals.push_back(max);
414  parent_t::Reset();
415  }
416 
418  void PrintDebug(std::ostream & os=std::cout) {
419  os << "DataNodeModule for data::FullRange. (level " << (int) data::FullRange << ")\n";
420  parent_t::PrintDebug(os);
421  }
422  };
423 
430 
431  template <typename VAL_TYPE, emp::data... MODS>
432  class DataNodeModule<VAL_TYPE, data::Stats, MODS...> : public DataNodeModule<VAL_TYPE, MODS...> {
433  protected:
434  // Running variance, skew, and kurtosis calculations based off of this class:
435  // https://www.johndcook.com/blog/skewness_kurtosis/
436 
437  // We don't need the mean (M1) because it's already being tracked
438  double M2;
439  double M3;
440  double M4;
441 
442  using this_t = DataNodeModule<VAL_TYPE, data::Stats, MODS...>;
443  using parent_t = DataNodeModule<VAL_TYPE, MODS...>;
445 
446  using base_t::val_count;
447  using parent_t::total;
448  using parent_t::min;
449  using parent_t::max;
450 
451  public:
452  DataNodeModule() : M2(0), M3(0), M4(0) { ; }
453 
454  using parent_t::GetMean;
455 
457  double GetVariance() const {return M2/(double)val_count;}
458 
460  double GetStandardDeviation() const {return sqrt(GetVariance());}
461 
466  double GetSkew() const {return sqrt(double(val_count)) * M3/ emp::Pow(M2, 1.5);}
467 
473  double GetKurtosis() const {return double(val_count)*M4 / (M2*M2) - 3.0;}
474 
476  void AddDatum(const VAL_TYPE & val) {
477  // Calculate deviation from mean (the ternary avoids dividing by
478  // 0 in the case where this is the first datum added since last reset)
479  const double n = (double) (val_count + 1);
480  const double delta = ((double) val) - (total/((val_count > 0) ? (double) val_count : 1.0));
481  const double delta_n = delta / n;
482  const double delta_n2 = delta_n * delta_n;
483  const double term1 = delta * delta_n * (double) val_count;
484 
485  M4 += term1 * delta_n2 * (n*n - 3.0*n + 3.0) + 6.0 * delta_n2 * M2 - 4.0 * delta_n * M3;
486  M3 += term1 * delta_n * (n - 2.0) - 3.0 * delta_n * M2;
487  M2 += term1;
488 
489  parent_t::AddDatum(val);
490  }
491 
493  void Reset() {
494  M2 = 0;
495  M3 = 0;
496  M4 = 0;
497  parent_t::Reset();
498  }
499 
501  void PrintDebug(std::ostream & os=std::cout) {
502  os << "DataNodeModule for data::Stats. (level " << (int) data::Stats << ")\n";
503  parent_t::PrintDebug(os);
504  }
505  };
506 
509  template <typename VAL_TYPE, emp::data... MODS>
510  class DataNodeModule<VAL_TYPE, data::Histogram, MODS...> : public DataNodeModule<VAL_TYPE, MODS...> {
511  protected:
512  VAL_TYPE offset;
513  VAL_TYPE width;
516 
517  using this_t = DataNodeModule<VAL_TYPE, data::Histogram, MODS...>;
518  using parent_t = DataNodeModule<VAL_TYPE, MODS...>;
520 
521  using base_t::val_count;
522 
523  public:
524  DataNodeModule() : offset(0.0), width(0), bins(), counts() { ; }
525 
528  VAL_TYPE GetHistMin() const { return offset; }
529 
532  VAL_TYPE GetHistMax() const { return offset + width; }
533 
535  size_t GetHistCount(size_t bin_id) const { return counts[bin_id]; }
536 
538  double GetHistWidth(size_t bin_id) const { return bins[bin_id]; } //width / (double) counts.size(); }
539 
541  const emp::vector<size_t> & GetHistCounts() const { return counts; }
542 
545  emp::vector<double> bin_mins(counts.size());
546  // double bin_width = width / (double) counts.size();
547  double cur_min = offset;
548  for (size_t i = 0; i < counts.size(); i++) {
549  bin_mins[i] = cur_min;
550  cur_min += bins[i]; // bin_width;
551  }
552  return bin_mins;
553  }
554 
560  void SetupBins(VAL_TYPE _min, VAL_TYPE _max, size_t num_bins) {
561  offset = _min;
562  width = _max - _min;
563  double bin_width = ((double) width) / (double) num_bins;
564  bins.Resize(num_bins);
565  bins.AdjustAll(bin_width);
566  counts.resize(num_bins);
567  for (size_t & x : counts) x = 0.0;
568  }
569 
571  void AddDatum(const VAL_TYPE & val) {
572  size_t bin_id = bins.Index((double) (val - offset));
573  // size_t bin_id = counts.size() * ((double) (val - offset)) / (double) width;
574  counts[bin_id]++;
575  parent_t::AddDatum(val);
576  }
577 
579  void Reset() {
580  for (size_t & x : counts) x = 0.0;
581  parent_t::Reset();
582  }
583 
585  void PrintDebug(std::ostream & os=std::cout) {
586  os << "DataNodeModule for data::Histogram. (level " << (int) data::FullRange << ")\n";
587  parent_t::PrintDebug(os);
588  }
589 
590  };
591 
597  template <typename VAL_TYPE, emp::data... MODS>
598  class DataNodeModule<VAL_TYPE, data::Pull, MODS...> : public DataNodeModule<VAL_TYPE, MODS...> {
599  protected:
602 
603  using this_t = DataNodeModule<VAL_TYPE, data::Pull, MODS...>;
604  using parent_t = DataNodeModule<VAL_TYPE, MODS...>;
606 
607  using base_t::in_vals;
608 
609  void PullData_impl() {
610  in_vals = pull_funs.Run();
611  const emp::vector< emp::vector<VAL_TYPE> > & pull_sets = pull_set_funs.Run();
612  for (const auto & x : pull_sets) {
613  in_vals.insert(in_vals.end(), x.begin(), x.end());
614  }
615  }
616 
617  public:
618  DataNodeModule() : pull_funs(), pull_set_funs() { ; }
619 
620  void AddPull(const std::function<VAL_TYPE()> & fun) { pull_funs.Add(fun); }
621  void AddPullSet(const std::function<emp::vector<VAL_TYPE>()> & fun) { pull_set_funs.Add(fun); }
622 
623  void PrintDebug(std::ostream & os=std::cout) {
624  os << "DataNodeModule for data::Pull. (level " << (int) data::Pull << ")\n";
625  parent_t::PrintDebug(os);
626  }
627  };
628 
629  template <typename VAL_TYPE, typename MOD_PACK> class DataNode_Interface;
630 
632  template <typename VAL_TYPE, int... IMODS>
633  class DataNode_Interface<VAL_TYPE, IntPack<IMODS...>>
634  : public DataNodeModule<VAL_TYPE, (emp::data) IMODS...> {
635  using parent_t = DataNodeModule<VAL_TYPE, (emp::data) IMODS...>;
636  };
637 
640  template<emp::data... MODS>
641  struct FormatDataMods {
642  using reqs = typename DataModuleRequisiteAdd<MODS...>::type;
643  using full = typename ModPack<MODS...>::template append<reqs>;
645  };
646 
647  template <typename VAL_TYPE, emp::data... MODS>
648  class DataNode : public DataNode_Interface< VAL_TYPE, typename FormatDataMods<MODS...>::sorted > {
649  private:
650  using parent_t = DataNode_Interface< VAL_TYPE, typename FormatDataMods<MODS...>::sorted >;
651  using parent_t::in_vals;
652 
653  public:
654 
655  inline void Add() { ; }
656 
658  template <typename... Ts>
659  inline void Add(const VAL_TYPE & val, const Ts &... extras) {
660  parent_t::AddDatum(val); Add(extras...);
661  }
662 
664  void PullData() {
665  parent_t::PullData_impl(); // Pull all data into in_vals.
666  for (const VAL_TYPE & val : in_vals) parent_t::AddDatum(val); // Actually add the data.
667  }
668 
670  void Reset() { parent_t::Reset(); }
671 
673  void PrintCurrent(std::ostream & os=std::cout) const { os << parent_t::GetCurrent(); }
674  void PrintLog(std::ostream & os=std::cout,
675  const std::string & spacer=", ",
676  const std::string & eol="\n") const {
677  const emp::vector<VAL_TYPE> & data = parent_t::GetData();
678  for (size_t i=0; i < data.size(); i++) {
679  if (i>0) os << spacer;
680  os << data[i];
681  }
682  os << eol;
683  }
684 
686  void PrintDebug(std::ostream & os=std::cout) {
687  os << "Main DataNode.\n";
688  parent_t::PrintDebug(os);
689  }
690  };
691 
692  // Shortcuts for common types of data nodes...
693 
697  template <typename T, emp::data... MODS>
699 
703  template <typename T, emp::data... MODS>
705 
711  template <typename T, emp::data... MODS>
713 }
714 
715 #endif
void SetName(const std::string &)
Definition: DataNode.h:127
static const std::string & empty_string()
Definition: string_utils.h:29
double GetMean() const
Get the mean of all values added to this DataNode since the last reset.
Definition: DataNode.h:323
Keep a full histogram.
double GetMean() const
Get the mean of all values added to this DataNode since the last reset.
Definition: DataNode.h:382
iterator insert(ARGS &&...args)
Definition: vector.h:201
double GetMean(size_t update) const
Get the mean of all values added to this DataNode during the.
Definition: DataNode.h:394
VAL_TYPE cur_val
Most recent value passed to this node.
Definition: DataNode.h:153
VAL_TYPE offset
Min value in first bin; others are offset by this much.
Definition: DataNode.h:512
void SetInfo(const std::string &_n, const std::string &_d="", const std::string &_k="")
Set this DataNode&#39;s name to.
Definition: DataNode.h:204
double GetMin() const
Definition: DataNode.h:116
Definition: DataNode.h:78
double GetMax() const
Get the maximum of all values added to this DataNode since the last reset.
Definition: DataNode.h:388
double GetTotal() const
Get the sum of all values added to this DataNode since the last reset.
Definition: DataNode.h:379
void SetInfo(const std::string &, const std::string &_d="", const std::string &_k="")
Definition: DataNode.h:131
const std::string & GetKeyword() const
Get this DataNode&#39;s keyword.
Definition: DataNode.h:194
void PrintDebug(std::ostream &os=std::cout)
Print debug information (useful for figuring out which modifiers you included)
Definition: DataNode.h:348
void PullData_impl()
Definition: DataNode.h:609
void SetDescription(const std::string &)
Definition: DataNode.h:128
typename DataModuleRequisiteAdd< MODS... >::type next_type
Definition: DataNode.h:81
Track all values since last Reset()
std::string name
Name of this data category.
Definition: DataNode.h:181
Definition: DataNode.h:629
void Resize(size_t new_size, double def_value=0.0)
Change the number of indecies in the map.
Definition: IndexMap.h:118
double GetKurtosis() const
Definition: DataNode.h:121
const std::string & GetName() const
Get this DataNode&#39;s name.
Definition: DataNode.h:190
void Reset()
Definition: DataNode.h:138
Definition: IntPack.h:26
size_t Index(double index, size_t cur_id=0) const
Determine the ID at the specified index position.
Definition: IndexMap.h:196
double GetTotal(size_t update) const
Get the sum of all values added to this DataNode during the.
Definition: DataNode.h:391
const std::string & GetDescription() const
Get this DataNode&#39;s description.
Definition: DataNode.h:192
std::string desc
Description of this type of data.
Definition: DataNode.h:182
double GetMax() const
Definition: DataNode.h:117
Include a signal when each datum is added.
typename ModPack< MODS... >::template append< reqs > full
Requisites + originals.
Definition: DataNode.h:643
Track Range data over time.
VAL_TYPE GetHistMin() const
Definition: DataNode.h:528
void PrintDebug(std::ostream &os=std::cout)
Print debug information (useful for figuring out which modifiers you included)
Definition: DataNode.h:141
const emp::vector< VAL_TYPE > & GetData() const
Get a vector of all data that has been added since the last reset.
Definition: DataNode.h:279
void AddDatum(const VAL_TYPE &val)
Add.
Definition: DataNode.h:476
Include information (name, keyword, description) for each instance.
double GetStandardDeviation() const
Get the standard deviation of values added since the last reset.
Definition: DataNode.h:460
double GetMin(size_t update) const
Get the minimum of all values added to this DataNode during the.
Definition: DataNode.h:397
const VAL_TYPE & GetCurrent() const
Return the current (most recently added) value.
Definition: DataNode.h:163
emp::vector< size_t > num_vals
Value counts from previous resets.
Definition: DataNode.h:362
Track most recent value.
void Reset()
Reset DataNode, setting the running calucluations of total, min, mean, and max to 0...
Definition: DataNode.h:340
void AddPullSet(const std::function< emp::vector< VAL_TYPE >()> &fun)
Definition: DataNode.h:621
void Reset()
Store the current range statistics in the archive and reset for a new interval.
Definition: DataNode.h:409
void SetupBins(VAL_TYPE _min, VAL_TYPE _max, size_t num_bins)
Definition: DataNode.h:560
const std::string & GetName() const
Definition: DataNode.h:123
emp::FunctionSet< VAL_TYPE()> pull_funs
Functions to pull data.
Definition: DataNode.h:600
void PrintDebug(std::ostream &os=std::cout)
Print debug information (useful for figuring out which modifiers you included)
Definition: DataNode.h:501
Unknown modifier; will trigger error.
A range of values from a lower limit to and upper limit, of any provided type.
Definition: Range.h:23
double max
Largest value passed in since last reset.
Definition: DataNode.h:309
Track Range + variance, standard deviation, skew, kertosis.
reverse< Usort< T > > RUsort
Definition: IntPack.h:196
void push_back(PB_Ts &&...args)
Definition: vector.h:189
void AddPull(const std::function< VAL_TYPE()> &fun)
Definition: DataNode.h:620
void SetKeyword(const std::string &_in)
Set this DataNode&#39;s keyword to.
Definition: DataNode.h:201
void Add()
Definition: DataNode.h:655
void PullData_impl()
Definition: DataNode.h:100
Base form of DataNodeModule (available in ALL data nodes.)
Definition: DataNode.h:95
Definition: IntPack.h:160
const emp::vector< VAL_TYPE > & GetData(size_t update) const
Get a vector of all data that was added during the.
Definition: DataNode.h:276
data
A set of modifiers are available do describe DataNode.
Definition: DataNode.h:38
size_t size() const
Definition: vector.h:151
void AddDatum(const VAL_TYPE &val)
Add.
Definition: DataNode.h:166
double GetMax(size_t update) const
Get the maximum of all values added to this DataNode during the.
Definition: DataNode.h:400
double GetMin() const
Get the min of all values added to this DataNode since the last reset.
Definition: DataNode.h:326
double min
Smallest value passed in since last reset.
Definition: DataNode.h:308
IndexMap bins
Map of values to which bin they fall in.
Definition: DataNode.h:514
Definition: DataNode.h:648
void PrintDebug(std::ostream &os=std::cout)
Print debug information (useful for figuring out which modifiers you included)
Definition: DataNode.h:418
double GetMin() const
Get the minimum of all values added to this DataNode since the last reset.
Definition: DataNode.h:385
emp::vector< double > GetBinMins() const
Return a vector containing the lowest value allowed in each bin.
Definition: DataNode.h:544
DataNodeModule()
Definition: DataNode.h:90
void SetKeyword(const std::string &)
Definition: DataNode.h:129
size_t GetResetCount() const
Definition: DataNode.h:404
emp::vector< double > min_vals
Minimums from previous resets.
Definition: DataNode.h:363
void Add(const VAL_TYPE &val, const Ts &...extras)
Methods to provide new data.
Definition: DataNode.h:659
size_t GetHistCount(size_t bin_id) const
Return the count of items in the.
Definition: DataNode.h:535
double GetHistWidth(size_t bin_id) const
Return the width of the.
Definition: DataNode.h:538
double GetTotal() const
Get the sum of all values added to this DataNode since the last reset.
Definition: DataNode.h:320
Include a signal for data OUTSIDE a range.
Include a signal for data in a range.
pack::RUsort< full > sorted
Unique and in order.
Definition: DataNode.h:644
size_t val_count
How many values have been loaded?
Definition: DataNode.h:97
double M3
The third moment of the distribution.
Definition: DataNode.h:439
double GetSkew() const
Definition: DataNode.h:120
void PrintLog(std::ostream &os=std::cout, const std::string &spacer=", ", const std::string &eol="\n") const
Definition: DataNode.h:674
VAL_TYPE value_t
Definition: DataNode.h:105
typename next_type::template append< this_req > type
Definition: DataNode.h:83
void PullData()
Method to retrieve new data.
Definition: DataNode.h:664
VAL_TYPE width
How wide is the overall histogram?
Definition: DataNode.h:513
void PrintDebug(std::ostream &os=std::cout)
Definition: DataNode.h:623
void PrintDebug(std::ostream &os=std::cout)
Print debug information (useful for figuring out which modifiers you included)
Definition: DataNode.h:585
Track Log + ALL values over time (with purge options)
emp::vector< double > max_vals
Maximums from previous resets.
Definition: DataNode.h:364
Track min, max, mean, total.
static constexpr type_if< T, std::is_integral > Pow(T base, T p)
A fast (O(log p)) integral-power command.
Definition: math.h:150
void resize(size_t new_size)
Definition: vector.h:161
size_t GetResetCount() const
Definition: DataNode.h:283
size_t GetCount() const
Return the number of values that have been added to this node since the last reset.
Definition: DataNode.h:108
const auto & GetArchive() const
Definition: DataNode.h:273
double GetStandardDeviation() const
Definition: DataNode.h:119
Include a signal when new data is added (as a group)
const std::string & GetDescription() const
Definition: DataNode.h:124
void PrintDebug(std::ostream &os=std::cout)
Print debug information (useful for figuring out which modifiers you included)
Definition: DataNode.h:686
void PrintDebug(std::ostream &os=std::cout)
Print debug information (useful for figuring out which modifiers you included)
Definition: DataNode.h:209
double GetTotal() const
Definition: DataNode.h:114
Include a signal that triggers BEFORE Reset() to process data.
double GetKurtosis() const
Definition: DataNode.h:473
void Reset()
Reset the DataNode (empties the historgram)
Definition: DataNode.h:579
If we are in emscripten, make sure to include the header.
Definition: array.h:37
size_t GetResetCount() const
Definition: DataNode.h:112
double GetMean() const
Definition: DataNode.h:115
double GetVariance() const
Definition: DataNode.h:118
double GetVariance() const
Get the variance (squared deviation from the mean) of values added since the last reset...
Definition: DataNode.h:457
const emp::vector< size_t > & GetHistCounts() const
Return a vector containing the count of items in each bin of the histogram.
Definition: DataNode.h:541
emp::vector< double > total_vals
Totals from previous resets.
Definition: DataNode.h:361
void AdjustAll(double new_weight)
Adjust all index weights to the set provided.
Definition: IndexMap.h:190
void Reset()
Methods to reset data.
Definition: DataNode.h:670
#define emp_assert(...)
Definition: assert.h:199
double total
Total of all data since last reset.
Definition: DataNode.h:307
const std::string & GetKeyword() const
Definition: DataNode.h:125
void Reset()
Reset this node (resets current stats to 0)
Definition: DataNode.h:493
double GetSkew() const
Definition: DataNode.h:466
double GetMax() const
Get the max of all values added to this DataNode since the last reset.
Definition: DataNode.h:329
double M2
The second moment of the distribution.
Definition: DataNode.h:438
void AddDatum(const VAL_TYPE &val)
Definition: DataNode.h:136
void SetName(const std::string &_in)
Set this DataNode&#39;s name to.
Definition: DataNode.h:197
void AddDatum(const VAL_TYPE &val)
Add.
Definition: DataNode.h:332
Definition: DataNode.h:70
const emp::vector< VAL_TYPE > & GetData() const
Get a vector of all data added since the last reset.
Definition: DataNode.h:232
void PrintDebug(std::ostream &os=std::cout)
Print debug information (useful for figuring out which modifiers you included)
Definition: DataNode.h:169
void AddDatum(const VAL_TYPE &val)
Add.
Definition: DataNode.h:235
void PrintDebug(std::ostream &os=std::cout)
Print debug information (useful for figuring out which modifiers you included)
Definition: DataNode.h:295
typename DataModuleRequisiteAdd< MODS... >::type reqs
Identify requisites.
Definition: DataNode.h:642
double M4
The fourth moment of the distribution.
Definition: DataNode.h:440
DataNodeModule()
Definition: DataNode.h:103
Definition: IndexMap.h:23
emp::vector< size_t > counts
Counts in each bin.
Definition: DataNode.h:515
emp::vector< emp::vector< VAL_TYPE > > archive
Data archived from before most recent reset.
Definition: DataNode.h:260
void AddDatum(const VAL_TYPE &val)
Add.
Definition: DataNode.h:571
VAL_TYPE GetHistMax() const
Definition: DataNode.h:532
void PrintCurrent(std::ostream &os=std::cout) const
Methods to Print the templated values that a DataNode can produce.
Definition: DataNode.h:673
Enable data collection on request.
Definition: DataNode.h:641
void Reset()
Reset this DataNode (clear the current log of data)
Definition: DataNode.h:241
Generic form of DataNodeModule (should never be used; trigger error!)
Definition: DataNode.h:88
void PrintDebug(std::ostream &os=std::cout)
Print debug information (useful for figuring out which modifiers you included)
Definition: DataNode.h:247
emp::vector< VAL_TYPE > in_vals
What values are waiting to be included?
Definition: DataNode.h:98
typename DataModInfo< CUR_MOD >::reqs this_req
Definition: DataNode.h:82
void SetDescription(const std::string &_in)
Set this DataNode&#39;s description to.
Definition: DataNode.h:199
std::string keyword
Short keyword.
Definition: DataNode.h:183
emp::vector< VAL_TYPE > val_set
All values saved since last reset.
Definition: DataNode.h:221