28 #ifndef DOXYGEN_SHOULD_SKIP_THIS 36 template <
template <
typename >
class ALLOC >
38 const DatabaseTable< ALLOC >& database,
39 const Bijection<
NodeId, std::size_t, ALLOC< std::size_t > >&
42 Apriori< ALLOC >(database, nodeId2columns, alloc) {
48 template <
template <
typename >
class ALLOC >
50 const AprioriBDeu< ALLOC >& from,
58 template <
template <
typename >
class ALLOC >
64 template <
template <
typename >
class ALLOC >
66 AprioriBDeu< ALLOC >&& from,
74 template <
template <
typename >
class ALLOC >
80 template <
template <
typename >
class ALLOC >
83 ALLOC< AprioriBDeu< ALLOC > > allocator(alloc);
84 AprioriBDeu< ALLOC >* apriori = allocator.allocate(1);
86 allocator.construct(apriori, *
this, alloc);
88 allocator.deallocate(apriori, 1);
97 template <
template <
typename >
class ALLOC >
104 template <
template <
typename >
class ALLOC >
111 template <
template <
typename >
class ALLOC >
113 operator=(
const AprioriBDeu< ALLOC >& from) {
120 template <
template <
typename >
class ALLOC >
129 template <
template <
typename >
class ALLOC >
133 "A negative weight (" << weight
134 <<
") is forbidden for the BDeu apriori");
141 template <
template <
typename >
class ALLOC >
148 template <
template <
typename >
class ALLOC >
155 template <
template <
typename >
class ALLOC >
162 template <
template <
typename >
class ALLOC >
169 template <
template <
typename >
class ALLOC >
171 const IdSet< ALLOC >& idset,
172 std::vector<
double, ALLOC< double > >& counts) {
174 if (idset.empty() || (this->
_weight == 0.0))
return;
177 const double weight = this->
_weight / counts.size();
178 for (
auto& count : counts)
184 template <
template <
typename >
class ALLOC >
186 const IdSet< ALLOC >& idset,
187 std::vector<
double, ALLOC< double > >& counts) {
190 if ((idset.size() == idset.nbLHSIds()) || (this->
_weight == 0.0)
191 || (idset.nbLHSIds() == std::size_t(0)))
195 const double weight = this->
_weight / counts.size();
196 for (
auto& count : counts)
virtual void addConditioningApriori(const IdSet< ALLOC > &idset, std::vector< double, ALLOC< double > > &counts) final
adds the apriori to a counting vectordefined over the right hand side of the idset ...
virtual AprioriBDeu< ALLOC > * clone() const
virtual copy constructor
AprioriBDeu< ALLOC > & operator=(const AprioriBDeu< ALLOC > &from)
copy operator
virtual ~AprioriBDeu()
destructor
virtual const std::string & getType() const final
returns the type of the apriori
static const std::string type
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void setWeight(const double weight) final
sets the effective sample size N' (alias of setEffectiveSampleSize ())
virtual void addAllApriori(const IdSet< ALLOC > &idset, std::vector< double, ALLOC< double > > &counts) final
adds the apriori to a counting vector corresponding to the idset
double weight() const
returns the weight assigned to the apriori
virtual bool isInformative() const final
indicates whether the apriori is potentially informative
double _weight
the weight of the apriori
Apriori< ALLOC > & operator=(const Apriori< ALLOC > &from)
copy operator
static bool isOfType(const std::string &t)
allocator_type getAllocator() const
returns the allocator used by the internal apriori
virtual bool isOfType(const std::string &type) final
indicates whether an apriori is of a certain type
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Size NodeId
Type for node ids.
Apriori(const DatabaseTable< ALLOC > &database, const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > &nodeId2columns=Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(), const allocator_type &alloc=allocator_type())
default constructor
AprioriBDeuType type
the type of the a priori
#define GUM_ERROR(type, msg)
AprioriBDeu(const DatabaseTable< ALLOC > &database, const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > &nodeId2columns=Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(), const allocator_type &alloc=allocator_type())
default constructor
void setEffectiveSampleSize(const double weight)
sets the effective sample size N'