aGrUM
0.20.2
a C++ library for (probabilistic) graphical models
aprioriNoApriori_tpl.h
Go to the documentation of this file.
1
/**
2
*
3
* Copyright 2005-2020 Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4
* info_at_agrum_dot_org
5
*
6
* This library is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this library. If not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
22
/** @file
23
* @brief the no a priori class: corresponds to 0 weight-sample
24
*
25
* @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26
*/
27
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
28
29
namespace
gum
{
30
31
namespace
learning
{
32
33
34
/// default constructor
35
template
<
template
<
typename
>
class
ALLOC >
36
INLINE AprioriNoApriori<
ALLOC
>::
AprioriNoApriori
(
37
const
DatabaseTable
<
ALLOC
>&
database
,
38
const
Bijection
<
NodeId
,
std
::
size_t
,
ALLOC
<
std
::
size_t
> >&
39
nodeId2columns
,
40
const
typename
AprioriNoApriori
<
ALLOC
>::
allocator_type
&
alloc
) :
41
Apriori
<
ALLOC
>(
database
,
nodeId2columns
,
alloc
) {
42
Apriori
<
ALLOC
>::
setWeight
(0.0);
43
GUM_CONSTRUCTOR
(
AprioriNoApriori
);
44
}
45
46
47
/// copy constructor with a given allocator
48
template
<
template
<
typename
>
class
ALLOC
>
49
INLINE
AprioriNoApriori
<
ALLOC
>::
AprioriNoApriori
(
50
const
AprioriNoApriori
<
ALLOC
>&
from
,
51
const
typename
AprioriNoApriori
<
ALLOC
>::
allocator_type
&
alloc
) :
52
Apriori
<
ALLOC
>(
from
,
alloc
) {
53
GUM_CONS_CPY
(
AprioriNoApriori
);
54
}
55
56
57
/// copy constructor
58
template
<
template
<
typename
>
class
ALLOC
>
59
INLINE
AprioriNoApriori
<
ALLOC
>::
AprioriNoApriori
(
60
const
AprioriNoApriori
<
ALLOC
>&
from
) :
61
AprioriNoApriori
<
ALLOC
>(
from
,
from
.
getAllocator
()) {}
62
63
64
/// move constructor with a given allocator
65
template
<
template
<
typename
>
class
ALLOC
>
66
INLINE
AprioriNoApriori
<
ALLOC
>::
AprioriNoApriori
(
67
AprioriNoApriori
<
ALLOC
>&&
from
,
68
const
typename
AprioriNoApriori
<
ALLOC
>::
allocator_type
&
alloc
) :
69
Apriori
<
ALLOC
>(
std
::
move
(
from
),
alloc
) {
70
GUM_CONS_MOV
(
AprioriNoApriori
);
71
}
72
73
74
/// move constructor
75
template
<
template
<
typename
>
class
ALLOC
>
76
INLINE
AprioriNoApriori
<
ALLOC
>::
AprioriNoApriori
(
77
AprioriNoApriori
<
ALLOC
>&&
from
) :
78
AprioriNoApriori
<
ALLOC
>(
std
::
move
(
from
),
from
.
getAllocator
()) {}
79
80
81
/// virtual copy constructor with a given allocator
82
template
<
template
<
typename
>
class
ALLOC
>
83
AprioriNoApriori
<
ALLOC
>*
AprioriNoApriori
<
ALLOC
>::
clone
(
84
const
typename
AprioriNoApriori
<
ALLOC
>::
allocator_type
&
alloc
)
const
{
85
ALLOC
<
AprioriNoApriori
<
ALLOC
> >
allocator
(
alloc
);
86
AprioriNoApriori
<
ALLOC
>*
apriori
=
allocator
.
allocate
(1);
87
try
{
88
allocator
.
construct
(
apriori
, *
this
,
alloc
);
89
}
catch
(...) {
90
allocator
.
deallocate
(
apriori
, 1);
91
throw
;
92
}
93
94
return
apriori
;
95
}
96
97
98
/// virtual copy constructor
99
template
<
template
<
typename
>
class
ALLOC
>
100
INLINE
AprioriNoApriori
<
ALLOC
>*
AprioriNoApriori
<
ALLOC
>::
clone
()
const
{
101
return
clone
(
this
->
getAllocator
());
102
}
103
104
105
/// destructor
106
template
<
template
<
typename
>
class
ALLOC
>
107
INLINE
AprioriNoApriori
<
ALLOC
>::~
AprioriNoApriori
() {
108
GUM_DESTRUCTOR
(
AprioriNoApriori
);
109
}
110
111
112
/// copy operator
113
template
<
template
<
typename
>
class
ALLOC
>
114
INLINE
AprioriNoApriori
<
ALLOC
>&
AprioriNoApriori
<
ALLOC
>::
operator
=(
115
const
AprioriNoApriori
<
ALLOC
>&
from
) {
116
Apriori
<
ALLOC
>::
operator
=(
from
);
117
return
*
this
;
118
}
119
120
121
/// move operator
122
template
<
template
<
typename
>
class
ALLOC
>
123
INLINE
AprioriNoApriori
<
ALLOC
>&
124
AprioriNoApriori
<
ALLOC
>::
operator
=(
AprioriNoApriori
<
ALLOC
>&&
from
) {
125
Apriori
<
ALLOC
>::
operator
=(
std
::
move
(
from
));
126
return
*
this
;
127
}
128
129
130
/// sets the weight of the a priori
131
template
<
template
<
typename
>
class
ALLOC
>
132
INLINE
void
AprioriNoApriori
<
ALLOC
>::
setWeight
(
const
double
) {}
133
134
135
/// indicates whether an apriori is of a certain type
136
template
<
template
<
typename
>
class
ALLOC
>
137
INLINE
bool
AprioriNoApriori
<
ALLOC
>::
isOfType
(
const
std
::
string
&
type
) {
138
return
AprioriNoAprioriType
::
isOfType
(
type
);
139
}
140
141
142
/// returns the type of the apriori
143
template
<
template
<
typename
>
class
ALLOC
>
144
INLINE
const
std
::
string
&
AprioriNoApriori
<
ALLOC
>::
getType
()
const
{
145
return
AprioriNoAprioriType
::
type
;
146
}
147
148
149
/// indicates whether the apriori is potentially informative
150
template
<
template
<
typename
>
class
ALLOC
>
151
INLINE
bool
AprioriNoApriori
<
ALLOC
>::
isInformative
()
const
{
152
return
false
;
153
}
154
155
156
/// returns the apriori vector all the variables in the idset
157
template
<
template
<
typename
>
class
ALLOC
>
158
INLINE
void
AprioriNoApriori
<
ALLOC
>::
addAllApriori
(
159
const
IdCondSet
<
ALLOC
>&
idset
,
160
std
::
vector
<
double
,
ALLOC
<
double
> >&
counts
) {}
161
162
163
/// returns the apriori vector over only the conditioning set of an idset
164
template
<
template
<
typename
>
class
ALLOC
>
165
INLINE
void
AprioriNoApriori
<
ALLOC
>::
addConditioningApriori
(
166
const
IdCondSet
<
ALLOC
>&
idset
,
167
std
::
vector
<
double
,
ALLOC
<
double
> >&
counts
) {}
168
169
170
}
/* namespace learning */
171
172
}
/* namespace gum */
173
174
#
endif
/* DOXYGEN_SHOULD_SKIP_THIS */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:669
gum::learning::genericBNLearner::Database::Database
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
Definition:
genericBNLearner_tpl.h:31