aGrUM  0.13.2
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 58 of file DFSTree.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 205 of file searchStrategy_tpl.h.

205  : _tree(0) {
206  GUM_CONSTRUCTOR(SearchStrategy);
207  }
DFSTree< GUM_SCALAR > * _tree
SearchStrategy()
Default constructor.
template<typename GUM_SCALAR >
INLINE gum::prm::gspan::SearchStrategy< GUM_SCALAR >::SearchStrategy ( const SearchStrategy< GUM_SCALAR > &  from)

Copy constructor.

Definition at line 210 of file searchStrategy_tpl.h.

211  :
212  _tree(from._tree) {
213  GUM_CONS_CPY(SearchStrategy);
214  }
DFSTree< GUM_SCALAR > * _tree
SearchStrategy()
Default constructor.
template<typename GUM_SCALAR >
INLINE gum::prm::gspan::SearchStrategy< GUM_SCALAR >::~SearchStrategy ( )
virtual

Destructor.

Definition at line 217 of file searchStrategy_tpl.h.

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

217  {
218  GUM_DESTRUCTOR(SearchStrategy);
219  }
SearchStrategy()
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)
protected

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>
virtual bool gum::prm::gspan::SearchStrategy< GUM_SCALAR >::accept_growth ( const Pattern parent,
const Pattern child,
const EdgeGrowth< GUM_SCALAR > &  growth 
)
pure virtual
template<typename GUM_SCALAR>
virtual bool gum::prm::gspan::SearchStrategy< GUM_SCALAR >::accept_root ( const Pattern r)
pure virtual
template<typename GUM_SCALAR>
virtual bool gum::prm::gspan::SearchStrategy< GUM_SCALAR >::operator() ( LabelData i,
LabelData j 
)
pure virtual
template<typename GUM_SCALAR>
virtual bool gum::prm::gspan::SearchStrategy< GUM_SCALAR >::operator() ( Pattern i,
Pattern j 
)
pure virtual
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 223 of file searchStrategy_tpl.h.

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

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

223  {
224  this->_tree = from._tree;
225  return *this;
226  }
DFSTree< GUM_SCALAR > * _tree

+ 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)

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: