aGrUM  0.13.2
varMod2BNsMap.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
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  ***************************************************************************/
20 
28 #ifndef __VAR_MOD_2_BNS_MAP__H__
29 #define __VAR_MOD_2_BNS_MAP__H__
30 
31 #include <list>
32 
33 //#include <tr1/functional>
34 
35 #include <agrum/core/hashTable.h>
36 #include <agrum/core/math/pow.h>
37 
38 #include <agrum/CN/credalNet.h>
39 
40 namespace gum {
41  namespace credal {
42 
53  template < typename GUM_SCALAR >
54  class VarMod2BNsMap {
55  private:
56  typedef std::vector< bool > dBN;
57 
58  typedef typename std::vector< Size > varKey;
59 
61 
63 
65 
66  protected:
68  hashNet _myHashNet;
71  varHashs _myVarHashs;
75  hashVars _myHashVars;
76 
80  std::vector< std::vector< std::vector< bool > > > _sampleDef;
81 
87  std::hash< std::vector< bool > > _vectHash;
88 
91 
92  public:
95 
102  explicit VarMod2BNsMap(const CredalNet< GUM_SCALAR >& cn);
103 
107  VarMod2BNsMap();
108 
110  ~VarMod2BNsMap();
111 
113 
123  bool insert(const std::vector< bool >& bn, const std::vector< Size >& key);
124 
132  bool insert(const std::vector< Size >& key, const bool isBetter);
133 
136 
144  void setCNet(const CredalNet< GUM_SCALAR >& cn);
145 
150  void setCurrentSample(
151  const std::vector< std::vector< std::vector< bool > > >& sample);
152 
158  const dBN& getCurrentSample();
159 
164  const std::vector< std::vector< std::vector< bool > > >& getSampleDef();
165 
174  const std::vector< dBN* > getBNOptsFromKey(const std::vector< Size >& key);
175 
183  std::vector< std::vector< std::vector< std::vector< bool > > > >
184  getFullBNOptsFromKey(const std::vector< Size >& key);
185 
187  Size getEntrySize() const;
188 
190 
191  }; // end of OptBN
192 
193 
194  extern template class VarMod2BNsMap< float >;
195  extern template class VarMod2BNsMap< double >;
196 
197  } // namespace credal
198 } // namespace gum
199 
201 
202 #endif
gum::HashTable< Size, dBN > hashNet
Definition: varMod2BNsMap.h:60
unsigned long Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:50
const std::vector< dBN * > getBNOptsFromKey(const std::vector< Size > &key)
Get optimum IBayesNet (s) without structure of the given variable, modality for min or max...
hashVars _myHashVars
Map id - list(varKey) : get all variables, modalities associated to this optimal net id...
Definition: varMod2BNsMap.h:75
std::hash< std::vector< bool > > _vectHash
The hash fuction.
Definition: varMod2BNsMap.h:87
gum::HashTable< varKey, std::list< Size > > varHashs
Definition: varMod2BNsMap.h:62
Implementation of pow functions with integers, faster than stl implementation.
const CredalNet< GUM_SCALAR > * cnet
A pointer to the CredalNet to be used.
Definition: varMod2BNsMap.h:90
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
Size _currentHash
The current sampled IBayesNet hash.
Definition: varMod2BNsMap.h:85
Class template representing a Credal Network.
Definition: credalNet.h:87
Size getEntrySize() const
Get the number of IBayesNet stored.
std::vector< std::vector< std::vector< std::vector< bool > > > > getFullBNOptsFromKey(const std::vector< Size > &key)
Get optimum IBayesNet (s) with structure of the given variable, modality for min or max...
gum::HashTable< Size, std::list< varKey > > hashVars
Definition: varMod2BNsMap.h:64
dBN _currentSample
The current sampled IBayesNet.
Definition: varMod2BNsMap.h:83
std::vector< std::vector< std::vector< bool > > > _sampleDef
Since all samples have the same structure, this will be used as default initialization (copy construc...
Definition: varMod2BNsMap.h:80
std::vector< bool > dBN
Definition: varMod2BNsMap.h:56
void setCNet(const CredalNet< GUM_SCALAR > &cn)
Initialize __sampleDef from the CredalNet.
varHashs _myVarHashs
Map varKey - list(id) : get all optimal nets id from the given key : variable, modality and min=0 ( o...
Definition: varMod2BNsMap.h:71
Class representing Credal Networks.
const dBN & getCurrentSample()
Get the current sample as a vector of bits without structure.
VarMod2BNsMap()
Default constructor that should be used only by InferenceEngine since it has a member variable...
const std::vector< std::vector< std::vector< bool > > > & getSampleDef()
Get the sample structure.
hashNet _myHashNet
Map id - dBN : get a net from it&#39;s id.
Definition: varMod2BNsMap.h:68
bool insert(const std::vector< bool > &bn, const std::vector< Size > &key)
Insert for thread fusion.
Class used to store optimum IBayesNet during some inference algorithms.
Definition: varMod2BNsMap.h:54
Class hash tables iterators.
std::vector< Size > varKey
Definition: varMod2BNsMap.h:58
void setCurrentSample(const std::vector< std::vector< std::vector< bool > > > &sample)
Set the current thread sample and it&#39;s hash.