aGrUM  0.20.2
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 >:
+ Collaboration diagram for gum::prm::gspan::FrequenceSearch< GUM_SCALAR >:

Public Member Functions

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

Protected Attributes

DFSTree< GUM_SCALAR > * tree_
 

Protected Member Functions

double computeCost_ (const Pattern &p)
 

Detailed Description

template<typename 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 126 of file searchStrategy.h.

Constructor & Destructor Documentation

◆ FrequenceSearch() [1/2]

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

Default constructor.

Definition at line 243 of file searchStrategy_tpl.h.

References gum::prm::gspan::operator<<().

243  :
244  SearchStrategy< GUM_SCALAR >(), freq__(freq) {
245  GUM_CONSTRUCTOR(FrequenceSearch);
246  }
FrequenceSearch(Size freq)
Default constructor.
+ Here is the call graph for this function:

◆ FrequenceSearch() [2/2]

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

Copy constructor.

Definition at line 249 of file searchStrategy_tpl.h.

References gum::prm::gspan::operator<<().

250  :
251  SearchStrategy< GUM_SCALAR >(from),
252  freq__(from.freq__) {
253  GUM_CONS_CPY(FrequenceSearch);
254  }
FrequenceSearch(Size freq)
Default constructor.
+ Here is the call graph for this function:

◆ ~FrequenceSearch()

template<typename GUM_SCALAR >
INLINE gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::~FrequenceSearch ( )
virtual

Destructor.

Definition at line 257 of file searchStrategy_tpl.h.

References gum::prm::gspan::operator<<().

257  {
258  GUM_DESTRUCTOR(FrequenceSearch);
259  }
FrequenceSearch(Size freq)
Default constructor.
+ Here is the call graph for this function:

Member Function Documentation

◆ accept_growth()

template<typename GUM_SCALAR >
INLINE bool gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::accept_growth ( const Pattern parent,
const Pattern child,
const EdgeGrowth< GUM_SCALAR > &  growth 
)
virtual

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

Definition at line 275 of file searchStrategy_tpl.h.

References gum::prm::gspan::operator<<().

278  {
279  return this->tree_->frequency(*child) >= freq__;
280  }
DFSTree< GUM_SCALAR > * tree_
+ Here is the call graph for this function:

◆ accept_root()

template<typename GUM_SCALAR >
INLINE bool gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::accept_root ( const Pattern r)
virtual

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

Definition at line 270 of file searchStrategy_tpl.h.

References gum::prm::gspan::operator<<().

270  {
271  return this->tree_->frequency(*r) >= freq__;
272  }
DFSTree< GUM_SCALAR > * tree_
+ Here is the call graph for this function:

◆ computeCost_()

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

Definition at line 35 of file searchStrategy_tpl.h.

References gum::prm::gspan::operator<<().

35  {
36  double cost = 0;
37  const Sequence< PRMInstance< GUM_SCALAR >* >& seq
38  = *(this->tree_->data(p).iso_map.begin().val());
39  Sequence< PRMClassElement< GUM_SCALAR >* > input_set;
40 
41  for (const auto inst: seq) {
42  for (const auto input: inst->type().slotChains())
43  for (const auto inst2: inst->getInstances(input->id()))
44  if ((!seq.exists(inst2))
45  && (!input_set.exists(
46  &(inst2->get(input->lastElt().safeName()))))) {
47  cost += std::log(input->type().variable().domainSize());
48  input_set.insert(&(inst2->get(input->lastElt().safeName())));
49  }
50 
51  for (auto vec = inst->beginInvRef(); vec != inst->endInvRef(); ++vec)
52  for (const auto inverse: *vec.val())
53  if (!seq.exists(inverse.first)) {
54  cost += std::log(
55  inst->get(vec.key()).type().variable().domainSize());
56  break;
57  }
58  }
59 
60  return cost;
61  }
DFSTree< GUM_SCALAR > * tree_
+ Here is the call graph for this function:

◆ operator()() [1/2]

template<typename GUM_SCALAR >
INLINE bool gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::operator() ( LabelData i,
LabelData j 
)
virtual

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

Definition at line 290 of file searchStrategy_tpl.h.

References gum::prm::gspan::operator<<().

291  {
292  return (this->tree_->graph().size(i) > this->tree_->graph().size(j));
293  }
DFSTree< GUM_SCALAR > * tree_
+ Here is the call graph for this function:

◆ operator()() [2/2]

template<typename GUM_SCALAR >
INLINE bool gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::operator() ( gspan::Pattern i,
gspan::Pattern j 
)
virtual

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

Definition at line 283 of file searchStrategy_tpl.h.

References gum::prm::gspan::operator<<().

284  {
285  // We want a descending order
286  return this->tree_->frequency(*i) > this->tree_->frequency(*j);
287  }
DFSTree< GUM_SCALAR > * tree_
+ Here is the call graph for this function:

◆ operator=()

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

Copy operator.

Definition at line 263 of file searchStrategy_tpl.h.

References gum::prm::gspan::operator<<().

264  {
265  freq__ = from.freq__;
266  return *this;
267  }
+ Here is the call graph for this function:

◆ setTree()

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

Definition at line 235 of file searchStrategy_tpl.h.

References gum::prm::gspan::operator<<().

235  {
236  this->tree_ = tree;
237  }
DFSTree< GUM_SCALAR > * tree_
+ Here is the call graph for this function:

Member Data Documentation

◆ freq__

template<typename GUM_SCALAR >
Size gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::freq__
private

Definition at line 162 of file searchStrategy.h.

◆ tree_

template<typename GUM_SCALAR >
DFSTree< GUM_SCALAR >* gum::prm::gspan::SearchStrategy< GUM_SCALAR >::tree_
protectedinherited

Definition at line 112 of file searchStrategy.h.


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