aGrUM  0.14.2
loopySamplingInference_tpl.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et 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  ***************************************************************************/
31 
32 #define DEFAULT_VIRTUAL_LBP_SIZE 5000
33 
34 namespace gum {
35 
36 
37  template < typename GUM_SCALAR, template < typename > class APPROX >
39  const IBayesNet< GUM_SCALAR >* BN) :
40  APPROX< GUM_SCALAR >(BN),
41  _virtualLBPSize(DEFAULT_VIRTUAL_LBP_SIZE) {
42  GUM_CONSTRUCTOR(LoopySamplingInference);
43  }
44 
45 
46  template < typename GUM_SCALAR, template < typename > class APPROX >
48  GUM_DESTRUCTOR(LoopySamplingInference);
49  }
50 
51 
52  template < typename GUM_SCALAR, template < typename > class APPROX >
54  LoopyBeliefPropagation< GUM_SCALAR > lbp(&this->BN());
55  for (const auto x : this->hardEvidence()) {
56  lbp.addEvidence(x.first, x.second);
57  }
58  lbp.makeInference();
59 
60  if (!this->isSetEstimator) {
61  this->_setEstimatorFromLBP(&lbp, _virtualLBPSize);
62  }
63 
64  this->_loopApproxInference();
65  }
66 } // namespace gum
#define DEFAULT_VIRTUAL_LBP_SIZE
Class representing the minimal interface for Bayesian Network.
Definition: IBayesNet.h:59
gum is the global namespace for all aGrUM entities
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.
This file implements a Hybrid sampling class using LoopyBeliefPropagation and an approximate Inferenc...
<agrum/BN/inference/loopySamplingInference.h>