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 AprioriSmoothing< ALLOC >& from,
55 template <
template <
typename >
class ALLOC >
57 const AprioriSmoothing< ALLOC >& from) :
62 template <
template <
typename >
class ALLOC >
64 AprioriSmoothing< ALLOC >&& from,
72 template <
template <
typename >
class ALLOC >
74 AprioriSmoothing< ALLOC >&& from) :
79 template <
template <
typename >
class ALLOC >
82 ALLOC< AprioriSmoothing< ALLOC > > allocator(alloc);
83 AprioriSmoothing< ALLOC >* apriori = allocator.allocate(1);
85 allocator.construct(apriori, *
this, alloc);
87 allocator.deallocate(apriori, 1);
96 template <
template <
typename >
class ALLOC >
103 template <
template <
typename >
class ALLOC >
110 template <
template <
typename >
class ALLOC >
112 operator=(
const AprioriSmoothing< ALLOC >& from) {
119 template <
template <
typename >
class ALLOC >
121 operator=(AprioriSmoothing< ALLOC >&& from) {
128 template <
template <
typename >
class ALLOC >
135 template <
template <
typename >
class ALLOC >
142 template <
template <
typename >
class ALLOC >
149 template <
template <
typename >
class ALLOC >
151 const IdSet< ALLOC >& idset,
152 std::vector<
double, ALLOC< double > >& counts) {
154 if (idset.empty() || (this->
_weight == 0.0))
return;
157 for (
auto& count : counts)
163 template <
template <
typename >
class ALLOC >
165 const IdSet< ALLOC >& idset,
166 std::vector<
double, ALLOC< double > >& counts) {
169 if ((idset.size() == idset.nbLHSIds()) || (this->
_weight == 0.0)
170 || (idset.nbLHSIds() == std::size_t(0)))
176 for (std::size_t i = std::size_t(0); i < idset.nbLHSIds(); ++i) {
177 weight *= this->
_database->domainSize(idset[i]);
180 for (std::size_t i = std::size_t(0); i < idset.nbLHSIds(); ++i) {
187 for (
auto& count : counts)
const T2 & second(const T1 &first) const
Returns the second value of a pair given its first value.
static const std::string type
gum is the global namespace for all aGrUM entities
virtual bool isOfType(const std::string &type) final
indicates whether an apriori is of a certain type
virtual bool isInformative() const final
indicates whether the apriori is potentially informative
const DatabaseTable< ALLOC > * _database
a reference to the database in order to have access to its variables
virtual AprioriSmoothing< ALLOC > * clone() const
virtual copy constructor
virtual ~AprioriSmoothing()
destructor
bool empty() const noexcept
Returns true if the gum::Bijection doesn't contain any association.
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
double weight() const
returns the weight assigned to the apriori
virtual const std::string & getType() const final
returns the type of the apriori
double _weight
the weight of the apriori
Apriori< ALLOC > & operator=(const Apriori< ALLOC > &from)
copy operator
static bool isOfType(const std::string &t)
AprioriSmoothingType type
the type of the a priori
allocator_type getAllocator() const
returns the allocator used by the internal apriori
AprioriSmoothing< ALLOC > & operator=(const AprioriSmoothing< ALLOC > &from)
copy operator
Bijection< NodeId, std::size_t, ALLOC< std::size_t > > _nodeId2columns
a mapping from the NodeIds of the variables to the indices of the columns in the database ...
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
AprioriSmoothing(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
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
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 ...