27 #ifndef GUM_STRUCTURED_INFERENCE_H 28 #define GUM_STRUCTURED_INFERENCE_H 60 template <
typename GUM_SCALAR >
91 virtual std::string
name()
const;
236 inline std::vector< NodeId >&
elim_order() {
return __elim_order; }
327 std::pair< Idx, std::string >& v);
330 std::pair< Idx, std::string > attr);
345 const std::vector< NodeId >& elim_order);
351 const std::vector< NodeId >& elim_order);
383 std::string
info()
const;
387 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS List< NodeSet > partial_order
The partial order used of variable elimination.
void __buildPatternGraph(PData &data, Set< Potential< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match)
Build the DAG corresponding to Pattern data.pattern, initialize pool with all the Potentials of all v...
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...
aGrUM's Potential is a multi-dimensional array with tensor operators.
void __reducePattern(const gspan::Pattern *p)
Proceed with the elimination of all inner variables (observed or not) of all usable matches of Patter...
NodeProperty< Size > mods
The class variables modalities.
UndiGraph reducedGraph
The reduced graph.
virtual void _marginal(const typename PRMInference< GUM_SCALAR >::Chain &chain, Potential< GUM_SCALAR > &m)
See PRMInference::_marginal().
NodeSet & queries()
Returns the set of queried nodes given all the matches of pattern.
List< NodeSet > partial_order
Partial order used for triangulation, first is outputs nodes, second query nodes. ...
Set< Potential< GUM_SCALAR > *> __trash
Keeping track of create potentials to delete them after inference.
GSpan< GUM_SCALAR >::MatchedInstances & matches
A reference over the usable matches of pattern.
class for NoisyOR-net implementation as multiDim
std::vector< NodeId > __elim_order
GSpan< GUM_SCALAR > * __gspan
Pointer over th GSpan<GUM_SCALAR> instance used by this class.
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
UndiGraph moral_graph
The class moral graph. NodeId matches those in c.
PData * __pdata
The pattern data of the pattern which one of its matches contains the query.
The generic class for storing (ordered) sequences of objects.
Headers of MultiDimSparse.
NodeSet & outputs()
Returns the set of outputs nodes given all the matches of pattern.
NodeProperty< std::pair< Idx, std::string > > map
To ease translating potentials from one match to another.
bool __mining
Flag which tells to use pattern mining or not.
Set< Potential< GUM_SCALAR > *> * __eliminateObservedNodesInSource(typename StructuredInference::PData &data, const Set< Potential< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match, const std::vector< NodeId > &elim_order)
List< NodeSet > * __real_order
A copy of __partial_order without empty sets.
Set< const PRMInstance< GUM_SCALAR > *> instances
The Set of Instances reduces at class level.
Bijection< const DiscreteVariable *, NodeId > var2node
Mapping between DiscreteVariable and NodeId.
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)
Private structure to represent data about a Class<GUM_SCALAR>.
void __reduceAloneInstances(RGData &data)
Add the reduced potentials of instances not in any used patterns.
UndiGraph graph
A yet to be triangulated undigraph.
NodeSet & obs()
Returns the set of inner and observed nodes given all the matches of pattern.
class for multiDimNoisyORCompound
std::string __dot
Unreduce the match containing the query.
Generic doubly linked lists.
Class used to compute response times for benchmark purposes.
gum is the global namespace for all aGrUM entities
NodeSet & outputs()
Returns the set of outputs nodes.
bool __found_query
Flag with an explicit name.
void __addEdgesInReducedGraph(RGData &data)
Add the nodes in the reduced graph.
Implementation of a variable elimination algorithm for inference in Bayesian Networks.
The class for generic Hash Tables.
const gspan::Pattern & pattern
The pattern for which this represents data about it.
NodeSet & queries()
Returns the set of query nodes (which will not be eliminated).
StructuredInference & operator=(const StructuredInference &source)
Copy operator.
NodeProperty< Potential< GUM_SCALAR > *> pots
To handle barren nodes.
void __buildReduceGraph(RGData &data)
This calls __reducePattern() over each pattern and then build the reduced graph which is used for inf...
NodeSet & outputs()
Returns the set of outputs nodes (which will be eliminated).
Representation of a setA Set is a structure that contains arbitrary elements.
void __removeBarrenNodes(typename StructuredInference::PData &data, Set< Potential< GUM_SCALAR > * > &pool)
Header of the Potential class.
HashTable< const Sequence< PRMInstance< GUM_SCALAR > *> *, Set< Potential< GUM_SCALAR > *> *> __elim_map
Mapping between a Pattern's match and its potential pool after inner variables were eliminated...
RGData()
Default constructor.
<agrum/PRM/structuredInference.h>
Bijection< NodeId, const DiscreteVariable *> vars
Bijection between graph's nodes and their corresponding DiscreteVariable, for inference purpose...
Private structure to represent data about a pattern.
PRMInference< GUM_SCALAR >::Chain __query
The query.
StructuredInference(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
Set< Potential< GUM_SCALAR > *> pool
The potential pool obtained by C elimination of inner nodes.
Set< const PRMInstance< GUM_SCALAR > *> __reducedInstances
This keeps track of reduced instances.
Set< NodeId > barren
Set of barren nodes.
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
virtual std::string name() const
Tells this algorithm to use pattern mining or not.
Set of pairs of elements with fast search for both elements.
Efficient functionals for projecting multiDimensional tables.
List< NodeSet > __partial_order
We'll use a PartialOrderedTriangulation with three sets: output, nodes and obs with children outside ...
NodeSet & inners()
Returns the set of inner nodes.
Set< Potential< GUM_SCALAR > *> * __eliminateObservedNodes(typename StructuredInference::PData &data, const Set< Potential< 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.
A PRMSlotChain represents a sequence of gum::prm::PRMClassElement<GUM_SCALAR> where the n-1 first gum...
NodeProperty< Size > mod
The pattern's variables modalities.
NodeSet & aggregators()
Returns the set of aggregators and their parents.
std::pair< const PRMInstance< GUM_SCALAR > *, const PRMAttribute< GUM_SCALAR > *> Chain
Code alias.
Set< Potential< GUM_SCALAR > *> * __translatePotSet(typename StructuredInference::PData &data, const Set< Potential< GUM_SCALAR > * > &pool, const Sequence< PRMInstance< GUM_SCALAR > * > &match)
Translate a given Potential Set into one w.r.t. variables in match.
virtual void _joint(const std::vector< typename PRMInference< GUM_SCALAR >::Chain > &queries, Potential< GUM_SCALAR > &j)
See PRMInference::_joint().
HashTable< const PRMClass< GUM_SCALAR > *, std::vector< NodeId > *> __outputs
std::string __str(const PRMInstance< GUM_SCALAR > *i, const PRMAttribute< GUM_SCALAR > *a) const
This abstract class is used as base class for all inference class on PRM<GUM_SCALAR>.
bool __allInstanceNoRefAttr(typename StructuredInference::PData &data, std::pair< Idx, std::string > attr)
Private structure to represent data about a reduced graph.
std::vector< NodeId > & elim_order()
The elimination order for nodes of this class.
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
class for graph triangulations for which we enforce a given partial ordering on the nodes elimination...
A PRMClass is an object of a PRM representing a fragment of a Bayesian Network which can be instantia...
This class discovers pattern in a PRM<GUM_SCALAR>'s PRMSystem<GUM_SCALAR> to speed up structured infe...
std::pair< Idx, std::string > __query_data
Base class for undirected graphs.
virtual ~StructuredInference()
Destructor.
Class used to compute response times for benchmark purposesThis class represents a classic timer...
NodeSet & inners()
Returns the set of inner nodes.
GSpan< GUM_SCALAR > & gspan()
Returns the instance of gspan used to search patterns.
virtual void _evidenceRemoved(const typename PRMInference< GUM_SCALAR >::Chain &chain)
See PRMInference::_evidenceRemoved().
PRMAttribute is a member of a Class in a PRM.
Bijection< NodeId, std::string > node2attr
A bijection to easily keep track between graph and attributes, its of the form instance_name DOT attr...
virtual void _evidenceAdded(const typename PRMInference< GUM_SCALAR >::Chain &chain)
See PRMInference::_evidenceAdded().
Set< Potential< GUM_SCALAR > *> pool
The pool of potentials matching the reduced graph.
void setPatternMining(bool b)
Tells this algorithm to use pattern mining or not.
Inline implementation of StructuredInference.
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.
Size NodeId
Type for node ids.
NodeProperty< Size > mods
Mapping between NodeId and modalities.
const PRMClass< GUM_SCALAR > & c
The class about what this data is about.
Set< Potential< GUM_SCALAR > *> __trash
void __removeNode(typename StructuredInference::PData &data, NodeId id, Set< Potential< GUM_SCALAR > * > &pool)
void searchPatterns()
Search for patterns without doing any computations.