aGrUM  0.16.0
leastSquareTestPolicy.h
Go to the documentation of this file.
1 
30 #ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_LEAST_SQUARE_TEST_POLICY_H
31 #define GUM_MULTI_DIM_FUNCTION_GRAPH_LEAST_SQUARE_TEST_POLICY_H
32 
33 // ============================================================================
36 // ============================================================================
38 // ============================================================================
39 
40 namespace gum {
41 
51  template < typename GUM_SCALAR >
52  class LeastSquareTestPolicy : public ITestPolicy< GUM_SCALAR > {
53  public:
54  // ############################################################################
56  // ############################################################################
58 
59  // ============================================================================
61  // ============================================================================
63  ITestPolicy< GUM_SCALAR >(), __sumO(0.0), __score(0) {
64  GUM_CONSTRUCTOR(LeastSquareTestPolicy);
65  }
66 
67  // ============================================================================
69  // ============================================================================
70  void* operator new(size_t s) {
72  }
73  void operator delete(void* p) {
75  sizeof(LeastSquareTestPolicy));
76  }
77 
78  // ============================================================================
80  // ============================================================================
81  virtual ~LeastSquareTestPolicy();
82 
83  // ############################################################################
85  // ############################################################################
87 
88  // ============================================================================
90  // ============================================================================
91  void addObservation(Idx attr, GUM_SCALAR value);
92 
94 
95 
96  // ############################################################################
98  // ############################################################################
100 
101  // ============================================================================
104  // ============================================================================
105  bool isTestRelevant() const { return (this->nbObservation() > 20); }
106 
108 
109 
110  // ############################################################################
112  // ############################################################################
114 
115  // ============================================================================
117  // ============================================================================
118  void computeScore();
119 
120  // ============================================================================
122  // ============================================================================
123  double score();
124 
125  // ============================================================================
127  // ============================================================================
128  double secondaryscore() const;
129 
131 
132 
133  // ############################################################################
135  // ############################################################################
137 
138  // ============================================================================
141  // ============================================================================
142  void add(const LeastSquareTestPolicy< GUM_SCALAR >& src);
143 
144 
145  // ============================================================================
147  // ============================================================================
148  double sumValue() const { return __sumO; }
149 
150  // ============================================================================
152  // ============================================================================
153  const HashTable< Idx, Idx >& nbObsTable() const { return __nbObsTable; }
154 
155  // ============================================================================
157  // ============================================================================
159 
160  // ============================================================================
162  // ============================================================================
164  return __obsTable;
165  }
166 
167  private:
169  double __sumO;
170 
173 
176 
179 
181  double __score;
182  };
183 
184 } // End of namespace gum
185 
187 
188 #endif /* GUM_MULTI_DIM_FUNCTION_GRAPH_LEAST_SQUARE_TEST_POLICY_H */
const HashTable< Idx, LinkedList< double > *> & obsTable() const
Returns global sum (needed for the merging)
double score()
Returns the performance of current variable according to the test.
const HashTable< Idx, Idx > & nbObsTable() const
Returns nbobs per modality table (needed for the merging)
HashTable< Idx, LinkedList< double > *> __obsTable
Not sure if needed.
virtual ~LeastSquareTestPolicy()
Destructor.
double secondaryscore() const
Returns a second criterion to severe ties.
const HashTable< Idx, double > & sumAttrTable() const
Returns sum per modality table (needed for the merging)
void add(const LeastSquareTestPolicy< GUM_SCALAR > &src)
Performs the merging of current LeastSquareTestPolicy instance with given instance.
double sumValue() const
Returns global sum (needed for the merging)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool isTestRelevant() const
Returns true if enough observation were made so that the test can be relevant.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
HashTable< Idx, Idx > __nbObsTable
Nb Observation for each modality assumed by variable.
<agrum/multidim/core/testPolicy/leastSquareTestPolicy.h>
void addObservation(Idx attr, GUM_SCALAR value)
Comptabilizes the new observation.
<agrum/multidim/core/testPolicies/ITestPolicy.h>
Definition: ITestPolicy.h:50
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void computeScore()
Returns the performance of current variable according to the test.
double __score
Keeping computed score.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
HashTable< Idx, double > __sumAttrTable
Sum for each modality assumed by variable.
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
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
static SmallObjectAllocator & instance()