aGrUM  0.16.0
varMod2BNsMap.h
Go to the documentation of this file.
1 
30 #ifndef __VAR_MOD_2_BNS_MAP__H__
31 #define __VAR_MOD_2_BNS_MAP__H__
32 
33 #include <list>
34 
35 //#include <tr1/functional>
36 
37 #include <agrum/core/hashTable.h>
38 #include <agrum/core/math/pow.h>
39 
40 #include <agrum/CN/credalNet.h>
41 
42 namespace gum {
43  namespace credal {
44 
55  template < typename GUM_SCALAR >
56  class VarMod2BNsMap {
57  private:
58  typedef std::vector< bool > dBN;
59 
60  typedef typename std::vector< Size > varKey;
61 
63 
65 
67 
68  protected:
70  hashNet _myHashNet;
73  varHashs _myVarHashs;
77  hashVars _myHashVars;
78 
82  std::vector< std::vector< std::vector< bool > > > _sampleDef;
83 
89  std::hash< std::vector< bool > > _vectHash;
90 
93 
94  public:
97 
104  explicit VarMod2BNsMap(const CredalNet< GUM_SCALAR >& cn);
105 
109  VarMod2BNsMap();
110 
112  ~VarMod2BNsMap();
113 
115 
125  bool insert(const std::vector< bool >& bn, const std::vector< Size >& key);
126 
134  bool insert(const std::vector< Size >& key, const bool isBetter);
135 
138 
146  void setCNet(const CredalNet< GUM_SCALAR >& cn);
147 
152  void setCurrentSample(
153  const std::vector< std::vector< std::vector< bool > > >& sample);
154 
160  const dBN& getCurrentSample();
161 
166  const std::vector< std::vector< std::vector< bool > > >& getSampleDef();
167 
176  const std::vector< dBN* > getBNOptsFromKey(const std::vector< Size >& key);
177 
185  std::vector< std::vector< std::vector< std::vector< bool > > > >
186  getFullBNOptsFromKey(const std::vector< Size >& key);
187 
189  Size getEntrySize() const;
190 
192 
193  }; // end of OptBN
194 
195 
196 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
197  extern template class VarMod2BNsMap< double >;
198 #endif
199 
200  } // namespace credal
201 } // namespace gum
202 
204 
205 #endif
gum::HashTable< Size, dBN > hashNet
Definition: varMod2BNsMap.h:62
hashVars _myHashVars
Map id - list(varKey) : get all variables, modalities associated to this optimal net id...
Definition: varMod2BNsMap.h:77
std::hash< std::vector< bool > > _vectHash
The hash fuction.
Definition: varMod2BNsMap.h:89
gum::HashTable< varKey, std::list< Size > > varHashs
Definition: varMod2BNsMap.h:64
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const CredalNet< GUM_SCALAR > * cnet
A pointer to the CredalNet to be used.
Definition: varMod2BNsMap.h:92
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Size _currentHash
The current sampled IBayesNet hash.
Definition: varMod2BNsMap.h:87
Class template representing a Credal Network.
Definition: credalNet.h:89
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...
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...
gum::HashTable< Size, std::list< varKey > > hashVars
Definition: varMod2BNsMap.h:66
dBN _currentSample
The current sampled IBayesNet.
Definition: varMod2BNsMap.h:85
Size getEntrySize() const
Get the number of IBayesNet stored.
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:82
std::vector< bool > dBN
Definition: varMod2BNsMap.h:58
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:73
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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:70
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
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:56
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::vector< Size > varKey
Definition: varMod2BNsMap.h:60
void setCurrentSample(const std::vector< std::vector< std::vector< bool > > > &sample)
Set the current thread sample and it&#39;s hash.