aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
gibbsOperator.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
41
48
49
50
#ifndef GUM_GIBBS_OPERATOR_H
51
#define GUM_GIBBS_OPERATOR_H
52
53
#include <
agrum/BN/IBayesNet.h
>
54
55
namespace
gum
{
56
65
66
template
< GUM_Numeric GUM_SCALAR >
67
class
GibbsOperator
{
68
public
:
72
GibbsOperator
(
const
IBayesNet< GUM_SCALAR >
& BN,
73
const
NodeProperty< Idx >
* hardEv,
74
Size
nbr = 1,
75
bool
atRandom =
false
);
76
80
virtual
~GibbsOperator
();
81
83
Size
nbrDrawnVar
()
const
;
84
85
void
setNbrDrawnVar
(
Size
nbr);
86
87
bool
isDrawnAtRandom
()
const
;
88
89
void
setDrawnAtRandom
(
bool
atRandom);
90
92
Instantiation
monteCarloSample
();
93
95
Instantiation
nextSample
(
Instantiation
prev);
96
97
protected
:
98
Size
counting_
;
99
const
IBayesNet< GUM_SCALAR >
&
samplingBn_
;
100
const
NodeProperty< Idx >
*
hardEv_
;
101
Sequence< NodeId >
samplingNodes_
;
102
103
Size
nbr_
;
104
bool
atRandom_
;
105
106
void
updateSamplingNodes_
();
107
108
private
:
109
// adds a node to current instantiation
110
void
_drawVarMonteCarlo_
(
NodeId
nod,
Instantiation
* I);
111
112
void
_GibbsSample_
(
NodeId
id
,
Instantiation
* I);
113
};
114
115
116
#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
117
118
extern
template
class
GUM_PUBLIC_BN
GibbsOperator< double >
;
119
120
#endif
121
122
}
// namespace gum
123
124
#include <
agrum/BN/inference/tools/gibbsOperator_tpl.h
>
125
126
#endif
IBayesNet.h
Class representing the minimal interface for Bayesian network with no numerical data.
gum::GibbsOperator::setDrawnAtRandom
void setDrawnAtRandom(bool atRandom)
Definition
gibbsOperator_tpl.h:152
gum::GibbsOperator::nbrDrawnVar
Size nbrDrawnVar() const
Getters and setters.
Definition
gibbsOperator_tpl.h:137
gum::GibbsOperator::_drawVarMonteCarlo_
void _drawVarMonteCarlo_(NodeId nod, Instantiation *I)
Definition
gibbsOperator_tpl.h:103
gum::GibbsOperator::setNbrDrawnVar
void setNbrDrawnVar(Size nbr)
Definition
gibbsOperator_tpl.h:142
gum::GibbsOperator::nbr_
Size nbr_
Definition
gibbsOperator.h:103
gum::GibbsOperator::samplingBn_
const IBayesNet< GUM_SCALAR > & samplingBn_
Definition
gibbsOperator.h:99
gum::GibbsOperator::_GibbsSample_
void _GibbsSample_(NodeId id, Instantiation *I)
change in Instantiation I a new drawn value for id
Definition
gibbsOperator_tpl.h:123
gum::GibbsOperator::nextSample
Instantiation nextSample(Instantiation prev)
draws next sample of Gibbs sampling
Definition
gibbsOperator_tpl.h:110
gum::GibbsOperator::samplingNodes_
Sequence< NodeId > samplingNodes_
Definition
gibbsOperator.h:101
gum::GibbsOperator::monteCarloSample
Instantiation monteCarloSample()
draws a Monte Carlo sample
Definition
gibbsOperator_tpl.h:88
gum::GibbsOperator::hardEv_
const NodeProperty< Idx > * hardEv_
Definition
gibbsOperator.h:100
gum::GibbsOperator::counting_
Size counting_
Definition
gibbsOperator.h:98
gum::GibbsOperator::isDrawnAtRandom
bool isDrawnAtRandom() const
Definition
gibbsOperator_tpl.h:147
gum::GibbsOperator::GibbsOperator
GibbsOperator(const IBayesNet< GUM_SCALAR > &BN, const NodeProperty< Idx > *hardEv, Size nbr=1, bool atRandom=false)
constructor
Definition
gibbsOperator_tpl.h:59
gum::GibbsOperator::updateSamplingNodes_
void updateSamplingNodes_()
Definition
gibbsOperator_tpl.h:73
gum::GibbsOperator::atRandom_
bool atRandom_
Definition
gibbsOperator.h:104
gum::IBayesNet
Class representing the minimal interface for Bayesian network with no numerical data.
Definition
IBayesNet.h:75
gum::Instantiation
Class for assigning/browsing values to tuples of discrete variables.
Definition
instantiation.h:102
gum::Sequence< NodeId >
gibbsOperator_tpl.h
Implementation of Gibbs inference methods in Bayesian networks.
gum::Size
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition
types.h:74
gum::NodeId
Size NodeId
Type for node ids.
Definition
graphElements.h:117
gum::NodeProperty
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Definition
graphElements.h:407
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::GibbsOperator< double >
template class GUM_PUBLIC_BN GibbsOperator< double >
Definition
gibbsOperator.cpp:46
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0