aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
aprioriNoApriori_tpl.h
Go to the documentation of this file.
1
/**
2
*
3
* Copyright (c) 2005-2021 by 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
> >&
nodeId2columns
,
39
const
typename
AprioriNoApriori
<
ALLOC
>::
allocator_type
&
alloc
) :
40
Apriori
<
ALLOC
>(
database
,
nodeId2columns
,
alloc
) {
41
Apriori
<
ALLOC
>::
setWeight
(0.0);
42
GUM_CONSTRUCTOR
(
AprioriNoApriori
);
43
}
44
45
46
/// copy constructor with a given allocator
47
template
<
template
<
typename
>
class
ALLOC
>
48
INLINE
AprioriNoApriori
<
ALLOC
>::
AprioriNoApriori
(
49
const
AprioriNoApriori
<
ALLOC
>&
from
,
50
const
typename
AprioriNoApriori
<
ALLOC
>::
allocator_type
&
alloc
) :
51
Apriori
<
ALLOC
>(
from
,
alloc
) {
52
GUM_CONS_CPY
(
AprioriNoApriori
);
53
}
54
55
56
/// copy constructor
57
template
<
template
<
typename
>
class
ALLOC
>
58
INLINE
AprioriNoApriori
<
ALLOC
>::
AprioriNoApriori
(
const
AprioriNoApriori
<
ALLOC
>&
from
) :
59
AprioriNoApriori
<
ALLOC
>(
from
,
from
.
getAllocator
()) {}
60
61
62
/// move constructor with a given allocator
63
template
<
template
<
typename
>
class
ALLOC
>
64
INLINE
AprioriNoApriori
<
ALLOC
>::
AprioriNoApriori
(
65
AprioriNoApriori
<
ALLOC
>&&
from
,
66
const
typename
AprioriNoApriori
<
ALLOC
>::
allocator_type
&
alloc
) :
67
Apriori
<
ALLOC
>(
std
::
move
(
from
),
alloc
) {
68
GUM_CONS_MOV
(
AprioriNoApriori
);
69
}
70
71
72
/// move constructor
73
template
<
template
<
typename
>
class
ALLOC
>
74
INLINE
AprioriNoApriori
<
ALLOC
>::
AprioriNoApriori
(
AprioriNoApriori
<
ALLOC
>&&
from
) :
75
AprioriNoApriori
<
ALLOC
>(
std
::
move
(
from
),
from
.
getAllocator
()) {}
76
77
78
/// virtual copy constructor with a given allocator
79
template
<
template
<
typename
>
class
ALLOC
>
80
AprioriNoApriori
<
ALLOC
>*
AprioriNoApriori
<
ALLOC
>::
clone
(
81
const
typename
AprioriNoApriori
<
ALLOC
>::
allocator_type
&
alloc
)
const
{
82
ALLOC
<
AprioriNoApriori
<
ALLOC
> >
allocator
(
alloc
);
83
AprioriNoApriori
<
ALLOC
>*
apriori
=
allocator
.
allocate
(1);
84
try
{
85
allocator
.
construct
(
apriori
, *
this
,
alloc
);
86
}
catch
(...) {
87
allocator
.
deallocate
(
apriori
, 1);
88
throw
;
89
}
90
91
return
apriori
;
92
}
93
94
95
/// virtual copy constructor
96
template
<
template
<
typename
>
class
ALLOC
>
97
INLINE
AprioriNoApriori
<
ALLOC
>*
AprioriNoApriori
<
ALLOC
>::
clone
()
const
{
98
return
clone
(
this
->
getAllocator
());
99
}
100
101
102
/// destructor
103
template
<
template
<
typename
>
class
ALLOC
>
104
INLINE
AprioriNoApriori
<
ALLOC
>::~
AprioriNoApriori
() {
105
GUM_DESTRUCTOR
(
AprioriNoApriori
);
106
}
107
108
109
/// copy operator
110
template
<
template
<
typename
>
class
ALLOC
>
111
INLINE
AprioriNoApriori
<
ALLOC
>&
112
AprioriNoApriori
<
ALLOC
>::
operator
=(
const
AprioriNoApriori
<
ALLOC
>&
from
) {
113
Apriori
<
ALLOC
>::
operator
=(
from
);
114
return
*
this
;
115
}
116
117
118
/// move operator
119
template
<
template
<
typename
>
class
ALLOC
>
120
INLINE
AprioriNoApriori
<
ALLOC
>&
121
AprioriNoApriori
<
ALLOC
>::
operator
=(
AprioriNoApriori
<
ALLOC
>&&
from
) {
122
Apriori
<
ALLOC
>::
operator
=(
std
::
move
(
from
));
123
return
*
this
;
124
}
125
126
127
/// sets the weight of the a priori
128
template
<
template
<
typename
>
class
ALLOC
>
129
INLINE
void
AprioriNoApriori
<
ALLOC
>::
setWeight
(
const
double
) {}
130
131
132
/// indicates whether an apriori is of a certain type
133
template
<
template
<
typename
>
class
ALLOC
>
134
INLINE
bool
AprioriNoApriori
<
ALLOC
>::
isOfType
(
const
std
::
string
&
type
) {
135
return
AprioriNoAprioriType
::
isOfType
(
type
);
136
}
137
138
139
/// returns the type of the apriori
140
template
<
template
<
typename
>
class
ALLOC
>
141
INLINE
const
std
::
string
&
AprioriNoApriori
<
ALLOC
>::
getType
()
const
{
142
return
AprioriNoAprioriType
::
type
;
143
}
144
145
146
/// indicates whether the apriori is potentially informative
147
template
<
template
<
typename
>
class
ALLOC
>
148
INLINE
bool
AprioriNoApriori
<
ALLOC
>::
isInformative
()
const
{
149
return
false
;
150
}
151
152
153
/// returns the apriori vector all the variables in the idset
154
template
<
template
<
typename
>
class
ALLOC
>
155
INLINE
void
156
AprioriNoApriori
<
ALLOC
>::
addAllApriori
(
const
IdCondSet
<
ALLOC
>&
idset
,
157
std
::
vector
<
double
,
ALLOC
<
double
> >&
counts
) {}
158
159
160
/// returns the apriori vector over only the conditioning set of an idset
161
template
<
template
<
typename
>
class
ALLOC
>
162
INLINE
void
AprioriNoApriori
<
ALLOC
>::
addConditioningApriori
(
163
const
IdCondSet
<
ALLOC
>&
idset
,
164
std
::
vector
<
double
,
ALLOC
<
double
> >&
counts
) {}
165
166
167
}
/* namespace learning */
168
169
}
/* namespace gum */
170
171
#
endif
/* DOXYGEN_SHOULD_SKIP_THIS */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:643
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