aGrUM  0.14.2
gibbsOperator.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  ***************************************************************************/
28 #ifndef GUM_GIBBS_OPERATOR_H
29 #define GUM_GIBBS_OPERATOR_H
30 
31 #include <agrum/BN/IBayesNet.h>
34 
35 namespace gum {
36 
46  template < typename GUM_SCALAR >
47  class GibbsOperator {
48  public:
53  const NodeProperty< Idx >* hardEv,
54  Size nbr = 1,
55  bool atRandom = false);
56 
60  virtual ~GibbsOperator();
61 
63  Size nbrDrawnVar() const { return _nbr; }
64 
65  void setNbrDrawnVar(Size nbr) { _nbr = nbr; }
66 
67  bool isDrawnAtRandom() const { return _atRandom; }
68 
69  void setDrawnAtRandom(bool atRandom) { _atRandom = atRandom; }
70 
73 
76 
77  protected:
83 
85 
86  protected:
87  bool _atRandom;
88 
89 
90  private:
91  void __updateSamplingNodes();
92  // adds a node to current instantiation
94  void __GibbsSample(NodeId id, Instantiation* I);
95  };
96 
97 
98 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
99  extern template class GibbsOperator< double >;
100 #endif
101 
102 } // namespace gum
103 
105 #endif
bool isDrawnAtRandom() const
Definition: gibbsOperator.h:67
GibbsOperator(const IBayesNet< GUM_SCALAR > &BN, const NodeProperty< Idx > *hardEv, Size nbr=1, bool atRandom=false)
constructor
Size nbrDrawnVar() const
Getters and setters.
Definition: gibbsOperator.h:63
Sequence< NodeId > _samplingNodes
Definition: gibbsOperator.h:82
void __drawVarMonteCarlo(NodeId nod, Instantiation *I)
Class representing Bayesian networks.
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
The class for generic Hash Tables.
Definition: hashTable.h:676
const IBayesNet< GUM_SCALAR > & _sampling_bn
Definition: gibbsOperator.h:80
void setDrawnAtRandom(bool atRandom)
Definition: gibbsOperator.h:69
Size _counting
number of samples drawn
Definition: gibbsOperator.h:79
Header of the Potential class.
Instantiation nextSample(Instantiation prev)
draws next sample of Gibbs sampling
Header files of gum::Instantiation.
void __GibbsSample(NodeId id, Instantiation *I)
change in Instantiation I a new drawn value for id
virtual ~GibbsOperator()
Destructor.
const NodeProperty< Idx > * _hardEv
Definition: gibbsOperator.h:81
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:80
Implementation of Gibbs inference methods in Bayesian Networks.
Instantiation monteCarloSample()
draws a Monte Carlo sample
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
void setNbrDrawnVar(Size nbr)
Definition: gibbsOperator.h:65
Size NodeId
Type for node ids.
Definition: graphElements.h:97
class containing all variables and methods required for Gibbssampling
Definition: gibbsOperator.h:47