aGrUM  0.16.0
ITestPolicy.h
Go to the documentation of this file.
1 
30 #ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_INTERFACE_TEST_POLICY_H
31 #define GUM_MULTI_DIM_FUNCTION_GRAPH_INTERFACE_TEST_POLICY_H
32 
33 // ============================================================================
35 // ============================================================================
37 // ============================================================================
38 
39 namespace gum {
40 
49  template < typename GUM_SCALAR >
50  class ITestPolicy {
51  public:
52  // ############################################################################
54  // ############################################################################
56 
57  // ============================================================================
59  // ============================================================================
60  ITestPolicy() : __isModified(false), __nbObs(0) {
61  GUM_CONSTRUCTOR(ITestPolicy);
62  }
63 
64  // ============================================================================
66  // ============================================================================
67  virtual ~ITestPolicy() { GUM_DESTRUCTOR(ITestPolicy); }
68 
69  // ============================================================================
71  // ============================================================================
72  void* operator new(size_t s) {
74  }
75  void operator delete(void* p) {
77  }
78 
80 
81 
82  // ############################################################################
84  // ############################################################################
86 
87  // ============================================================================
89  // ============================================================================
90  virtual void addObservation(Idx attr, GUM_SCALAR value) {
91  __isModified = true;
92  __nbObs++;
93  }
94 
95  // ============================================================================
97  // ============================================================================
98  Idx nbObservation() const { return __nbObs; }
99 
101 
102 
103  // ############################################################################
105  // ############################################################################
107 
108  // ============================================================================
111  // ============================================================================
112  virtual bool isTestRelevant() const = 0;
113 
114  // ============================================================================
116  // ============================================================================
117  virtual void computeScore() const { __isModified = false; }
118 
119  // ============================================================================
121  // ============================================================================
122  virtual double score() const = 0;
123 
124  // ============================================================================
126  // ============================================================================
127  virtual double secondaryscore() const = 0;
128 
130 
131 
132  // ############################################################################
134  // ############################################################################
136 
137  // ============================================================================
139  // ============================================================================
140  void add(const ITestPolicy< GUM_SCALAR >& src) {
141  __isModified = true;
142  __nbObs += src.nbObservation();
143  }
144 
146 
147 
148  // ############################################################################
150  // ############################################################################
152 
153  // ============================================================================
155  // ============================================================================
156  std::string toString() const {
157  std::stringstream ss;
158  ss << "\t\t\tNb Obs : " << __nbObs << std::endl;
159  return ss.str();
160  }
161 
163 
164  protected:
165  bool _isModified() const { return __isModified; }
166 
167  private:
169  mutable bool __isModified;
170 
173  };
174 
175 } // End of namespace gum
176 
177 #endif /* GUM_MULTI_DIM_FUNCTION_GRAPH_INTERFACE_TEST_POLICY_H */
virtual double score() const =0
Returns the performance of current variable according to the test.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void computeScore() const
Recomputes the statistic from the beginning.
Definition: ITestPolicy.h:117
virtual bool isTestRelevant() const =0
Returns true if enough observation were added so that the test can be relevant.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
ITestPolicy()
Allocators and Deallocators redefinition.
Definition: ITestPolicy.h:60
virtual void addObservation(Idx attr, GUM_SCALAR value)
Comptabilizes the new observation.
Definition: ITestPolicy.h:90
bool __isModified
Booleans indicating if we have to re eval test.
Definition: ITestPolicy.h:169
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
virtual double secondaryscore() const =0
Returns a second criterion to severe ties.
<agrum/multidim/core/testPolicies/ITestPolicy.h>
Definition: ITestPolicy.h:50
virtual ~ITestPolicy()
Allocators and Deallocators redefinition.
Definition: ITestPolicy.h:67
std::string toString() const
Definition: ITestPolicy.h:156
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
void add(const ITestPolicy< GUM_SCALAR > &src)
Definition: ITestPolicy.h:140
Size Idx
Type for indexes.
Definition: types.h:53
void * allocate(const size_t &objectSize)
Allocates a block.
Idx nbObservation() const
Comptabilizes the new observation.
Definition: ITestPolicy.h:98
bool _isModified() const
Definition: ITestPolicy.h:165
static SmallObjectAllocator & instance()