aGrUM 3.2.0
a C++ library for (probabilistic) graphical models
gum::prm::gspan::FrequenceSearch< GUM_SCALAR > Class Template Reference

This is class is an implementation of a simple serach strategy for the gspan algorithm: it accept a growth if its frequency is above a user defined value. More...

#include <agrum/PRM/gspan/DFSTree.h>

Inheritance diagram for gum::prm::gspan::FrequenceSearch< GUM_SCALAR >:
[legend]
Collaboration diagram for gum::prm::gspan::FrequenceSearch< GUM_SCALAR >:
[legend]

Public Member Functions

Constructor and destructor.
 FrequenceSearch (Size freq)
 Default constructor.
 FrequenceSearch (const FrequenceSearch &from)
 Copy constructor.
 ~FrequenceSearch () override
 Destructor.
FrequenceSearch & operator= (const FrequenceSearch &from)
 Copy operator.
Search methods.
bool accept_root (const Pattern *r) override
bool accept_growth (const Pattern *parent, const Pattern *child, const EdgeGrowth< GUM_SCALAR > &growth) override
bool operator() (LabelData *i, LabelData *j) override
bool operator() (Pattern *i, Pattern *j) override
Search methods.
void setTree (DFSTree< GUM_SCALAR > *tree)

Protected Member Functions

double computeCost_ (const Pattern &p)

Protected Attributes

DFSTree< GUM_SCALAR > * tree_

Private Attributes

Size _freq_

Detailed Description

template<GUM_Numeric GUM_SCALAR>
class gum::prm::gspan::FrequenceSearch< GUM_SCALAR >

This is class is an implementation of a simple serach strategy for the gspan algorithm: it accept a growth if its frequency is above a user defined value.

Definition at line 133 of file searchStrategy.h.

Constructor & Destructor Documentation

◆ FrequenceSearch() [1/2]

template<GUM_Numeric GUM_SCALAR>
gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::FrequenceSearch ( Size freq)
explicit

Default constructor.

Definition at line 244 of file searchStrategy_tpl.h.

244 :
247 }
This is class is an implementation of a simple serach strategy for the gspan algorithm: it accept a g...
FrequenceSearch(Size freq)
Default constructor.

References FrequenceSearch(), gum::prm::gspan::SearchStrategy< GUM_SCALAR >::SearchStrategy(), and _freq_.

Referenced by gum::prm::gspan::DFSTree< GUM_SCALAR >::DFSTree(), FrequenceSearch(), FrequenceSearch(), ~FrequenceSearch(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FrequenceSearch() [2/2]

template<GUM_Numeric GUM_SCALAR>
gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::FrequenceSearch ( const FrequenceSearch< GUM_SCALAR > & from)

Copy constructor.

Definition at line 250 of file searchStrategy_tpl.h.

References FrequenceSearch(), gum::prm::gspan::SearchStrategy< GUM_SCALAR >::SearchStrategy(), and _freq_.

Here is the call graph for this function:

◆ ~FrequenceSearch()

template<GUM_Numeric GUM_SCALAR>
gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::~FrequenceSearch ( )
override

Destructor.

Definition at line 256 of file searchStrategy_tpl.h.

256 {
258 }

References FrequenceSearch().

Here is the call graph for this function:

Member Function Documentation

◆ accept_growth()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::accept_growth ( const Pattern * parent,
const Pattern * child,
const EdgeGrowth< GUM_SCALAR > & growth )
overridevirtual

Implements gum::prm::gspan::SearchStrategy< GUM_SCALAR >.

Definition at line 273 of file searchStrategy_tpl.h.

275 {
276 return this->tree_->frequency(*child) >= _freq_;
277 }
DFSTree< GUM_SCALAR > * tree_

References _freq_, and gum::prm::gspan::SearchStrategy< GUM_SCALAR >::tree_.

◆ accept_root()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::accept_root ( const Pattern * r)
overridevirtual

Implements gum::prm::gspan::SearchStrategy< GUM_SCALAR >.

Definition at line 268 of file searchStrategy_tpl.h.

268 {
269 return this->tree_->frequency(*r) >= _freq_;
270 }

References _freq_, and gum::prm::gspan::SearchStrategy< GUM_SCALAR >::tree_.

◆ computeCost_()

template<GUM_Numeric GUM_SCALAR>
double gum::prm::gspan::SearchStrategy< GUM_SCALAR >::computeCost_ ( const Pattern & p)
protectedinherited

Definition at line 57 of file searchStrategy_tpl.h.

57 {
58 double cost = 0;
60 = *(this->tree_->data(p).iso_map.begin().val());
62
63 for (const auto inst: seq) {
64 for (const auto input: inst->type().slotChains())
65 for (const auto inst2: inst->getInstances(input->id()))
66 if ((!seq.exists(inst2))
67 && (!input_set.exists(&(inst2->get(input->lastElt().safeName()))))) {
68 cost += std::log(input->type().variable().domainSize());
69 input_set.insert(&(inst2->get(input->lastElt().safeName())));
70 }
71
72 for (auto vec = inst->beginInvRef(); vec != inst->endInvRef(); ++vec)
73 for (const auto& inverse: *vec.val())
74 if (!seq.exists(inverse.first)) {
75 cost += std::log(inst->get(vec.key()).type().variable().domainSize());
76 break;
77 }
78 }
79
80 return cost;
81 }
This is an abstract class used to tune search strategies in the gspan algorithm.

References gum::SequenceImplementation< Key, Gen >::exists(), gum::SequenceImplementation< Key, Gen >::insert(), and tree_.

Referenced by gum::prm::gspan::StrictSearch< GUM_SCALAR >::_compute_costs_(), and gum::prm::gspan::TreeWidthSearch< GUM_SCALAR >::cost().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator()() [1/2]

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::operator() ( LabelData * i,
LabelData * j )
overridevirtual

Implements gum::prm::gspan::SearchStrategy< GUM_SCALAR >.

Definition at line 286 of file searchStrategy_tpl.h.

286 {
287 return (this->tree_->internalGraph().size(i) > this->tree_->internalGraph().size(j));
288 }

References gum::prm::gspan::SearchStrategy< GUM_SCALAR >::tree_.

◆ operator()() [2/2]

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::operator() ( gspan::Pattern * i,
gspan::Pattern * j )
overridevirtual

Implements gum::prm::gspan::SearchStrategy< GUM_SCALAR >.

Definition at line 280 of file searchStrategy_tpl.h.

280 {
281 // We want a descending order
282 return this->tree_->frequency(*i) > this->tree_->frequency(*j);
283 }

References gum::prm::gspan::SearchStrategy< GUM_SCALAR >::tree_.

◆ operator=()

template<GUM_Numeric GUM_SCALAR>
FrequenceSearch< GUM_SCALAR > & gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::operator= ( const FrequenceSearch< GUM_SCALAR > & from)

Copy operator.

Definition at line 262 of file searchStrategy_tpl.h.

262 {
264 return *this;
265 }

References FrequenceSearch(), and _freq_.

Here is the call graph for this function:

◆ setTree()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::gspan::SearchStrategy< GUM_SCALAR >::setTree ( DFSTree< GUM_SCALAR > * tree)
inherited

Definition at line 236 of file searchStrategy_tpl.h.

236 {
237 this->tree_ = tree;
238 }

References tree_.

Referenced by operator=().

Here is the caller graph for this function:

Member Data Documentation

◆ _freq_

template<GUM_Numeric GUM_SCALAR>
Size gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::_freq_
private

◆ tree_


The documentation for this class was generated from the following files: