aGrUM 2.3.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.
 SearchStrategy (const SearchStrategy< GUM_SCALAR > &from)
 Copy constructor.
virtual ~SearchStrategy ()
 Destructor.
SearchStrategy< GUM_SCALAR > & operator= (const SearchStrategy< GUM_SCALAR > &from)
 Copy operator.
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 Member Functions

double computeCost_ (const Pattern &p)

Protected Attributes

DFSTree< GUM_SCALAR > * tree_

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 81 of file searchStrategy.h.

Constructor & Destructor Documentation

◆ SearchStrategy() [1/2]

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

Default constructor.

Definition at line 214 of file searchStrategy_tpl.h.

214 : tree_(0) {
216 }
This is an abstract class used to tune search strategies in the gspan algorithm.
DFSTree< GUM_SCALAR > * tree_

References SearchStrategy(), and tree_.

Referenced by gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::FrequenceSearch(), gum::prm::gspan::FrequenceSearch< GUM_SCALAR >::FrequenceSearch(), SearchStrategy(), SearchStrategy(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::StrictSearch(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::StrictSearch(), gum::prm::gspan::TreeWidthSearch< GUM_SCALAR >::TreeWidthSearch(), gum::prm::gspan::TreeWidthSearch< GUM_SCALAR >::TreeWidthSearch(), ~SearchStrategy(), and operator=().

Here is the call graph for this function:
Here is the caller 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 220 of file searchStrategy_tpl.h.

220 :
221 tree_(from.tree_) {
223 }

References SearchStrategy(), and tree_.

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

226 {
228 }

References SearchStrategy().

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

56 {
57 double cost = 0;
59 = *(this->tree_->data(p).iso_map.begin().val());
61
62 for (const auto inst: seq) {
63 for (const auto input: inst->type().slotChains())
64 for (const auto inst2: inst->getInstances(input->id()))
65 if ((!seq.exists(inst2))
66 && (!input_set.exists(&(inst2->get(input->lastElt().safeName()))))) {
67 cost += std::log(input->type().variable().domainSize());
68 input_set.insert(&(inst2->get(input->lastElt().safeName())));
69 }
70
71 for (auto vec = inst->beginInvRef(); vec != inst->endInvRef(); ++vec)
72 for (const auto& inverse: *vec.val())
73 if (!seq.exists(inverse.first)) {
74 cost += std::log(inst->get(vec.key()).type().variable().domainSize());
75 break;
76 }
77 }
78
79 return cost;
80 }

References gum::SequenceImplementation< Key, Gen >::exists(), gum::SequenceImplementation< Key, Gen >::insert(), and tree_.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator()() [1/2]

◆ operator()() [2/2]

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

232 {
233 this->tree_ = from.tree_;
234 return *this;
235 }

References SearchStrategy(), and 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 238 of file searchStrategy_tpl.h.

238 {
239 this->tree_ = tree;
240 }

References tree_.

Member Data Documentation

◆ tree_


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