aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
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 60 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 195 of file searchStrategy_tpl.h.

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

195  : tree_(0) {
196  GUM_CONSTRUCTOR(SearchStrategy);
197  }
DFSTree< GUM_SCALAR > * tree_
SearchStrategy()
Default constructor.
+ Here is the call graph for this function:

◆ 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 201 of file searchStrategy_tpl.h.

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

201  :
202  tree_(from.tree_) {
203  GUM_CONS_CPY(SearchStrategy);
204  }
DFSTree< GUM_SCALAR > * tree_
SearchStrategy()
Default constructor.
+ Here is the call graph for this function:

◆ ~SearchStrategy()

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

Destructor.

Definition at line 207 of file searchStrategy_tpl.h.

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

207  {
208  GUM_DESTRUCTOR(SearchStrategy);
209  }
SearchStrategy()
Default constructor.
+ Here is the call graph for this function:

Member Function Documentation

◆ 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

◆ computeCost_()

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

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(&(inst2->get(input->lastElt().safeName()))))) {
46  cost += std::log(input->type().variable().domainSize());
47  input_set.insert(&(inst2->get(input->lastElt().safeName())));
48  }
49 
50  for (auto vec = inst->beginInvRef(); vec != inst->endInvRef(); ++vec)
51  for (const auto inverse: *vec.val())
52  if (!seq.exists(inverse.first)) {
53  cost += 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:

◆ 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 213 of file searchStrategy_tpl.h.

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

213  {
214  this->tree_ = from.tree_;
215  return *this;
216  }
DFSTree< GUM_SCALAR > * tree_
+ 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)

Definition at line 219 of file searchStrategy_tpl.h.

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

219  {
220  this->tree_ = tree;
221  }
DFSTree< GUM_SCALAR > * tree_
+ Here is the call graph for this function:

Member Data Documentation

◆ tree_

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

Definition at line 111 of file searchStrategy.h.


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