aGrUM  0.16.0
multipleInferenceEngine.h
Go to the documentation of this file.
1 
23 #ifndef __MULTIPLE_INFERENCE_ENGINES__H__
24 #define __MULTIPLE_INFERENCE_ENGINES__H__
25 
32 
37 
38 namespace gum {
39  namespace credal {
40 
54  template < typename GUM_SCALAR, class BNInferenceEngine >
55  class MultipleInferenceEngine : public InferenceEngine< GUM_SCALAR > {
56  private:
59 
64 
66  typedef std::vector< __margi > __margis;
67  typedef std::vector< __expe > __expes;
68  typedef std::vector< __credalSet > __credalSets;
69  typedef std::vector< std::vector< __cluster > > __clusters;
70 
71  typedef typename std::vector<
74 
88  inline void __updateThreadCredalSets(const NodeId& id,
89  const std::vector< GUM_SCALAR >& vertex,
90  const bool& elimRedund);
91 
92  protected:
94  __margis _l_marginalMin;
96  __margis _l_marginalMax;
104  __credalSets _l_marginalSets;
106  __margis _l_evidence;
108  __clusters _l_clusters;
109 
111  typename std::vector< __bnet* > _workingSet;
113  typename std::vector< List< const Potential< GUM_SCALAR >* >* > _workingSetE;
114 
116  typename std::vector< BNInferenceEngine* > _l_inferenceEngine;
118  std::vector< VarMod2BNsMap< GUM_SCALAR >* > _l_optimalNet;
120  // OptBN< GUM_SCALAR > _threadFusion; // we should use this OptBN if omp
121  // is
122  // disabled (avoid creating 2 objects when only one is necessary)
123  // it should also avoid calling thread fusion operations
124 
127 
138  void _initThreadsData(const Size& num_threads,
139  const bool __storeVertices,
140  const bool __storeBNOpt);
141 
143 
146 
158  inline bool _updateThread(const NodeId& id,
159  const std::vector< GUM_SCALAR >& vertex,
160  const bool& elimRedund = false);
161 
165  inline void _updateMarginals();
166 
172  inline const GUM_SCALAR _computeEpsilon();
173 
181  void _updateOldMarginals();
182 
184 
187 
189  void _optFusion();
191  void _expFusion();
193  void _verticesFusion(); // called ?? not done yet
194 
196 
197  public:
200 
206 
208  virtual ~MultipleInferenceEngine();
209 
211 
214 
221  virtual void eraseAllEvidence();
223 
226 
227  virtual void makeInference() = 0;
229  };
230 
231 
232 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
233  extern template class MultipleInferenceEngine<
234  double,
236 
237  extern template class MultipleInferenceEngine< float,
239 #endif
240 
241  } // namespace credal
242 } // namespace gum
243 
245 
246 #endif
std::vector< BNInferenceEngine *> _l_inferenceEngine
Threads BNInferenceEngine.
NodeProperty< std::vector< std::vector< GUM_SCALAR > > > __credalSet
void _initThreadsData(const Size &num_threads, const bool __storeVertices, const bool __storeBNOpt)
Initialize threads data.
__expes _l_expectationMin
Threads lower expectations, one per thread.
NodeProperty< std::vector< NodeId > > __cluster
virtual void makeInference()=0
To be redefined by each credal net algorithm.
void _optFusion()
Fusion of threads optimal IBayesNet.
__margis _l_marginalMin
Threads lower marginals, one per thread.
void _expFusion()
Fusion of threads expectations.
Class representing the minimal interface for Bayesian Network.
Definition: IBayesNet.h:62
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
std::vector< List< const Potential< GUM_SCALAR > *> *> _workingSetE
Threads evidence.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
MultipleInferenceEngine(const CredalNet< GUM_SCALAR > &credalNet)
Constructor.
virtual void eraseAllEvidence()
Erase all inference related data to perform another one.
The class for generic Hash Tables.
Definition: hashTable.h:679
std::vector< VarMod2BNsMap< GUM_SCALAR > *> _l_optimalNet
Threads optimal IBayesNet.
std::vector< __bnet *> _workingSet
Threads IBayesNet.
Class template representing a Credal Network.
Definition: credalNet.h:89
void _updateMarginals()
Fusion of threads marginals.
void _updateOldMarginals()
Update old marginals (from current marginals).
__expes _l_expectationMax
Threads upper expectations, one per thread.
__clusters _l_clusters
Threads clusters.
Abstract class template representing a CredalNet inference engine.
std::vector< std::vector< __cluster > > __clusters
const CredalNet< GUM_SCALAR > & credalNet()
Get this creadal network.
std::vector< HashTable< std::string, std::vector< GUM_SCALAR > > > __modals
bool _updateThread(const NodeId &id, const std::vector< GUM_SCALAR > &vertex, const bool &elimRedund=false)
Update thread information (marginals, expectations, IBayesNet, vertices) for a given node id...
<agrum/BN/inference/lazyPropagation.h>
NodeProperty< std::vector< GUM_SCALAR > > __margi
Class template representing a CredalNet inference engine using one or more IBayesNet inference engine...
__margis _l_marginalMax
Threads upper marginals, one per thread.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
InferenceEngine< GUM_SCALAR > __infE
To easily access InferenceEngine< GUM_SCALAR > methods.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
__credalSets _l_marginalSets
Threads vertices.
void __updateThreadCredalSets(const NodeId &id, const std::vector< GUM_SCALAR > &vertex, const bool &elimRedund)
Ask for redundancy elimination of a node credal set of a calling thread.
Size NodeId
Type for node ids.
Definition: graphElements.h:98
const GUM_SCALAR _computeEpsilon()
Compute epsilon and update old marginals.