55 template <
typename GUM_SCALAR >
72 template <
typename GUM_SCALAR >
81 template <
typename GUM_SCALAR >
101 template <
typename GUM_SCALAR >
113 template <
typename GUM_SCALAR >
117 template <
typename GUM_SCALAR >
121 template <
typename GUM_SCALAR >
124 Tensor< GUM_SCALAR >& m) {
130 if (!this->
hasEvidence() && (chain.second->cpf().nbrDim() == 1)) {
134 m.set(i, chain.second->cpf().get(i));
151 for (
const auto pot: data.
pool)
152 if (pot->contains(
_query_.second->type().variable())) pots.
insert(pot);
154 if (pots.
size() == 1) {
155 Tensor< GUM_SCALAR >* pot =
const_cast< Tensor< GUM_SCALAR >*
>(*(pots.
begin()));
156 GUM_ASSERT(pot->contains(
_query_.second->type().variable()));
157 GUM_ASSERT(pot->variablesSequence().size() == 1);
160 for (i.setFirst(), j.
setFirst(); !i.end(); i.inc(), j.
inc())
161 m.set(j, pot->get(i));
164 Tensor< GUM_SCALAR >* tmp = Comb.
execute(pots);
167 for (i.setFirst(), j.
setFirst(); !i.end(); i.inc(), j.
inc())
168 m.set(i, tmp->get(j));
173 Tensor< GUM_SCALAR >* pot = *(data.
pool.
begin());
174 GUM_ASSERT(pot->contains(
_query_.second->type().variable()));
175 GUM_ASSERT(pot->variablesSequence().size() == 1);
178 for (i.setFirst(), j.
setFirst(); !i.end(); i.inc(), j.
inc())
179 m.set(j, pot->get(i));
192 template <
typename GUM_SCALAR >
195 Tensor< GUM_SCALAR >& j) {
199 template <
typename GUM_SCALAR >
202 s <<
"Triangulation time: " <<
triang_time << std::endl;
203 s <<
"Pattern mining time: " <<
mining_time << std::endl;
204 s <<
"Pattern elimination time: " <<
pattern_time << std::endl;
205 s <<
"Inner node elimination time: " <<
inner_time << std::endl;
206 s <<
"Observed node elimination time: " <<
obs_time << std::endl;
207 s <<
"Full inference time: " <<
full_time << std::endl;
208 s <<
"#patterns: " <<
_gspan_->patterns().size() << std::endl;
210 using Iter = std::vector< gspan::Pattern* >::const_iterator;
212 for (Iter p =
_gspan_->patterns().begin(); p !=
_gspan_->patterns().end(); ++p) {
213 if (
_gspan_->matches(**p).size()) {
214 s <<
"Pattern n°" << count++ <<
" match count: " <<
_gspan_->matches(**p).size()
216 s <<
"Pattern n°" << count++ <<
" instance count: " << (**p).size() << std::endl;
223 template <
typename GUM_SCALAR >
234 using Iter = std::vector< gspan::Pattern* >::const_iterator;
236 for (Iter p =
_gspan_->patterns().begin(); p !=
_gspan_->patterns().end(); ++p)
252 for (
size_t i = 0; i < data.
outputs().size(); ++i)
256 template <
typename GUM_SCALAR >
265 for (
size_t i = 0; i < data.
inners().size(); ++i)
272 for (
const auto elt: **iter)
277 else _elim_map_.insert(*iter,
new Set< Tensor< GUM_SCALAR >* >(pool));
282 for (; iter != data.
matches.end(); ++iter) {
288 for (; iter != data.
matches.end(); ++iter) {
295 for (
const auto pat: fake_patterns) {
296 for (
const auto elt: *pat)
305 for (
const auto m: data.
matches)
313 template <
typename GUM_SCALAR >
320 std::pair< Idx, std::string >& v) {
321 if ((*inst).hasRefAttr((*inst).get(v.second).id())) {
322 std::vector< std::pair< PRMInstance< GUM_SCALAR >*, std::string > >& refs
325 for (
auto r = refs.begin(); r != refs.end(); ++r) {
326 if (!match.exists(r->first)) {
334 for (
const auto m: data.
matches) {
335 if (this->
hasEvidence(std::make_pair((*m)[v.first], &((*m)[v.first]->get(v.second))))) {
336 GUM_ASSERT(inst->
type().name() == (*m)[v.first]->type().name());
337 GUM_ASSERT(inst->
get(v.second).safeName() == (*m)[v.first]->get(v.second).safeName());
347 template <
typename GUM_SCALAR >
350 Set< Tensor< GUM_SCALAR >* >& pool,
352 std::pair< Idx, std::string > v;
353 Tensor< GUM_SCALAR >* pot = 0;
355 for (
const auto inst: match) {
356 for (
const auto& elt: *inst) {
358 v = std::make_pair(match.pos(inst), elt.second->safeName());
359 data.
map.insert(
id, v);
361 data.
mod.insert(
id, elt.second->type()->domainSize());
362 data.
vars.insert(
id, &(elt.second->type().variable()));
363 pool.insert(
const_cast< Tensor< GUM_SCALAR >*
>(&(elt.second->cpf())));
364 pot = &(
const_cast< Tensor< GUM_SCALAR >&
>(inst->get(v.second).cpf()));
366 for (
const auto var: pot->variablesSequence()) {
376 && (inst->type().containerDag().children(elt.second->id()).size() == 0)
383 for (
const auto mat: data.
matches) {
387 = match.atPos(pos)->get(
_query_.second->safeName()).type().variable();
402 template <
typename GUM_SCALAR >
405 std::pair< Idx, std::string > attr) {
406 for (
const auto mat: data.
matches)
407 if (mat->atPos(attr.first)->hasRefAttr(mat->atPos(attr.first)->get(attr.second).id()))
413 template <
typename GUM_SCALAR >
416 Set< Tensor< GUM_SCALAR >* >& pool) {
419 for (
const auto node: data.
barren) {
420 for (
const auto pot: pool)
421 if (pot->contains(*data.
vars.second(node))) {
435 Tensor< GUM_SCALAR >* my_pot =
nullptr;
438 while (candidates.
size()) {
439 node = candidates.
back();
440 candidates.
erase(node);
443 for (
const auto pot: pool) {
444 if (pot->contains(*data.
vars.second(node))) {
465 template <
typename GUM_SCALAR >
469 const Set< Tensor< GUM_SCALAR >* >& pool,
471 const std::vector< NodeId >& elim_order) {
473 std::pair< Idx, std::string > target;
476 for (
size_t idx = data.
inners().
size(); idx < end; ++idx) {
477 target = data.
map[data.
vars.first(data.
vars.second(elim_order[idx]))];
478 eliminateNode(&(match[target.first]->get(target.second).type().variable()),
486 template <
typename GUM_SCALAR >
489 const Set< Tensor< GUM_SCALAR >* >& pool,
491 const std::vector< NodeId >& elim_order) {
493 std::pair< Idx, std::string > target;
496 for (
size_t idx = data.
inners().
size(); idx < end; ++idx) {
497 target = data.
map[data.
vars.first(data.
vars.second(elim_order[idx]))];
498 eliminateNode(&(match[target.first]->get(target.second).type().variable()),
506 template <
typename GUM_SCALAR >
509 const Set< Tensor< GUM_SCALAR >* >& pool,
513 for (
const auto iter = data.
matches.begin(); iter != data.
matches.end(); ++iter) {
514 GUM_ASSERT((**iter).size() == match.size());
516 for (
Size idx = 0; idx < match.size(); ++idx) {
517 GUM_ASSERT((**iter).atPos(idx)->type() == match.atPos(idx)->type());
523 std::pair< Idx, std::string > target;
527 for (
Size idx = 0; idx < match.size(); ++idx) {
529 const auto& chains = source[idx]->type().slotChains();
531 for (
const auto sc: chains) {
533 GUM_ASSERT(!(sc->isMultiple()));
538 ->getInstance(sc->id())
539 .get(sc->lastElt().safeName())
543 ->getInstance(sc->id())
544 .get(sc->lastElt().safeName())
549 if (bij.
first(&(match[idx]
550 ->getInstance(sc->id())
551 .get(sc->lastElt().safeName())
555 ->getInstance(sc->id())
556 .get(sc->lastElt().safeName())
570 for (
const auto p: pool) {
571 for (
const auto v: p->variablesSequence()) {
573 target = data.
map[data.
vars.first(v)];
574 bij.
insert(v, &(match[target.first]->get(target.second).type().variable()));
583 for (
const auto pot: *my_pool)
594 template <
typename GUM_SCALAR >
598 Tensor< GUM_SCALAR >* pot =
nullptr;
601 for (
const auto& elt: *this->
sys_) {
624 partial_order[0].
insert(agg);
632 if (partial_order[0].empty()) partial_order.
erase(0);
634 if (partial_order.
size() > 1) {
637 if (partial_order[1].empty()) partial_order.
erase(1);
642 partial_order.
insert(query_set);
645 for (
auto attr = inst->
begin(); attr != inst->
end(); ++attr)
646 pool.
insert(&(
const_cast< Tensor< GUM_SCALAR >&
>((*(attr.val())).cpf())));
650 for (
const auto& elt: this->
evidence(inst))
651 pool.
insert(
const_cast< Tensor< GUM_SCALAR >*
>(elt.second));
656 if (partial_order.
size() > 1)
657 for (
size_t idx = 0; idx < partial_order[0].
size(); ++idx)
662 for (
const auto& elt: *inst)
663 pool.
insert(&
const_cast< Tensor< GUM_SCALAR >&
>(elt.second->cpf()));
666 for (
const auto& elt: this->
evidence(inst))
667 pool.
insert(
const_cast< Tensor< GUM_SCALAR >*
>(elt.second));
671 for (
size_t idx = 0; idx < partial_order[0].
size(); ++idx)
681 for (
const auto srcPot: data->
pool) {
687 for (
const auto agg: data->
c.aggregates())
688 pool.
insert(&(
const_cast< Tensor< GUM_SCALAR >&
>(inst->
get(agg->id()).cpf())));
695 for (
size_t idx = data->
inners().
size(); idx < size; ++idx)
701 for (
const auto pot: pool)
708 template <
typename GUM_SCALAR >
715 for (
const auto pot: data.
pool) {
718 for (
Size var_1 = 0; var_1 < vars.
size(); ++var_1) {
724 data.
mods.insert(id_1, vars.
atPos(var_1)->domainSize());
728 for (
Size var_2 = var_1 + 1; var_2 < vars.
size(); ++var_2) {
734 data.
mods.insert(id_2, vars.
atPos(var_2)->domainSize());
748 for (
const auto pot: *elt.second) {
752 for (
Size var_1 = 0; var_1 < vars.
size(); ++var_1) {
758 data.
mods.insert(id_1, vars.
atPos(var_1)->domainSize());
762 for (
Size var_2 = var_1 + 1; var_2 < vars.
size(); ++var_2) {
768 data.
mods.insert(id_2, vars.
atPos(var_2)->domainSize());
781 template <
typename GUM_SCALAR >
788 template <
typename GUM_SCALAR >
795 for (
int i = 0; i < 4; ++i)
799 template <
typename GUM_SCALAR >
802 pattern(source.pattern), matches(source.matches), graph(source.graph), mod(source.mod),
803 node2attr(source.node2attr), vars(source.vars), _partial_order_(source._partial_order_),
808 template <
typename GUM_SCALAR >
820 template <
typename GUM_SCALAR >
826 for (
const auto node:
c.containerDag().nodes()) {
827 switch (
c.get(node).elt_type()) {
829 pool.insert(&(
const_cast< Tensor< GUM_SCALAR >&
>(
c.get(node).cpf())));
836 mods.insert(node,
c.get(node).type()->domainSize());
847 const auto& parents =
c.containerDag().parents(node);
850 for (
auto tail = parents.begin(); tail != parents.end(); ++tail) {
857 while (marry != parents.end()) {
868 switch (
c.get(node).elt_type()) {
876 for (
const auto par:
c.containerDag().parents(node)) {
877 const auto& prnt =
c.get(par);
879 if ((!
c.isOutputNode(prnt))
891 pool.insert(
const_cast< Tensor< GUM_SCALAR >*
>(&(
c.get(node).cpf())));
918 template <
typename GUM_SCALAR >
926 template <
typename GUM_SCALAR >
935 template <
typename GUM_SCALAR >
940 template <
typename GUM_SCALAR >
947 template <
typename GUM_SCALAR >
954 template <
typename GUM_SCALAR >
961 template <
typename GUM_SCALAR >
966 template <
typename GUM_SCALAR >
971 template <
typename GUM_SCALAR >
973 return "StructuredInference";
976 template <
typename GUM_SCALAR >
981 template <
typename GUM_SCALAR >
986 template <
typename GUM_SCALAR >
990 Set< Tensor< GUM_SCALAR >* >& pool) {
994 GUM_ASSERT(!data.
mod.exists(
id));
998 GUM_ASSERT(!data.
map.exists(
id));
999 data.
vars.eraseFirst(
id);
1000 GUM_ASSERT(!data.
vars.existsFirst(
id));
1003 pool.erase(data.
pots[
id]);
1004 GUM_ASSERT(!pool.exists(data.
pots[
id]));
1005 data.
pots.erase(
id);
1006 GUM_ASSERT(!data.
pots.exists(
id));
void eraseFirst(const T1 &first)
bool existsFirst(const T1 &first) const
Returns true if first is the first element in a pair in the gum::Bijection.
void insert(const T1 &first, const T2 &second)
const T1 & first(const T2 &second) const
Returns the first value of a pair given its second value.
Set of pairs of elements with fast search for both elements.
Base class for discrete random variable.
Exception : a similar element already exists.
const NodeSet & neighbours(NodeId id) const
returns the set of node neighbours to a given node
Base class for all aGrUM's exceptions.
Exception : fatal (unknown ?) error.
Class for assigning/browsing values to tuples of discrete variables.
bool end() const
Returns true if the Instantiation reached the end.
void inc()
Operator increment.
void setFirst()
Assign the first values to the tuple of the Instantiation.
Generic doubly linked lists.
Size size() const noexcept
Returns the number of elements in the list.
Val & push_back(Args &&... args)
An alias for pushBack used for STL compliance.
Val & insert(const Val &val)
Inserts a new element at the end of the chained list (alias of pushBack).
void erase(Size i)
Erases the ith element of the List (the first one is in position 0).
A class to combine efficiently several MultiDim tables.
TABLE * execute(const Set< const TABLE * > &set) const final
Creates and returns the result of the combination of the tables within set.
bool exists(const NodeId id) const
alias for existsNode
virtual NodeId addNode()
insert a new node and return its id
Exception : the element we looked for cannot be found.
Exception : operation not allowed.
class for graph triangulations for which we enforce a given partial ordering on the nodes elimination...
Size size() const noexcept
const Key & atPos(Idx i) const
Returns the object at the pos i.
void insert(const Key &k)
The generic class for storing (ordered) sequences of objects.
iterator begin() const
The usual unsafe begin iterator to parse the set.
SetIterator< Sequence< PRMInstance< GUM_SCALAR > * > * > const_iterator
Size size() const noexcept
Returns the number of elements in the set.
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
void insert(const Key &k)
Inserts a new element into the set.
void erase(const Key &k)
Erases an element from the set.
const std::vector< NodeId > & eliminationOrder()
returns an elimination ordering compatible with the triangulated graph
void addEdge(NodeId first, NodeId second) override
insert a new edge into the undirected graph
void eraseNode(NodeId id) override
remove a node and its adjacent edges from the graph
This class discovers pattern in a PRM<GUM_SCALAR>'s PRMSystem<GUM_SCALAR> to speed up structured infe...
Set< Sequence< PRMInstance< GUM_SCALAR > * > * > MatchedInstances
Code alias.
PRMAttribute is a member of a Class in a PRM.
static INLINE bool isAggregate(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMAggregate.
const std::string & safeName() const
Returns the safe name of this PRMClassElement, if any.
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantia...
std::pair< const PRMInstance< GUM_SCALAR > *, const PRMAttribute< GUM_SCALAR > * > Chain
Code alias.
EMap & evidence(const PRMInstance< GUM_SCALAR > &i)
Returns EMap of evidences over i.
PRMInference(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system)
Default constructor.
PRMSystem< GUM_SCALAR > const * sys_
The Model on which inference is done.
PRM< GUM_SCALAR > const * prm_
The PRM<GUM_SCALAR> on which inference is done.
bool hasEvidence(const PRMInstance< GUM_SCALAR > &i) const
Returns true if i has evidence.
An PRMInstance is a Bayesian network fragment defined by a Class and used in a PRMSystem.
const iterator & end()
Returns a reference over the iterator at the end of the list of gum::prm::PRMAttribute<GUM_SCALAR> in...
const Bijection< const DiscreteVariable *, const DiscreteVariable * > & bijection() const
Returns a mapping between DiscreteVariable used in this and the ones used in this PRMInstance<GUM_SCA...
std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > & getRefAttr(NodeId id)
Returns a vector of pairs of refering attributes of id.
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
PRMAttribute< GUM_SCALAR > & get(NodeId id)
Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.
iterator begin()
Returns an iterator at the begining of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInst...
Size size() const
Returns the number of attributes in this PRMInstance<GUM_SCALAR>.
const std::string & name() const
Returns the name of this object.
A PRMSlotChain represents a sequence of gum::prm::PRMClassElement<GUM_SCALAR> where the n-1 first gum...
PRMClassElement< GUM_SCALAR > & lastElt()
Returns the last element of the slot chain, typically this is an gum::PRMAttribute or a gum::PRMAggre...
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
virtual ~StructuredInference()
Destructor.
void searchPatterns()
Search for patterns without doing any computations.
Set< Tensor< GUM_SCALAR > * > * _eliminateObservedNodes_(typename StructuredInference::PData &data, const Set< Tensor< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match, const std::vector< NodeId > &elim_order)
Add in data.queries() any queried variable in one of data.pattern matches.
HashTable< const PRMClass< GUM_SCALAR > *, CData * > _cdata_map_
Mapping between a Class<GUM_SCALAR> and data about instances reduced using only Class<GUM_SCALAR> lev...
void _reducePattern_(const gspan::Pattern *p)
Proceed with the elimination of all inner variables (observed or not) of all usable matches of Patter...
std::string _dot_
Unreduce the match containing the query.
void setPatternMining(bool b)
Tells this algorithm to use pattern mining or not.
void _buildReduceGraph_(RGData &data)
This calls reducePattern() over each pattern and then build the reduced graph which is used for infer...
void _removeBarrenNodes_(typename StructuredInference::PData &data, Set< Tensor< GUM_SCALAR > * > &pool)
HashTable< const Sequence< PRMInstance< GUM_SCALAR > * > *, Set< Tensor< GUM_SCALAR > * > * > _elim_map_
Mapping between a Pattern's match and its tensor pool after inner variables were eliminated.
HashTable< const PRMClass< GUM_SCALAR > *, std::vector< NodeId > * > _outputs_
PRMInference< GUM_SCALAR >::Chain _query_
The query.
virtual void posterior_(const typename PRMInference< GUM_SCALAR >::Chain &chain, Tensor< GUM_SCALAR > &m)
See PRMInference::posterior_().
void _removeNode_(typename StructuredInference::PData &data, NodeId id, Set< Tensor< GUM_SCALAR > * > &pool)
void _buildPatternGraph_(PData &data, Set< Tensor< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match)
Build the DAG corresponding to Pattern data.pattern, initialize pool with all the Tensors of all vari...
PData * _pdata_
The pattern data of the pattern which one of its matches contains the query.
Set< Tensor< GUM_SCALAR > * > * _translatePotSet_(typename StructuredInference::PData &data, const Set< Tensor< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match)
Translate a given Tensor Set into one w.r.t. variables in match.
void _insertNodeInElimLists_(typename StructuredInference::PData &data, const Sequence< PRMInstance< GUM_SCALAR > * > &match, PRMInstance< GUM_SCALAR > *inst, PRMAttribute< GUM_SCALAR > *attr, NodeId id, std::pair< Idx, std::string > &v)
std::string _str_(const PRMInstance< GUM_SCALAR > *i, const PRMAttribute< GUM_SCALAR > *a) const
StructuredInference & operator=(const StructuredInference &source)
Copy operator.
void _addEdgesInReducedGraph_(RGData &data)
Add the nodes in the reduced graph.
bool _mining_
Flag which tells to use pattern mining or not.
GSpan< GUM_SCALAR > * _gspan_
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
GSpan< GUM_SCALAR > & gspan()
Returns the instance of gspan used to search patterns.
bool _found_query_
Flag with an explicit name.
virtual void evidenceAdded_(const typename PRMInference< GUM_SCALAR >::Chain &chain)
See PRMInference::evidenceAdded_().
bool _allInstanceNoRefAttr_(typename StructuredInference::PData &data, std::pair< Idx, std::string > attr)
virtual void joint_(const std::vector< typename PRMInference< GUM_SCALAR >::Chain > &queries, Tensor< GUM_SCALAR > &j)
See PRMInference::joint_().
virtual std::string name() const
Tells this algorithm to use pattern mining or not.
virtual void evidenceRemoved_(const typename PRMInference< GUM_SCALAR >::Chain &chain)
See PRMInference::evidenceRemoved_().
Set< const PRMInstance< GUM_SCALAR > * > _reducedInstances_
This keeps track of reduced instances.
StructuredInference(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
Set< Tensor< GUM_SCALAR > * > * _eliminateObservedNodesInSource_(typename StructuredInference::PData &data, const Set< Tensor< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match, const std::vector< NodeId > &elim_order)
Set< Tensor< GUM_SCALAR > * > _trash_
Keeping track of create tensors to delete them after inference.
void _reduceAloneInstances_(RGData &data)
Add the reduced tensors of instances not in any used patterns.
std::pair< Idx, std::string > _query_data_
This contains all the information we want for a node in a DFSTree.
This is an abstract class used to tune search strategies in the gspan algorithm.
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Size NodeId
Type for node ids.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
namespace for all probabilistic relational models entities
Tensor< GUM_SCALAR > multTensor(const Tensor< GUM_SCALAR > &t1, const Tensor< GUM_SCALAR > &t2)
void eliminateNode(const DiscreteVariable *var, Set< Tensor< GUM_SCALAR > * > &pool, Set< Tensor< GUM_SCALAR > * > &trash)
Proceeds with the elimination of var in pool.
Tensor< GUM_SCALAR > * copyTensor(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bij, const Tensor< GUM_SCALAR > &source)
Returns a copy of a Tensor after applying a bijection over the variables in source.
gum is the global namespace for all aGrUM entities
Private structure to represent data about a Class<GUM_SCALAR>.
NodeSet & aggregators()
Returns the set of aggregators and their parents.
std::vector< NodeId > _elim_order_
Set< Tensor< GUM_SCALAR > * > _trash_
List< NodeSet > partial_order
The partial order used of variable elimination.
Set< const PRMInstance< GUM_SCALAR > * > instances
The Set of Instances reduces at class level.
NodeSet & outputs()
Returns the set of outputs nodes.
UndiGraph moral_graph
The class moral graph. NodeId matches those in c.
CData(const PRMClass< GUM_SCALAR > &c)
Default constructor.
std::vector< NodeId > & elim_order()
The elimination order for nodes of this class.
Set< Tensor< GUM_SCALAR > * > pool
The tensor pool obtained by C elimination of inner nodes.
NodeSet & inners()
Returns the set of inner nodes.
const PRMClass< GUM_SCALAR > & c
The class about what this data is about.
NodeProperty< Size > mods
The class variables modalities.
Private structure to represent data about a pattern.
List< NodeSet > _partial_order_
We'll use a PartialOrderedTriangulation with three sets: output, nodes and obs with children outside ...
NodeSet & obs()
Returns the set of inner and observed nodes given all the matches of pattern.
NodeSet & queries()
Returns the set of queried nodes given all the matches of pattern.
const List< NodeSet > * partial_order()
Set< NodeId > barren
Set of barren nodes.
Bijection< NodeId, std::string > node2attr
A bijection to easily keep track between graph and attributes, its of the form instance_name DOT attr...
NodeProperty< std::pair< Idx, std::string > > map
To ease translating tensors from one match to another.
UndiGraph graph
A yet to be triangulated undigraph.
NodeSet & outputs()
Returns the set of outputs nodes given all the matches of pattern.
const gspan::Pattern & pattern
The pattern for which this represents data about it.
NodeSet & inners()
Returns the set of inner nodes.
NodeProperty< Tensor< GUM_SCALAR > * > pots
To handle barren nodes.
Bijection< NodeId, const DiscreteVariable * > vars
Bijection between graph's nodes and their corresponding DiscreteVariable, for inference purpose.
List< NodeSet > * _real_order_
A copy of partial_order without empty sets.
PData(const gspan::Pattern &p, typename GSpan< GUM_SCALAR >::MatchedInstances &m)
Default constructor.
NodeProperty< Size > mod
The pattern's variables modalities.
GSpan< GUM_SCALAR >::MatchedInstances & matches
A reference over the usable matches of pattern.
Private structure to represent data about a reduced graph.
List< NodeSet > partial_order
Partial order used for triangulation, first is outputs nodes, second query nodes.
Set< Tensor< GUM_SCALAR > * > pool
The pool of tensors matching the reduced graph.
RGData()
Default constructor.
Bijection< const DiscreteVariable *, NodeId > var2node
Mapping between DiscreteVariable and NodeId.
NodeSet & queries()
Returns the set of query nodes (which will not be eliminated).
UndiGraph reducedGraph
The reduced graph.
NodeSet & outputs()
Returns the set of outputs nodes (which will be eliminated).
NodeProperty< Size > mods
Mapping between NodeId and modalities.
Headers of StructuredInference.