aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
scoringCache_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 a cache for caching scores and independence tests results
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 
34  /// returns the allocator used by the translator
35  template < template < typename > class ALLOC >
37  ScoringCache< ALLOC >::getAllocator() const {
38  return *this;
39  }
40 
41 
42  /// default constructor
43  template < template < typename > class ALLOC >
45  const typename ScoringCache< ALLOC >::allocator_type& alloc) :
46  ALLOC< NodeId >(alloc) {
48  }
49 
50 
51  /// copy constructor with a given allocator
52  template < template < typename > class ALLOC >
54  const ScoringCache< ALLOC >& from,
55  const typename ScoringCache< ALLOC >::allocator_type& alloc) :
56  ALLOC< NodeId >(alloc),
59  }
60 
61 
62  /// copy constructor
63  template < template < typename > class ALLOC >
66 
67 
68  /// move constructor with a given allocator
69  template < template < typename > class ALLOC >
71  ScoringCache< ALLOC >&& from,
72  const typename ScoringCache< ALLOC >::allocator_type& alloc) :
73  ALLOC< NodeId >(alloc),
76  }
77 
78 
79  /// move constructor
80  template < template < typename > class ALLOC >
83 
84 
85  /// virtual copy constructor with a given allocator
86  template < template < typename > class ALLOC >
88  const typename ScoringCache< ALLOC >::allocator_type& alloc) const {
91  try {
92  allocator.construct(cache, *this, alloc);
93  } catch (...) {
95  throw;
96  }
97  return cache;
98  }
99 
100 
101  /// virtual copy constructor
102  template < template < typename > class ALLOC >
103  ScoringCache< ALLOC >* ScoringCache< ALLOC >::clone() const {
104  return clone(this->getAllocator());
105  }
106 
107 
108  /// destructor
109  template < template < typename > class ALLOC >
112  }
113 
114 
115  /// copy operator
116  template < template < typename > class ALLOC >
119  if (&from != this) { scores__ = from.scores__; }
120  return *this;
121  }
122 
123 
124  /// move operator
125  template < template < typename > class ALLOC >
128  if (&from != this) { scores__ = std::move(from.scores__); }
129  return *this;
130  }
131 
132 
133  /// insert a new score into the cache
134  template < template < typename > class ALLOC >
135  INLINE void ScoringCache< ALLOC >::insert(const IdCondSet< ALLOC >& idset,
136  double score) {
138  }
139 
140 
141  /// insert a new score into the cache
142  template < template < typename > class ALLOC >
144  double score) {
146  }
147 
148 
149  /// removes a score (if it exists)
150  template < template < typename > class ALLOC >
151  INLINE void ScoringCache< ALLOC >::erase(const IdCondSet< ALLOC >& idset) {
153  }
154 
155 
156  /// indicates whether a given score exists
157  template < template < typename > class ALLOC >
158  INLINE bool ScoringCache< ALLOC >::exists(const IdCondSet< ALLOC >& idset) {
159  return scores__.exists(idset);
160  }
161 
162 
163  /// returns a given score
164  template < template < typename > class ALLOC >
165  INLINE double ScoringCache< ALLOC >::score(const IdCondSet< ALLOC >& idset) {
166  return scores__[idset];
167  }
168 
169 
170  /// removes all the stored scores
171  template < template < typename > class ALLOC >
172  INLINE void ScoringCache< ALLOC >::clear() {
173  scores__.clear();
174  }
175 
176 
177  /// returns the number of scores saved in the cache
178  template < template < typename > class ALLOC >
179  INLINE std::size_t ScoringCache< ALLOC >::size() const {
180  return scores__.size();
181  }
182 
183 
184  } /* namespace learning */
185 
186 } /* namespace gum */
187 
188 #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)