71 template <
typename GUM_SCALAR >
105 const std::string& domain =
"[2]");
140 std::string
toDot()
const;
156 virtual const Tensor< GUM_SCALAR >&
cpt(
NodeId varId)
const;
158 virtual const Tensor< GUM_SCALAR >&
cpt(std::string name)
const final {
166 virtual const Tensor< GUM_SCALAR >&
utility(
NodeId varId)
const;
168 virtual const Tensor< GUM_SCALAR >&
utility(std::string name)
const final {
350 NodeId add(
const std::string& fast_description,
unsigned int default_nbrmod = 2);
371 NodeId addChanceNode(
const std::string& fast_description,
unsigned int default_nbrmod = 2);
449 void addArc(
const std::string& tail,
const std::string& head) {
472 void eraseArc(
const std::string& tail,
const std::string& head) {
Class representing probabilistic DAG model.
The base class for all directed edges.
DAGmodel()
Default constructor.
Base class for discrete random variable.
Class representing an Influence Diagram.
void beginTopologyTransformation()
When inserting/removing arcs, node CPTs/utilities change their dimension with a cost in time.
List< NodeSet > _temporalOrder_
The temporal order.
gum::DAG * getDecisionGraph() const
Returns the temporal Graph.
bool isUtilityNode(const std::string &name) const
Returns the CPT of a tensor variable.
bool existsPathBetween(const std::string &src, const std::string &dest) const
True if a directed path exist with all decision nodes.
const List< NodeSet > & getPartialTemporalOrder(bool clear=true) const
Returns partial temporal ordering.
bool isDecisionNode(NodeId varId) const
Returns true if node is a decision one.
VariableNodeMap _variableMap_
Mapping between id and variable.
virtual const Tensor< GUM_SCALAR > & cpt(NodeId varId) const
Returns the CPT of a tensor variable.
NodeId addChanceNode(const DiscreteVariable &variable, NodeId id=0)
Add a chance variable, it's associate node and it's CPT.
bool operator!=(const InfluenceDiagram< GUM_SCALAR > &other) const
Size chanceNodeSize() const
Returns the number of chance nodes.
void addArc(const std::string &tail, const std::string &head)
Add an arc in the ID, and update diagram's tensor nodes cpt if necessary.
void endTopologyTransformation()
terminates a sequence of insertions/deletions of arcs by adjusting all CPTs/utilities dimensions.
void removeTables_()
Removing ancient table.
NodeProperty< Tensor< GUM_SCALAR > * > _tensorMap_
Mapping between tensor variable's id and their CPT.
const VariableNodeMap & variableNodeMap() const final
Returns a constant reference to the VariableNodeMap of this Influence Diagram.
void addArc(NodeId tail, NodeId head)
Add an arc in the ID, and update diagram's tensor nodes cpt if necessary.
virtual void moralGraph_(UndiGraph &graph) const
Returns the moral graph of this InfluenceDiagram.
NodeId addNode_(const DiscreteVariable &variableType, NodeId DesiredId)
Add a node.
std::string toDot() const
bool decisionOrderExists() const
True if a directed path exist with all decision nodes.
Size utilityNodeSize() const
Returns the number of utility nodes.
InfluenceDiagram< GUM_SCALAR > & operator=(const InfluenceDiagram< GUM_SCALAR > &source)
Copy Operator.
void changeVariableName(NodeId id, const std::string &new_name)
we allow the user to change the name of a variable
NodeId add(const DiscreteVariable &variable, NodeId id=0)
Add a chance variable, it's associate node and it's CPT.
static InfluenceDiagram< GUM_SCALAR > fastPrototype(const std::string &dotlike, Size domainSize)
Create an Influence Diagram with a dot-like syntax which specifies:
NodeId addUtilityNode(const DiscreteVariable &variable, NodeId id=0)
Add a utility variable, it's associate node and it's UT.
std::string toString() const
bool isUtilityNode(NodeId varId) const
Returns true if node is a utility one.
void copyStructureAndTables_(const InfluenceDiagram< GUM_SCALAR > &IDsource)
Copying tables from another influence diagram.
virtual const Tensor< GUM_SCALAR > & cpt(std::string name) const final
Returns the CPT of a tensor variable.
NodeId addDecisionNode(const DiscreteVariable &variable, NodeId id=0)
Add a decision variable.
bool isChanceNode(NodeId varId) const
Returns true if node is a chance one.
InfluenceDiagram()
Default constructor.
const DiscreteVariable & variable(NodeId id) const final
Returns a constant reference over a variable given it's node id.
bool isChanceNode(const std::string &name) const
Returns the CPT of a tensor variable.
bool operator==(const InfluenceDiagram< GUM_SCALAR > &other) const
void eraseArc(const Arc &arc)
Removes an arc in the ID, and update diagram's tensor nodes cpt if necessary.
NodeProperty< Tensor< GUM_SCALAR > * > _utilityMap_
Mapping between utility variable's id and their utility table.
NodeId nodeId(const DiscreteVariable &var) const final
Return id node from discrete var pointer.
void eraseArc(const std::string &tail, const std::string &head)
Add an arc in the ID, and update diagram's tensor nodes cpt if necessary.
Size decisionNodeSize() const
Returns the number of decision nodes.
const DiscreteVariable & variable(const std::string &name) const
Returns the CPT of a tensor variable.
virtual const Tensor< GUM_SCALAR > & utility(std::string name) const final
Returns the CPT of a tensor variable.
Sequence< NodeId > getChildrenDecision_(NodeId parentDecision) const
Returns the list of children decision for a given nodeId.
const DiscreteVariable & variableFromName(const std::string &name) const final
Getter by name.
void changeVariableName(const std::string &name, const std::string &new_name)
Returns the CPT of a tensor variable.
void erase(NodeId id)
Erase a Variable from the network and remove the variable from all his children.
virtual const Tensor< GUM_SCALAR > & utility(NodeId varId) const
Returns the utility table of a utility node.
std::vector< NodeId > decisionOrder() const
Returns the sequence of decision nodes in the directed path.
NodeId idFromName(const std::string &name) const final
Getter by name.
bool existsPathBetween(NodeId src, NodeId dest) const
Returns true if a path exists between two nodes.
bool isDecisionNode(const std::string &name) const
Returns the CPT of a tensor variable.
void erase(const std::string &name)
Returns the CPT of a tensor variable.
~InfluenceDiagram() override
Destructor.
Generic doubly linked lists.
<agrum/base/multidim/multiDimImplementation.h>
Base class for undirected graphs.
Container used to map discrete variables with nodes.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Template implementation of InfluenceDiagram/InfluenceDiagram.h classes.
gum is the global namespace for all aGrUM entities
Header of the Tensor class.