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 AprioriSmoothing< ALLOC >& from,
58 template <
template <
typename >
class ALLOC >
60 const AprioriSmoothing< ALLOC >& from) :
65 template <
template <
typename >
class ALLOC >
67 AprioriSmoothing< ALLOC >&& from,
75 template <
template <
typename >
class ALLOC >
77 AprioriSmoothing< ALLOC >&& from) :
82 template <
template <
typename >
class ALLOC >
85 ALLOC< AprioriSmoothing< ALLOC > > allocator(alloc);
86 AprioriSmoothing< ALLOC >* apriori = allocator.allocate(1);
88 allocator.construct(apriori, *
this, alloc);
90 allocator.deallocate(apriori, 1);
99 template <
template <
typename >
class ALLOC >
106 template <
template <
typename >
class ALLOC >
113 template <
template <
typename >
class ALLOC >
115 const AprioriSmoothing< ALLOC >& from) {
122 template <
template <
typename >
class ALLOC >
123 INLINE AprioriSmoothing< ALLOC >&
131 template <
template <
typename >
class ALLOC >
138 template <
template <
typename >
class ALLOC >
145 template <
template <
typename >
class ALLOC >
152 template <
template <
typename >
class ALLOC >
154 const IdCondSet< ALLOC >& idset,
155 std::vector<
double, ALLOC< double > >& counts) {
157 if (idset.empty() || (this->
_weight == 0.0))
return;
160 for (
auto& count: counts)
166 template <
template <
typename >
class ALLOC >
168 const IdCondSet< ALLOC >& idset,
169 std::vector<
double, ALLOC< double > >& counts) {
172 if ((idset.size() == idset.nbLHSIds()) || (this->
_weight == 0.0)
173 || (idset.nbLHSIds() == std::size_t(0)))
179 for (std::size_t i = std::size_t(0); i < idset.nbLHSIds(); ++i) {
180 weight *= this->
_database->domainSize(idset[i]);
183 for (std::size_t i = std::size_t(0); i < idset.nbLHSIds(); ++i) {
190 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
virtual void addConditioningApriori(const IdCondSet< ALLOC > &idset, std::vector< double, ALLOC< double > > &counts) final
adds the apriori to a counting vectordefined over the right hand side of the idset ...
Copyright 2005-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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 ...
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
virtual void addAllApriori(const IdCondSet< ALLOC > &idset, std::vector< double, ALLOC< double > > &counts) final
adds the apriori to a counting vector corresponding to the idset
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