31 #ifndef GUM_INF_DIAG_H 32 #define GUM_INF_DIAG_H 37 #include <agrum/agrum.h> 39 #include <agrum/tools/core/hashTable.h> 40 #include <agrum/tools/graphicalModels/DAGmodel.h> 41 #include <agrum/tools/multidim/potential.h> 52 template <
typename GUM_SCALAR >
113 std::string
toDot()
const;
131 return cpt(idFromName(name));
140 return utility(idFromName(name));
153 bool isUtilityNode(
const std::string& name)
const {
return isUtilityNode(idFromName(name)); };
158 bool isDecisionNode(
const std::string& name)
const {
return isDecisionNode(idFromName(name)); };
164 bool isChanceNode(
const std::string& name)
const {
return isChanceNode(idFromName(name)); };
302 void erase(NodeId id);
303 void erase(
const std::string& name) { erase(idFromName(name)); };
312 void erase(
const DiscreteVariable& var);
320 changeVariableName(idFromName(name), new_name);
338 void addArc(NodeId tail, NodeId head);
339 void addArc(
const std::string& tail,
const std::string& head) {
340 addArc(idFromName(tail), idFromName(head));
360 void eraseArc(NodeId tail, NodeId head);
361 void eraseArc(
const std::string& tail,
const std::string& head) {
362 eraseArc(idFromName(tail), idFromName(head));
393 return existsPathBetween(idFromName(src), idFromName(dest));
443 #include <agrum/ID/influenceDiagram_tpl.h> static InfluenceDiagram< GUM_SCALAR > fastPrototype(const std::string &dotlike, Size domainSize=2)
Create an Influence Diagram with a dot-like syntax which specifies:
void addArc(NodeId tail, NodeId head)
Add an arc in the ID, and update diagram's potential nodes cpt if necessary.
NodeId idFromName(const std::string &name) const final
Getter by name.
bool isChanceNode(NodeId varId) const
Returns true if node is a chance one.
void erase(NodeId id)
Erase a Variable from the network and remove the variable from all his children.
NodeId addChanceNode(const DiscreteVariable &variable, NodeId id=0)
Add a chance variable, it's associate node and it's CPT.
bool existsPathBetween(NodeId src, NodeId dest) const
Returns true if a path exists between two nodes.
std::string toString() const
INLINE void emplace(Args &&... args)
NodeId nodeId(const DiscreteVariable &var) const final
Return id node from discrete var pointer.
gum::DAG * getDecisionGraph() const
Returns the temporal Graph.
void removeTables_()
Removing ancient table.
bool existsPathBetween(const std::string &src, const std::string &dest) const
True if a directed path exist with all decision nodes.
NodeId addChanceNode(const DiscreteVariable &variable, MultiDimImplementation< GUM_SCALAR > *aContent, NodeId id=0)
Add a chance variable, it's associate node and it's CPT.
std::vector< NodeId > decisionOrder() const
Returns the sequence of decision nodes in the directed path.
Size decisionNodeSize() const
Returns the number of decision nodes.
virtual const Potential< GUM_SCALAR > & utility(NodeId varId) const
Returns the utility table of a utility node.
void changeVariableName(NodeId id, const std::string &new_name)
we allow the user to change the name of a variable
Size chanceNodeSize() const
Returns the number of chance nodes.
Size utilityNodeSize() const
Returns the number of utility nodes.
bool isChanceNode(const std::string &name) const
Returns the CPT of a potential variable.
void addArc(const std::string &tail, const std::string &head)
Add an arc in the ID, and update diagram's potential nodes cpt if necessary.
const DiscreteVariable & variableFromName(const std::string &name) const final
Getter by name.
virtual const Potential< GUM_SCALAR > & utility(std::string name) const final
Returns the CPT of a potential variable.
std::string toDot() const
void eraseArc(NodeId tail, NodeId head)
Removes an arc in the ID, and update diagram's potential nodes cpt if necessary.
const List< NodeSet > & getPartialTemporalOrder(bool clear=true) const
Returns partial temporal ordering.
NodeProperty< Potential< GUM_SCALAR > *> _utilityMap_
Mapping between utility variable's id and their utility table.
bool isDecisionNode(NodeId varId) const
Returns true if node is a decision one.
List< NodeSet > _temporalOrder_
The temporal order.
bool isUtilityNode(NodeId varId) const
Returns true if node is a utility one.
VariableNodeMap _variableMap_
Mapping between id and variable.
NodeId addNode_(const DiscreteVariable &variableType, NodeId DesiredId)
Add a node.
void changeVariableName(const std::string &name, const std::string &new_name)
Returns the CPT of a potential variable.
NodeId addUtilityNode(const DiscreteVariable &variable, MultiDimImplementation< GUM_SCALAR > *aContent, NodeId id=0)
Add a chance variable, it's associate node and it's CPT.
void eraseArc(const std::string &tail, const std::string &head)
Add an arc in the ID, and update diagram's potential nodes cpt if necessary.
bool decisionOrderExists() const
True if a directed path exist with all decision nodes.
Sequence< NodeId > getChildrenDecision_(NodeId parentDecision) const
Returns the list of children decision for a given nodeId.
void erase(const std::string &name)
Returns the CPT of a potential variable.
InfluenceDiagram< GUM_SCALAR > & operator=(const InfluenceDiagram< GUM_SCALAR > &source)
Copy Operator.
void copyStructureAndTables_(const InfluenceDiagram< GUM_SCALAR > &IDsource)
Copying tables from another influence diagram.
virtual void moralGraph_(UndiGraph &graph) const
Returns the moral graph of this InfluenceDiagram.
void erase(const DiscreteVariable &var)
Erase a Variable from the network and remove the variable from all his children.
void eraseArc(const Arc &arc)
Removes an arc in the ID, and update diagram's potential nodes cpt if necessary.
bool isUtilityNode(const std::string &name) const
Returns the CPT of a potential variable.
NodeId addUtilityNode(const DiscreteVariable &variable, NodeId id=0)
Add a utility variable, it's associate node and it's UT.
InfluenceDiagram()
Default constructor.
NodeId add(const DiscreteVariable &variable, NodeId id=0)
Add a chance variable, it's associate node and it's CPT.
InfluenceDiagram(const InfluenceDiagram< GUM_SCALAR > &source)
Copy Constructor.
virtual const Potential< GUM_SCALAR > & cpt(std::string name) const final
Returns the CPT of a potential variable.
NodeId addDecisionNode(const DiscreteVariable &variable, NodeId id=0)
Add a decision variable.
~InfluenceDiagram() override
Destructor.
const DiscreteVariable & variable(NodeId id) const final
Returns a constant reference over a variable given it's node id.
const VariableNodeMap & variableNodeMap() const final
Returns a constant reference to the VariableNodeMap of this Influence Diagram.
virtual const Potential< GUM_SCALAR > & cpt(NodeId varId) const
Returns the CPT of a potential variable.
bool isDecisionNode(const std::string &name) const
Returns the CPT of a potential variable.