aGrUM  0.16.0
loopySamplingInference_tpl.h
Go to the documentation of this file.
1 
34 
35 #define DEFAULT_VIRTUAL_LBP_SIZE 5000
36 
37 namespace gum {
38 
39 
40  template < typename GUM_SCALAR, template < typename > class APPROX >
42  const IBayesNet< GUM_SCALAR >* BN) :
43  APPROX< GUM_SCALAR >(BN),
44  _virtualLBPSize(DEFAULT_VIRTUAL_LBP_SIZE) {
45  GUM_CONSTRUCTOR(LoopySamplingInference);
46  }
47 
48 
49  template < typename GUM_SCALAR, template < typename > class APPROX >
51  GUM_DESTRUCTOR(LoopySamplingInference);
52  }
53 
54 
55  template < typename GUM_SCALAR, template < typename > class APPROX >
57  LoopyBeliefPropagation< GUM_SCALAR > lbp(&this->BN());
58  for (const auto x : this->hardEvidence()) {
59  lbp.addEvidence(x.first, x.second);
60  }
61  lbp.makeInference();
62 
63  if (!this->isSetEstimator) {
64  this->_setEstimatorFromLBP(&lbp, _virtualLBPSize);
65  }
66 
67  this->_loopApproxInference();
68  }
69 } // namespace gum
#define DEFAULT_VIRTUAL_LBP_SIZE
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
virtual void makeInference() final
perform the heavy computations needed to compute the targets&#39; posteriors
virtual ~LoopySamplingInference()
destructor
virtual void addEvidence(NodeId id, const Idx val) final
adds a new hard evidence on node id
<agrum/BN/inference/loopyBeliefPropagation.h>
virtual void _makeInference()
makes the inference by generating samples w.r.t the mother class&#39; sampling method after initalizing e...
LoopySamplingInference(const IBayesNet< GUM_SCALAR > *bn)
Default constructor.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
<agrum/BN/inference/loopySamplingInference.h>