50#ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_H
51#define GUM_MULTI_DIM_FUNCTION_GRAPH_H
61 template <
typename GUM_ELEMENT,
template <
typename >
class TerminalNodePolicy >
64 template <
typename GUM_ELEMENT,
template <
typename >
class TerminalNodePolicy >
67 template <
typename GUM_ELEMENT,
template <
typename >
class TerminalNodePolicy >
88 template <
typename GUM_ELEMENT,
92 public TerminalNodePolicy< GUM_ELEMENT > {
146 void fill(
const GUM_ELEMENT& d)
const override;
152 void populate(
const std::vector< GUM_ELEMENT >& v)
const override;
157 void populate(std::initializer_list< GUM_ELEMENT > v)
const override;
182 const std::string&
name()
const override;
193 Idx newval)
override;
265 std::string
toDot(
bool withBackArcs =
false)
const;
277 MultiDimFunctionGraphManager< GUM_ELEMENT, TerminalNodePolicy >*
manager();
390 MultiDimFunctionGraphManager< GUM_ELEMENT, TerminalNodePolicy >*
_manager_;
408#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
409# ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
413#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
414# ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
Headers of the ExactTerminalNodePolicy.
Set of pairs of elements with fast search for both elements.
Base class for discrete random variable.
Implementation of a Terminal Node Policy that maps nodeid directly to value.
const GUM_ELEMENT & value() const override
Returns the value of the current terminal nodes pointed by the constant safe iterator.
The class for generic Hash Tables.
Class for assigning/browsing values to tuples of discrete variables.
Structure used to represent a node internal structure.
Abstract base class for all multi dimensionnal containers.
virtual std::string toString() const
Returns a representation of this MultiDimContainer.
Class implementingting a function graph manager.
NodeGraphPart _model_
Indicates available nodeIds.
NodeId _root_
The root node of the function graph.
Size realSize() const override
Returns the real number of parameters used for this table.
HashTable< NodeId, InternalNode * > _internalNodeMap_
Associates each non-terminal node to a variable.
~MultiDimFunctionGraph() override
Class destructor.
void clear()
Clears the function graph.
std::string toDot(bool withBackArcs=false) const
Returns a const reference to the manager of this diagram.
static MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * getTreeInstance()
Returns an arborescent instance.
HashTable< const DiscreteVariable *, LinkedList< NodeId > * > _var2NodeIdMap_
Mapping between var and node.
void copyFrom(const MultiDimContainer< GUM_ELEMENT > &src, Instantiation *p_i=(Instantiation *) 0) const override
void setFirstNotification(const Instantiation &i) override
Listen to setFirst in a given Instantiation.
void setChangeNotification(const Instantiation &i) override
Listen to an assignment of a value in a Instantiation.
MultiDimFunctionGraph(bool isReduced=true)
Default constructor.
void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
void replace_(const DiscreteVariable *x, const DiscreteVariable *y) override
void setTableName(std::string_view name)
Sets the name of the table represented by this structure.
void copy(const MultiDimContainer< GUM_ELEMENT > &src) override
MultiDimContainer< GUM_ELEMENT > * newFactory() const override
Creates an empty clone of this MultiDimContainer.
MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > & operator=(const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > &from)
Copy Operator.
bool isInternalNode(const NodeId &node) const
Indicates if given node is terminal or not.
const LinkedList< NodeId > * varNodeListe(const DiscreteVariable *var) const
Returns the list of node associated to given variable.
MultiDimFunctionGraphManager< GUM_ELEMENT, TerminalNodePolicy > * _manager_
A reference to the manager that edits this function graph.
const NodeId & root() const
Returns the id of the root node from the diagram.
void copyAndMultiplyByScalar(const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > &src, GUM_ELEMENT gamma)
Copies src diagrams and multiply every value by the given scalar.
void set(const Instantiation &i, const GUM_ELEMENT &value) const override
void setDecNotification(const Instantiation &i) override
Listen to increment in each recorded Instantiation.
void setLastNotification(const Instantiation &i) override
Listen to setLast in a given Instantiation.
void changeNotification(const Instantiation &i, const DiscreteVariable *const var, Idx oldval, Idx newval) override
Listen to changes in a given Instantiation.
const std::string & tableName() const
Returns the name of the table represented by this structure.
const std::string & name() const override
Returns the real name of the multiDim implementation.
bool isReducedAndOrdered() const
Returns true if this MultiDimFunctionGraph is reduced and Ordered.
std::string _name_
The name of the data structure.
bool isTerminalNode(const NodeId &node) const
Indicates if given node is terminal or not.
GUM_ELEMENT & get_(const Instantiation &inst) const override
void copyAndReassign(const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > &src, const Bijection< const DiscreteVariable *, const DiscreteVariable * > &reassign)
Copies src diagrams structure into this diagrams.
bool _isReduced_
Wheter the MultiDimFunctionGraphManager is reduced or not.
const GUM_ELEMENT & nodeValue(NodeId n) const
Returns value associated to given node.
void fill(const GUM_ELEMENT &d) const override
void erase(const DiscreteVariable &v) override
Removes a var from the variables of the multidimensional matrix.
const NodeGraphPart & model() const
Returns a const reference to the manager of this diagram.
void populate(const std::vector< GUM_ELEMENT > &v) const override
void setIncNotification(const Instantiation &i) override
Listen to increment in a given Instantiation.
std::string _tableName_
The name of the data structure.
GUM_ELEMENT get(const Instantiation &i) const override
Returns the value pointed by i.
const InternalNode * node(NodeId n) const
Returns internalNode structure associated to that nodeId.
MultiDimFunctionGraphManager< GUM_ELEMENT, TerminalNodePolicy > * manager()
Returns a const reference to the manager of this diagram.
static const GUM_ELEMENT defaultValue
Only for proper initialization of a certain returned value.
static MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.
MultiDimImplementation()
Default constructor.
Class for node sets in graph.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Size NodeId
Type for node ids.
Headers of MultiDimFunctionGraphManager.
Template methods of MultiDimFunctionGraph.
Headers of gum::MultiDimImplementation.
gum is the global namespace for all aGrUM entities
Template trick for efficient development.
Provides basic types used in aGrUM.