creativity  v1.3.0
Agent-based model of creativity and piracy
TreatmentFilter.hpp
1 #pragma once
2 #include <creativity/data/Treatment.hpp>
3 #include <memory>
4 
5 namespace creativity { namespace data {
6 
36 class TreatmentFilter : public Treatment {
37  public:
39  class StageProperties final {
40  public:
50  double value(const std::string &field) const;
51 
52  private:
53  const Treatment &source_;
54  const unsigned row_;
55  StageProperties(const Treatment &source, unsigned rownum)
56  : source_(source), row_(rownum) {}
57  friend class TreatmentFilter;
58  };
59 
61  struct Properties final {
62  public:
64  std::unique_ptr<const StageProperties> pre;
69  std::unique_ptr<const StageProperties> piracy;
74  std::unique_ptr<const StageProperties> policy;
79  std::unique_ptr<const StageProperties> piracy_SR;
84  std::unique_ptr<const StageProperties> policy_SR;
86  std::string source;
87  };
88 
101  TreatmentFilter(const Treatment &source,
102  std::function<bool(const Properties&)> filter,
103  std::function<bool(bool pre, bool piracy, bool policy, bool short_run)> stage_filter = [](bool,bool,bool,bool) { return true; }
104  );
105 };
106 
107 }}
Extension to Treatment that applies a filter to an existing Treatment variable, resulting in a new Tr...
Definition: TreatmentFilter.hpp:36
std::unique_ptr< const StageProperties > policy
A pointer to the Properties values for the LR policy row associated with this row.
Definition: TreatmentFilter.hpp:74
Primary namespace for all Creativity library code.
Definition: config.hpp:4
std::unique_ptr< const StageProperties > pre
A pointer to the Properties value for the pre row associated with this row.
Definition: TreatmentFilter.hpp:64
std::string source
The source data simulation filename.
Definition: TreatmentFilter.hpp:86
std::unique_ptr< const StageProperties > piracy
A pointer to the Properties values for the LR piracy row associated with this row.
Definition: TreatmentFilter.hpp:69
std::unique_ptr< const StageProperties > policy_SR
A pointer to the Properties values for the SR public row associated with this row.
Definition: TreatmentFilter.hpp:84
This class converts raw simulation data into multiple data rows, with piracy/policy, SR/LR as treatment effects on the base (pre-piracy, pre-policy) row.
Definition: Treatment.hpp:14
Data properties for rows filtered by TreatmentFilter()
Definition: TreatmentFilter.hpp:61
Provides a simple interface to accessing the value of a field for a single observation.
Definition: TreatmentFilter.hpp:39
double value(const std::string &field) const
Returns the value associated with the given stage field name.
std::unique_ptr< const StageProperties > piracy_SR
A pointer to the Properties values for the SR piracy row associated with this row.
Definition: TreatmentFilter.hpp:79