aGrUM  0.14.2
kNML.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_LEARNING_K_NML_H
28 #define GUM_LEARNING_K_NML_H
29 
30 #include <vector>
31 
32 #include <agrum/core/math/math.h>
35 
36 namespace gum {
37 
38  namespace learning {
39 
40 
46  template < template < typename > class ALLOC = std::allocator >
47  class KNML : private IndependenceTest< ALLOC > {
48  public:
50  using allocator_type = ALLOC< NodeId >;
51 
52  // ##########################################################################
54  // ##########################################################################
56 
58 
80  KNML(const DBRowGeneratorParser< ALLOC >& parser,
81  const Apriori< ALLOC >& apriori,
82  const std::vector< std::pair< std::size_t, std::size_t >,
83  ALLOC< std::pair< std::size_t, std::size_t > > >&
84  ranges,
85  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
86  nodeId2columns =
87  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
88  const allocator_type& alloc = allocator_type());
89 
90 
92 
108  KNML(const DBRowGeneratorParser< ALLOC >& parser,
109  const Apriori< ALLOC >& apriori,
110  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
111  nodeId2columns =
112  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
113  const allocator_type& alloc = allocator_type());
114 
116  KNML(const KNML< ALLOC >& from);
117 
119  KNML(const KNML< ALLOC >& from, const allocator_type& alloc);
120 
122  KNML(KNML< ALLOC >&& from);
123 
125  KNML(KNML< ALLOC >&& from, const allocator_type& alloc);
126 
128  virtual KNML< ALLOC >* clone() const;
129 
131  virtual KNML< ALLOC >* clone(const allocator_type& alloc) const;
132 
134  virtual ~KNML();
135 
137 
138 
139  // ##########################################################################
141  // ##########################################################################
142 
144 
146  KNML< ALLOC >& operator=(const KNML< ALLOC >& from);
147 
150 
152 
153 
154  // ##########################################################################
156  // ##########################################################################
158 
161 
164 
175 
178 
180 
187 
190 
193 
196 
198  virtual void clear();
199 
201  virtual void clearCache();
202 
204  virtual void useCache(const bool on_off);
205 
207 
211 
214 
217 
219 
220 
221  protected:
223 
226  virtual double _score(const IdSet< ALLOC >& idset) final;
227 
228 
229 #ifndef DOXYGEN_SHOULD_SKIP_THIS
230 
231  private:
233  VariableLog2ParamComplexity< ALLOC > __param_complexity;
234 
235 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
236  };
237 
238  } /* namespace learning */
239 
240 } /* namespace gum */
241 
242 
243 // always include the template implementation
245 
246 #endif /* GUM_LEARNING_K_NML_H */
Useful macros for maths.
the base class for all the independence tests used for learning
The base class for all the independence tests used for learning.
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: kNML.h:50
A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set...
Definition: idSet.h:45
the base class for all a priori
Definition: apriori.h:47
const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > > & ranges() const
returns the current ranges
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
the class for computing the log2 of the parametric complexity of an r-ary multinomial variable ...
virtual void clear()
clears all the data structures from memory, including the C_n^r cache
virtual ~KNML()
destructor
virtual double _score(const IdSet< ALLOC > &idset) final
returns the score for a given IdSet
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1803
virtual void clearCache()
clears the current C_n^r cache
the class for computing the log2 of the parametric complexity of an r-ary multinomial variableThis cl...
KNML< ALLOC > & operator=(const KNML< ALLOC > &from)
copy operator
the class for computing the NML penalty used by 3off2
Definition: kNML.h:47
virtual void useCache(const bool on_off)
turn on/off the use of the C_n^r cache
virtual KNML< ALLOC > * clone() const
virtual copy constructor
the class used to read a row in the database and to transform it into a set of DBRow instances that c...
Size NodeId
Type for node ids.
Definition: graphElements.h:97
KNML(const DBRowGeneratorParser< ALLOC > &parser, const Apriori< ALLOC > &apriori, const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > > &ranges, const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > &nodeId2columns=Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(), const allocator_type &alloc=allocator_type())
default constructor
The class for the NML penalty used in 3off2.