25 #ifndef DOXYGEN_SHOULD_SKIP_THIS 33 template <
template <
typename >
class ALLOC >
35 const DatabaseTable< ALLOC >& database,
36 const Bijection<
NodeId, std::size_t, ALLOC< std::size_t > >&
39 Apriori< ALLOC >(database, nodeId2columns, alloc) {
45 template <
template <
typename >
class ALLOC >
47 const AprioriBDeu< ALLOC >& from,
55 template <
template <
typename >
class ALLOC >
61 template <
template <
typename >
class ALLOC >
63 AprioriBDeu< ALLOC >&& from,
71 template <
template <
typename >
class ALLOC >
77 template <
template <
typename >
class ALLOC >
80 ALLOC< AprioriBDeu< ALLOC > > allocator(alloc);
81 AprioriBDeu< ALLOC >* apriori = allocator.allocate(1);
83 allocator.construct(apriori, *
this, alloc);
85 allocator.deallocate(apriori, 1);
94 template <
template <
typename >
class ALLOC >
101 template <
template <
typename >
class ALLOC >
108 template <
template <
typename >
class ALLOC >
110 operator=(
const AprioriBDeu< ALLOC >& from) {
117 template <
template <
typename >
class ALLOC >
126 template <
template <
typename >
class ALLOC >
130 "A negative weight (" << weight
131 <<
") is forbidden for the BDeu apriori");
138 template <
template <
typename >
class ALLOC >
145 template <
template <
typename >
class ALLOC >
152 template <
template <
typename >
class ALLOC >
159 template <
template <
typename >
class ALLOC >
166 template <
template <
typename >
class ALLOC >
168 const IdSet< ALLOC >& idset,
169 std::vector<
double, ALLOC< double > >& counts) {
171 if (idset.empty() || (this->
_weight == 0.0))
return;
174 const double weight = this->
_weight / counts.size();
175 for (
auto& count : counts)
181 template <
template <
typename >
class ALLOC >
183 const IdSet< ALLOC >& idset,
184 std::vector<
double, ALLOC< double > >& counts) {
187 if ((idset.size() == idset.nbLHSIds()) || (this->
_weight == 0.0)
188 || (idset.nbLHSIds() == std::size_t(0)))
192 const double weight = this->
_weight / counts.size();
193 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
gum is the global namespace for all aGrUM entities
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'