aGrUM  0.13.2
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 123 of file searchStrategy.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 238 of file searchStrategy_tpl.h.

238  :
239  SearchStrategy< GUM_SCALAR >(), __freq(freq) {
240  GUM_CONSTRUCTOR(FrequenceSearch);
241  }
FrequenceSearch(Size freq)
Default constructor.
template<typename GUM_SCALAR >
INLINE gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::FrequenceSearch ( const FrequenceSearch< GUM_SCALAR > &  from)

Copy constructor.

Definition at line 244 of file searchStrategy_tpl.h.

245  :
246  SearchStrategy< GUM_SCALAR >(from),
247  __freq(from.__freq) {
248  GUM_CONS_CPY(FrequenceSearch);
249  }
FrequenceSearch(Size freq)
Default constructor.
template<typename GUM_SCALAR >
INLINE gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::~FrequenceSearch ( )
virtual

Destructor.

Definition at line 252 of file searchStrategy_tpl.h.

References gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::operator=().

252  {
253  GUM_DESTRUCTOR(FrequenceSearch);
254  }
FrequenceSearch(Size freq)
Default constructor.

+ Here is the call graph for this function:

Member Function Documentation

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

Definition at line 33 of file searchStrategy_tpl.h.

References gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::exists(), and gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::insert().

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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
template<typename GUM_SCALAR >
INLINE bool gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::accept_root ( const Pattern r)
virtual
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 284 of file searchStrategy_tpl.h.

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

285  {
286  return (this->_tree->graph().size(i) > this->_tree->graph().size(j));
287  }
DFSTree< GUM_SCALAR > * _tree
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 277 of file searchStrategy_tpl.h.

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

278  {
279  // We want a descending order
280  return this->_tree->frequency(*i) > this->_tree->frequency(*j);
281  }
DFSTree< GUM_SCALAR > * _tree
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 258 of file searchStrategy_tpl.h.

References gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::__freq.

Referenced by gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::~FrequenceSearch().

258  {
259  __freq = from.__freq;
260  return *this;
261  }

+ Here is the caller graph for this function:

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

Definition at line 230 of file searchStrategy_tpl.h.

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

230  {
231  this->_tree = tree;
232  }
DFSTree< GUM_SCALAR > * _tree

Member Data Documentation


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