aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
apriori_tpl.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 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,
37  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
39  const typename Apriori< ALLOC >::allocator_type& alloc) :
40  ALLOC< NodeId >(alloc),
43  }
44 
45 
46  /// copy constructor with a given allocator
47  template < template < typename > class ALLOC >
49  const Apriori< ALLOC >& from,
50  const typename Apriori< ALLOC >::allocator_type& alloc) :
51  ALLOC< NodeId >(alloc),
55  }
56 
57 
58  /// copy constructor
59  template < template < typename > class ALLOC >
60  INLINE Apriori< ALLOC >::Apriori(const Apriori< ALLOC >& from) :
62 
63 
64  /// move constructor
65  template < template < typename > class ALLOC >
67  Apriori< ALLOC >&& from,
68  const typename Apriori< ALLOC >::allocator_type& alloc) :
69  ALLOC< NodeId >(alloc),
73  }
74 
75 
76  /// move constructor
77  template < template < typename > class ALLOC >
80 
81 
82  /// destructor
83  template < template < typename > class ALLOC >
84  INLINE Apriori< ALLOC >::~Apriori() {
86  }
87 
88 
89  /// copy operator
90  template < template < typename > class ALLOC >
91  Apriori< ALLOC >& Apriori< ALLOC >::operator=(const Apriori< ALLOC >& from) {
92  if (this != &from) {
96  }
97  return *this;
98  }
99 
100 
101  /// move operator
102  template < template < typename > class ALLOC >
104  if (this != &from) {
106  weight_ = from.weight_;
108  }
109  return *this;
110  }
111 
112 
113  /// sets the weight of the a priori (kind of effective sample size)
114  template < template < typename > class ALLOC >
115  INLINE void Apriori< ALLOC >::setWeight(const double weight) {
116  if (weight < 0.0) {
118  "A negative weight (" << weight
119  << ") is forbidden for an apriori");
120  }
121  weight_ = weight;
122  }
123 
124 
125  /// returns the weight assigned to the apriori
126  template < template < typename > class ALLOC >
127  INLINE double Apriori< ALLOC >::weight() const {
128  return weight_;
129  }
130 
131 
132  /// returns the allocator used by the translator
133  template < template < typename > class ALLOC >
134  INLINE typename Apriori< ALLOC >::allocator_type
135  Apriori< ALLOC >::getAllocator() const {
136  return *this;
137  }
138 
139 
140  } /* namespace learning */
141 
142 } /* namespace gum */
143 
144 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)