aGrUM  0.16.0
apriori_tpl.h
Go to the documentation of this file.
1 
28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 
30 namespace gum {
31 
32  namespace learning {
33 
35  template < template < typename > class ALLOC >
37  const DatabaseTable< ALLOC >& database,
38  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
39  nodeId2columns,
40  const typename Apriori< ALLOC >::allocator_type& alloc) :
41  ALLOC< NodeId >(alloc),
42  _database(&database), _nodeId2columns(nodeId2columns) {
43  GUM_CONSTRUCTOR(Apriori);
44  }
45 
46 
48  template < template < typename > class ALLOC >
50  const Apriori< ALLOC >& from,
51  const typename Apriori< ALLOC >::allocator_type& alloc) :
52  ALLOC< NodeId >(alloc),
53  _weight(from._weight), _database(from._database),
55  GUM_CONS_CPY(Apriori);
56  }
57 
58 
60  template < template < typename > class ALLOC >
61  INLINE Apriori< ALLOC >::Apriori(const Apriori< ALLOC >& from) :
62  Apriori(from, from.getAllocator()) {}
63 
64 
66  template < template < typename > class ALLOC >
68  Apriori< ALLOC >&& from,
69  const typename Apriori< ALLOC >::allocator_type& alloc) :
70  ALLOC< NodeId >(alloc),
71  _weight(from._weight), _database(from._database),
72  _nodeId2columns(std::move(from._nodeId2columns)) {
73  GUM_CONS_MOV(Apriori);
74  }
75 
76 
78  template < template < typename > class ALLOC >
79  INLINE Apriori< ALLOC >::Apriori(Apriori< ALLOC >&& from) :
80  Apriori(std::move(from), from.getAllocator()) {}
81 
82 
84  template < template < typename > class ALLOC >
86  GUM_DESTRUCTOR(Apriori);
87  }
88 
89 
91  template < template < typename > class ALLOC >
92  Apriori< ALLOC >& Apriori< ALLOC >::operator=(const Apriori< ALLOC >& from) {
93  if (this != &from) {
94  _nodeId2columns = from._nodeId2columns;
95  _weight = from._weight;
96  _database = from._database;
97  }
98  return *this;
99  }
100 
101 
103  template < template < typename > class ALLOC >
104  Apriori< ALLOC >& Apriori< ALLOC >::operator=(Apriori< ALLOC >&& from) {
105  if (this != &from) {
106  _nodeId2columns = std::move(from._nodeId2columns);
107  _weight = from._weight;
108  _database = from._database;
109  }
110  return *this;
111  }
112 
113 
115  template < template < typename > class ALLOC >
116  INLINE void Apriori< ALLOC >::setWeight(const double weight) {
117  if (weight < 0.0) {
118  GUM_ERROR(OutOfBounds,
119  "A negative weight (" << weight
120  << ") is forbidden for an apriori");
121  }
122  _weight = weight;
123  }
124 
125 
127  template < template < typename > class ALLOC >
128  INLINE double Apriori< ALLOC >::weight() const {
129  return _weight;
130  }
131 
132 
134  template < template < typename > class ALLOC >
135  INLINE typename Apriori< ALLOC >::allocator_type
137  return *this;
138  }
139 
140 
141  } /* namespace learning */
142 
143 } /* namespace gum */
144 
145 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
virtual void setWeight(const double weight)
sets the weight of the a priori (kind of effective sample size)
STL namespace.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
const DatabaseTable< ALLOC > * _database
a reference to the database in order to have access to its variables
Definition: apriori.h:146
double weight() const
returns the weight assigned to the apriori
double _weight
the weight of the apriori
Definition: apriori.h:143
Apriori< ALLOC > & operator=(const Apriori< ALLOC > &from)
copy operator
allocator_type getAllocator() const
returns the allocator used by the internal apriori
Bijection< NodeId, std::size_t, ALLOC< std::size_t > > _nodeId2columns
a mapping from the NodeIds of the variables to the indices of the columns in the database ...
Definition: apriori.h:150
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: apriori.h:53
Size NodeId
Type for node ids.
Definition: graphElements.h:98
Apriori(const DatabaseTable< ALLOC > &database, 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
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
virtual ~Apriori()
destructor