aGrUM  0.20.2
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 210 of file searchStrategy_tpl.h.

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

210  : tree_(0) {
211  GUM_CONSTRUCTOR(SearchStrategy);
212  }
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 215 of file searchStrategy_tpl.h.

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

216  :
217  tree_(from.tree_) {
218  GUM_CONS_CPY(SearchStrategy);
219  }
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 222 of file searchStrategy_tpl.h.

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

222  {
223  GUM_DESTRUCTOR(SearchStrategy);
224  }
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(
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 >
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 227 of file searchStrategy_tpl.h.

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

228  {
229  this->tree_ = from.tree_;
230  return *this;
231  }
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 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

◆ tree_

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

Definition at line 112 of file searchStrategy.h.


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