aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
apriori_tpl.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /** @file
23  * @brief the base class for all a prioris
24  *
25  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 #ifndef DOXYGEN_SHOULD_SKIP_THIS
28 
29 namespace gum {
30 
31  namespace learning {
32 
33  /// default constructor
34  template < template < typename > class ALLOC >
35  INLINE Apriori< ALLOC >::Apriori(
36  const DatabaseTable< ALLOC >& database,
38  const typename Apriori< ALLOC >::allocator_type& alloc) :
39  ALLOC< NodeId >(alloc),
42  }
43 
44 
45  /// copy constructor with a given allocator
46  template < template < typename > class ALLOC >
48  const typename Apriori< ALLOC >::allocator_type& alloc) :
49  ALLOC< NodeId >(alloc),
52  }
53 
54 
55  /// copy constructor
56  template < template < typename > class ALLOC >
57  INLINE Apriori< ALLOC >::Apriori(const Apriori< ALLOC >& from) :
59 
60 
61  /// move constructor
62  template < template < typename > class ALLOC >
64  const typename Apriori< ALLOC >::allocator_type& alloc) :
65  ALLOC< NodeId >(alloc),
69  }
70 
71 
72  /// move constructor
73  template < template < typename > class ALLOC >
76 
77 
78  /// destructor
79  template < template < typename > class ALLOC >
80  INLINE Apriori< ALLOC >::~Apriori() {
82  }
83 
84 
85  /// copy operator
86  template < template < typename > class ALLOC >
87  Apriori< ALLOC >& Apriori< ALLOC >::operator=(const Apriori< ALLOC >& from) {
88  if (this != &from) {
92  }
93  return *this;
94  }
95 
96 
97  /// move operator
98  template < template < typename > class ALLOC >
100  if (this != &from) {
102  weight_ = from.weight_;
104  }
105  return *this;
106  }
107 
108 
109  /// sets the weight of the a priori (kind of effective sample size)
110  template < template < typename > class ALLOC >
111  INLINE void Apriori< ALLOC >::setWeight(const double weight) {
112  if (weight < 0.0) {
113  GUM_ERROR(OutOfBounds, "A negative weight (" << weight << ") is forbidden for an apriori");
114  }
115  weight_ = weight;
116  }
117 
118 
119  /// returns the weight assigned to the apriori
120  template < template < typename > class ALLOC >
121  INLINE double Apriori< ALLOC >::weight() const {
122  return weight_;
123  }
124 
125 
126  /// returns the allocator used by the translator
127  template < template < typename > class ALLOC >
128  INLINE typename Apriori< ALLOC >::allocator_type Apriori< ALLOC >::getAllocator() const {
129  return *this;
130  }
131 
132 
133  } /* namespace learning */
134 
135 } /* namespace gum */
136 
137 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)