aGrUM  0.14.2
ITestPolicy.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 #ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_INTERFACE_TEST_POLICY_H
28 #define GUM_MULTI_DIM_FUNCTION_GRAPH_INTERFACE_TEST_POLICY_H
29 
30 // ============================================================================
32 // ============================================================================
34 // ============================================================================
35 
36 namespace gum {
37 
46  template < typename GUM_SCALAR >
47  class ITestPolicy {
48  public:
49  // ############################################################################
51  // ############################################################################
53 
54  // ============================================================================
56  // ============================================================================
57  ITestPolicy() : __isModified(false), __nbObs(0) {
58  GUM_CONSTRUCTOR(ITestPolicy);
59  }
60 
61  // ============================================================================
63  // ============================================================================
64  virtual ~ITestPolicy() { GUM_DESTRUCTOR(ITestPolicy); }
65 
66  // ============================================================================
68  // ============================================================================
69  void* operator new(size_t s) {
71  }
72  void operator delete(void* p) {
74  }
75 
77 
78 
79  // ############################################################################
81  // ############################################################################
83 
84  // ============================================================================
86  // ============================================================================
87  virtual void addObservation(Idx attr, GUM_SCALAR value) {
88  __isModified = true;
89  __nbObs++;
90  }
91 
92  // ============================================================================
94  // ============================================================================
95  Idx nbObservation() const { return __nbObs; }
96 
98 
99 
100  // ############################################################################
102  // ############################################################################
104 
105  // ============================================================================
108  // ============================================================================
109  virtual bool isTestRelevant() const = 0;
110 
111  // ============================================================================
113  // ============================================================================
114  virtual void computeScore() const { __isModified = false; }
115 
116  // ============================================================================
118  // ============================================================================
119  virtual double score() const = 0;
120 
121  // ============================================================================
123  // ============================================================================
124  virtual double secondaryscore() const = 0;
125 
127 
128 
129  // ############################################################################
131  // ############################################################################
133 
134  // ============================================================================
136  // ============================================================================
137  void add(const ITestPolicy< GUM_SCALAR >& src) {
138  __isModified = true;
139  __nbObs += src.nbObservation();
140  }
141 
143 
144 
145  // ############################################################################
147  // ############################################################################
149 
150  // ============================================================================
152  // ============================================================================
153  std::string toString() const {
154  std::stringstream ss;
155  ss << "\t\t\tNb Obs : " << __nbObs << std::endl;
156  return ss.str();
157  }
158 
160 
161  protected:
162  bool _isModified() const { return __isModified; }
163 
164  private:
166  mutable bool __isModified;
167 
170  };
171 
172 } // End of namespace gum
173 
174 #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.
Base node set class for graphs.
virtual void computeScore() const
Recomputes the statistic from the beginning.
Definition: ITestPolicy.h:114
virtual bool isTestRelevant() const =0
Returns true if enough observation were added so that the test can be relevant.
Headers of gum::SmallObjectAllocator.
ITestPolicy()
Allocators and Deallocators redefinition.
Definition: ITestPolicy.h:57
virtual void addObservation(Idx attr, GUM_SCALAR value)
Comptabilizes the new observation.
Definition: ITestPolicy.h:87
bool __isModified
Booleans indicating if we have to re eval test.
Definition: ITestPolicy.h:166
gum is the global namespace for all aGrUM entities
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:47
virtual ~ITestPolicy()
Allocators and Deallocators redefinition.
Definition: ITestPolicy.h:64
std::string toString() const
Definition: ITestPolicy.h:153
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
void add(const ITestPolicy< GUM_SCALAR > &src)
Definition: ITestPolicy.h:137
Size Idx
Type for indexes.
Definition: types.h:50
void * allocate(const size_t &objectSize)
Allocates a block.
Idx nbObservation() const
Comptabilizes the new observation.
Definition: ITestPolicy.h:95
bool _isModified() const
Definition: ITestPolicy.h:162
static SmallObjectAllocator & instance()