aGrUM  0.14.2
scoringCache.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  ***************************************************************************/
31 #ifndef GUM_LEARNING_SCORING_CACHE_H
32 #define GUM_LEARNING_SCORING_CACHE_H
33 
34 #include <utility>
35 
36 #include <agrum/agrum.h>
38 
39 namespace gum {
40 
41  namespace learning {
42 
43 
56  template < template < typename > class ALLOC = std::allocator >
57  class ScoringCache : private ALLOC< NodeId > {
58  public:
60  using allocator_type = ALLOC< NodeId >;
61 
62  // ##########################################################################
64  // ##########################################################################
66 
68  ScoringCache(const allocator_type& alloc = allocator_type());
69 
72 
74  ScoringCache(const ScoringCache< ALLOC >& from, const allocator_type& alloc);
75 
78 
81 
83  virtual ScoringCache< ALLOC >* clone() const;
84 
86  virtual ScoringCache< ALLOC >* clone(const allocator_type& alloc) const;
87 
89  virtual ~ScoringCache();
90 
92 
93 
94  // ##########################################################################
96  // ##########################################################################
98 
101 
104 
106 
107 
108  // ##########################################################################
110  // ##########################################################################
112 
114 
118  void insert(const IdSet< ALLOC >& idset, double score);
119 
121 
125  void insert(IdSet< ALLOC >&& idset, double score);
126 
128 
131  void erase(const IdSet< ALLOC >& idset);
132 
134 
135  bool exists(const IdSet< ALLOC >& idset);
136 
138 
140  double score(const IdSet< ALLOC >& idset);
141 
143  void clear();
144 
146  std::size_t size() const;
147 
150 
152 
153 
154 #ifndef DOXYGEN_SHOULD_SKIP_THIS
155 
156  private:
159  double,
160  ALLOC< std::pair< IdSet< ALLOC >, double > > >
161  __scores;
162 
163 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
164  };
165 
166  } /* namespace learning */
167 
168 } /* namespace gum */
169 
170 
171 // always include the template implementation
173 
174 
175 #endif /* GUM_LEARNING_SCORING_CACHE_H */
virtual ~ScoringCache()
destructor
A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set...
Definition: idSet.h:45
void erase(const IdSet< ALLOC > &idset)
removes a score (if it exists)
A class used by learning caches to represent uniquely sets of variables.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:676
std::size_t size() const
returns the number of scores saved in the cache
a cache for caching scores and independence tests results
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: scoringCache.h:60
void clear()
removes all the stored scores
double score(const IdSet< ALLOC > &idset)
returns a given score
ScoringCache< ALLOC > & operator=(const ScoringCache< ALLOC > &from)
copy operator
void insert(const IdSet< ALLOC > &idset, double score)
insert a new score into the cache
ScoringCache(const allocator_type &alloc=allocator_type())
default constructor
virtual ScoringCache< ALLOC > * clone() const
virtual copy constructor
a cache for caching scores and independence tests resultsCaching previously computed scores or the re...
Definition: scoringCache.h:57
allocator_type getAllocator() const
returns the allocator used by the translator
bool exists(const IdSet< ALLOC > &idset)
indicates whether a given score exists