aGrUM  0.16.0
gum::prm::gspan::SearchStrategy< GUM_SCALAR > Class Template Referenceabstract

This is an abstract class used to tune search strategies in the gspan algorithm. More...

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

+ Inheritance diagram for gum::prm::gspan::SearchStrategy< GUM_SCALAR >:

Public Member Functions

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

Protected Attributes

DFSTree< GUM_SCALAR > * _tree
 

Protected Member Functions

double _computeCost (const Pattern &p)
 

Detailed Description

template<typename GUM_SCALAR>
class gum::prm::gspan::SearchStrategy< GUM_SCALAR >

This is an abstract class used to tune search strategies in the gspan algorithm.

Since GSpan uses a DFS to expand the search tree, this class works as a stack regarding adding and removing informations about the growths.

Definition at line 61 of file DFSTree.h.

Constructor & Destructor Documentation

◆ SearchStrategy() [1/2]

template<typename GUM_SCALAR >
INLINE gum::prm::gspan::SearchStrategy< GUM_SCALAR >::SearchStrategy ( )

Default constructor.

Definition at line 208 of file searchStrategy_tpl.h.

208  : _tree(0) {
209  GUM_CONSTRUCTOR(SearchStrategy);
210  }
DFSTree< GUM_SCALAR > * _tree
SearchStrategy()
Default constructor.

◆ SearchStrategy() [2/2]

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

Copy constructor.

Definition at line 213 of file searchStrategy_tpl.h.

214  :
215  _tree(from._tree) {
216  GUM_CONS_CPY(SearchStrategy);
217  }
DFSTree< GUM_SCALAR > * _tree
SearchStrategy()
Default constructor.

◆ ~SearchStrategy()

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

Destructor.

Definition at line 220 of file searchStrategy_tpl.h.

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

220  {
221  GUM_DESTRUCTOR(SearchStrategy);
222  }
SearchStrategy()
Default constructor.
+ Here is the call graph for this function:

Member Function Documentation

◆ _computeCost()

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

Definition at line 36 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().

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

◆ accept_growth()

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

◆ accept_root()

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

◆ operator()() [1/2]

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

◆ operator()() [2/2]

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

◆ operator=()

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

Copy operator.

Definition at line 226 of file searchStrategy_tpl.h.

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

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

226  {
227  this->_tree = from._tree;
228  return *this;
229  }
DFSTree< GUM_SCALAR > * _tree
+ Here is the caller graph for this function:

◆ setTree()

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

Definition at line 233 of file searchStrategy_tpl.h.

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

233  {
234  this->_tree = tree;
235  }
DFSTree< GUM_SCALAR > * _tree

Member Data Documentation

◆ _tree


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