![]() |
aGrUM
0.16.0
|
Class representing an Influence Diagram. More...
#include <agrum/ID/influenceDiagram.h>
Public Member Functions | |
std::string | toDot () const |
std::string | toString () const |
double | log10DomainSize () const |
bool | hasSameStructure (const DAGmodel &other) |
Constructors / Destructors | |
InfluenceDiagram () | |
Default constructor. More... | |
virtual | ~InfluenceDiagram () |
Destructor. More... | |
InfluenceDiagram (const InfluenceDiagram< GUM_SCALAR > &source) | |
Copy Constructor. More... | |
InfluenceDiagram< GUM_SCALAR > & | operator= (const InfluenceDiagram< GUM_SCALAR > &source) |
Copy Operator. More... | |
Variable manipulation methods. | |
virtual const Potential< GUM_SCALAR > & | cpt (NodeId varId) const |
Returns the CPT of a potential variable. More... | |
virtual const Potential< GUM_SCALAR > & | utility (NodeId varId) const |
Returns the utility table of a utility node. More... | |
virtual const VariableNodeMap & | variableNodeMap () const |
Returns a constant reference to the VariableNodeMap of this Influence Diagram. More... | |
bool | isUtilityNode (NodeId varId) const |
Returns true if node is a utility one. More... | |
bool | isDecisionNode (NodeId varId) const |
Returns true if node is a decision one. More... | |
bool | isChanceNode (NodeId varId) const |
Returns true if node is a chance one. More... | |
Size | utilityNodeSize () const |
Returns the number of utility nodes. More... | |
Size | chanceNodeSize () const |
Returns the number of chance nodes. More... | |
Size | decisionNodeSize () const |
Returns the number of decision nodes. More... | |
virtual const DiscreteVariable & | variable (NodeId id) const |
Returns a constant reference over a variabe given it's node id. More... | |
virtual NodeId | nodeId (const DiscreteVariable &var) const |
Return id node from discrete var pointer. More... | |
virtual NodeId | idFromName (const std::string &name) const |
Getter by name. More... | |
virtual const DiscreteVariable & | variableFromName (const std::string &name) const |
Getter by name. More... | |
NodeId | add (const DiscreteVariable &variable, NodeId id=0) |
Add a chance variable, it's associate node and it's CPT. More... | |
NodeId | addChanceNode (const DiscreteVariable &variable, NodeId id=0) |
Add a chance variable, it's associate node and it's CPT. More... | |
NodeId | addUtilityNode (const DiscreteVariable &variable, NodeId id=0) |
Add a utility variable, it's associate node and it's UT. More... | |
NodeId | addDecisionNode (const DiscreteVariable &variable, NodeId id=0) |
Add a decision variable. More... | |
NodeId | addChanceNode (const DiscreteVariable &variable, MultiDimImplementation< GUM_SCALAR > *aContent, NodeId id=0) |
Add a chance variable, it's associate node and it's CPT. More... | |
NodeId | addUtilityNode (const DiscreteVariable &variable, MultiDimImplementation< GUM_SCALAR > *aContent, NodeId id=0) |
Add a chance variable, it's associate node and it's CPT. More... | |
void | erase (NodeId id) |
Erase a Variable from the network and remove the variable from all his childs. More... | |
void | erase (const DiscreteVariable &var) |
Erase a Variable from the network and remove the variable from all his childs. More... | |
void | changeVariableName (NodeId id, const std::string &new_name) |
we allow the user to change the name of a variable More... | |
Arc manipulation methods. | |
void | addArc (NodeId tail, NodeId head) |
Add an arc in the ID, and update diagram's potential nodes cpt if necessary. More... | |
void | eraseArc (const Arc &arc) |
Removes an arc in the ID, and update diagram's potential nodes cpt if necessary. More... | |
void | eraseArc (NodeId tail, NodeId head) |
RRemoves an arc in the ID, and update diagram's potential nodes cpt if necessary. More... | |
Decisions methods | |
bool | decisionOrderExists () const |
True if a directed path exist with all decison nodes. More... | |
gum::DAG * | getDecisionGraph () const |
Returns the temporal Graph. More... | |
std::vector< NodeId > * | getDecisionOrder () const |
Returns the sequence of decision nodes in the directed path. More... | |
bool | existsPathBetween (NodeId src, NodeId dest) const |
Returns true if a path exists between two nodes. More... | |
const List< NodeSet > & | getPartialTemporalOrder (bool clear=true) const |
Returns partial temporal ordering. More... | |
Getter and setters | |
const std::string & | property (const std::string &name) const |
Return the value of the property name of this DAGModel. More... | |
const std::string & | propertyWithDefault (const std::string &name, const std::string &byDefault) const |
Return the value of the property name of this DAGModel. More... | |
void | setProperty (const std::string &name, const std::string &value) |
Add or change a property of this DAGModel. More... | |
Variable manipulation methods. | |
const DAG & | dag () const |
Returns a constant reference to the dag of this Bayes Net. More... | |
Size | size () const |
Returns the number of variables in this Directed Graphical Model. More... | |
Size | sizeArcs () const |
Returns the number of arcs in this Directed Graphical Model. More... | |
bool | empty () const |
Retursn true if this Directed Graphical Model is empty. More... | |
const NodeGraphPart & | nodes () const |
Returns a constant reference to the dag of this Bayes Net. More... | |
virtual Instantiation | completeInstantiation () const final |
Get an instantiation over all the variables of the model. More... | |
Arc manipulation methods. | |
const ArcSet & | arcs () const |
returns the set of nodes with arc ingoing to a given node More... | |
const NodeSet & | parents (const NodeId id) const |
returns the set of nodes with arc ingoing to a given node More... | |
const NodeSet & | parents (const std::string &name) const |
returns the set of nodes with arc ingoing to a given node More... | |
const NodeSet & | children (const NodeId id) const |
returns the set of nodes with arc outgoing from a given node More... | |
const NodeSet & | children (const std::string &name) const |
returns the set of nodes with arc ingoing to a given node More... | |
Graphical methods | |
const UndiGraph & | moralGraph (bool clear=true) const |
The node's id are coherent with the variables and nodes of the topology. More... | |
const Sequence< NodeId > & | topologicalOrder (bool clear=true) const |
The topological order stays the same as long as no variable or arcs are added or erased src the topology. More... | |
Protected Attributes | |
DAG | _dag |
The DAG of this Directed Graphical Model. More... | |
Protected Member Functions | |
virtual void | _moralGraph (UndiGraph &graph) const |
Returns the moral graph of this InfluenceDiagram. More... | |
void | _removeTables () |
Removing ancient table. More... | |
void | _copyTables (const InfluenceDiagram< GUM_SCALAR > &IDsource) |
Copying tables from another influence diagram. More... | |
NodeId | _addNode (const DiscreteVariable &variableType, NodeId DesiredId) |
Add a node. More... | |
Sequence< NodeId > | _getChildrenDecision (NodeId parentDecision) const |
Returns the list of children decision for a given nodeId. More... | |
Class representing an Influence Diagram.
Definition at line 54 of file influenceDiagram.h.
INLINE gum::InfluenceDiagram< GUM_SCALAR >::InfluenceDiagram | ( | ) |
Default constructor.
Definition at line 44 of file influenceDiagram_tpl.h.
|
virtual |
Destructor.
Definition at line 52 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::_removeTables().
gum::InfluenceDiagram< GUM_SCALAR >::InfluenceDiagram | ( | const InfluenceDiagram< GUM_SCALAR > & | source | ) |
Copy Constructor.
Definition at line 61 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::_copyTables(), and gum::InfluenceDiagram< GUM_SCALAR >::operator=().
|
protected |
Add a node.
Definition at line 466 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__variableMap, gum::DAGmodel::_dag, gum::NodeGraphPart::addNodeWithId(), gum::VariableNodeMap::insert(), and gum::NodeGraphPart::nextNodeId().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::addChanceNode(), gum::InfluenceDiagram< GUM_SCALAR >::addDecisionNode(), and gum::InfluenceDiagram< GUM_SCALAR >::addUtilityNode().
|
protected |
Copying tables from another influence diagram.
Definition at line 108 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__potentialMap, gum::InfluenceDiagram< GUM_SCALAR >::__utilityMap, gum::DAGmodel::_dag, gum::Instantiation::chgVal(), gum::Instantiation::end(), gum::Instantiation::inc(), gum::Instantiation::nbrDim(), gum::InfluenceDiagram< GUM_SCALAR >::nodeId(), gum::ArcGraphPart::parents(), gum::Instantiation::setFirst(), gum::Instantiation::val(), gum::InfluenceDiagram< GUM_SCALAR >::variable(), and gum::Instantiation::variable().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::InfluenceDiagram(), and gum::InfluenceDiagram< GUM_SCALAR >::operator=().
|
protected |
Returns the list of children decision for a given nodeId.
Definition at line 699 of file influenceDiagram_tpl.h.
References gum::DAGmodel::_dag, gum::ArcGraphPart::children(), gum::List< Val, Alloc >::empty(), gum::List< Val, Alloc >::front(), gum::SequenceImplementation< Key, Alloc, Gen >::insert(), gum::InfluenceDiagram< GUM_SCALAR >::isDecisionNode(), gum::NodeGraphPart::nodesProperty(), gum::List< Val, Alloc >::popFront(), and gum::List< Val, Alloc >::pushBack().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::getDecisionGraph().
|
protectedvirtual |
Returns the moral graph of this InfluenceDiagram.
Definition at line 590 of file influenceDiagram_tpl.h.
References gum::DAGmodel::_dag, gum::UndiGraph::addEdge(), gum::NodeGraphPart::addNodeWithId(), gum::InfluenceDiagram< GUM_SCALAR >::isChanceNode(), gum::InfluenceDiagram< GUM_SCALAR >::isDecisionNode(), gum::InfluenceDiagram< GUM_SCALAR >::isUtilityNode(), gum::NodeGraphPart::nodes(), and gum::ArcGraphPart::parents().
|
protected |
Removing ancient table.
Definition at line 95 of file influenceDiagram_tpl.h.
References gum::DAGmodel::_dag, gum::InfluenceDiagram< GUM_SCALAR >::cpt(), gum::InfluenceDiagram< GUM_SCALAR >::isChanceNode(), gum::InfluenceDiagram< GUM_SCALAR >::isUtilityNode(), gum::NodeGraphPart::nodes(), and gum::InfluenceDiagram< GUM_SCALAR >::utility().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::operator=(), and gum::InfluenceDiagram< GUM_SCALAR >::~InfluenceDiagram().
NodeId gum::InfluenceDiagram< GUM_SCALAR >::add | ( | const DiscreteVariable & | variable, |
NodeId | id = 0 |
||
) |
Add a chance variable, it's associate node and it's CPT.
The id of the new variable is automatically generated.
The implementation of the Potential is by default a MultiDimArray.
variable | The variable added by copy. |
id | The chosen id. If 0, the NodeGraphPart will choose. |
DuplicateElement | if id(<>0) is already used |
Definition at line 358 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::addChanceNode().
INLINE void gum::InfluenceDiagram< GUM_SCALAR >::addArc | ( | NodeId | tail, |
NodeId | head | ||
) |
Add an arc in the ID, and update diagram's potential nodes cpt if necessary.
head | and |
tail | as NodeId |
InvalidEdge | If arc.tail and/or arc.head are not in the ID. |
InvalidEdge | if tail is a utility node |
Definition at line 537 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__potentialMap, gum::InfluenceDiagram< GUM_SCALAR >::__utilityMap, gum::DAGmodel::_dag, gum::DAG::addArc(), GUM_ERROR, gum::InfluenceDiagram< GUM_SCALAR >::isChanceNode(), gum::InfluenceDiagram< GUM_SCALAR >::isUtilityNode(), and gum::InfluenceDiagram< GUM_SCALAR >::variable().
Referenced by gum::InfluenceDiagramGenerator< GUM_SCALAR >::__checkTemporalOrder(), and gum::InfluenceDiagramGenerator< GUM_SCALAR >::generateID().
NodeId gum::InfluenceDiagram< GUM_SCALAR >::addChanceNode | ( | const DiscreteVariable & | variable, |
NodeId | id = 0 |
||
) |
Add a chance variable, it's associate node and it's CPT.
The id of the new variable is automatically generated.
The implementation of the Potential is by default a MultiDimArray.
variable | The variable added by copy. |
id | The chosen id. If 0, the NodeGraphPart will choose. |
DuplicateElement | if id(<>0) is already used |
Definition at line 401 of file influenceDiagram_tpl.h.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::add(), and gum::InfluenceDiagramGenerator< GUM_SCALAR >::generateID().
NodeId gum::InfluenceDiagram< GUM_SCALAR >::addChanceNode | ( | const DiscreteVariable & | variable, |
MultiDimImplementation< GUM_SCALAR > * | aContent, | ||
NodeId | id = 0 |
||
) |
Add a chance variable, it's associate node and it's CPT.
The id of the new variable is automatically generated.
variable | The variable added by copy. |
aContent | The content used for the variable potential. |
id | The chosen id. If 0, the NodeGraphPart will choose. |
DuplicateElement | if id(<>0) is already used |
Definition at line 421 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__potentialMap, gum::InfluenceDiagram< GUM_SCALAR >::_addNode(), and gum::InfluenceDiagram< GUM_SCALAR >::variable().
NodeId gum::InfluenceDiagram< GUM_SCALAR >::addDecisionNode | ( | const DiscreteVariable & | variable, |
NodeId | id = 0 |
||
) |
Add a decision variable.
The id of the new variable is automatically generated.
variable | The variable added by copy. |
id | The chosen id. If 0, the NodeGraphPart will choose. |
DuplicateElement | if id(<>0) is already used |
Definition at line 391 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::_addNode().
Referenced by gum::InfluenceDiagramGenerator< GUM_SCALAR >::generateID().
NodeId gum::InfluenceDiagram< GUM_SCALAR >::addUtilityNode | ( | const DiscreteVariable & | variable, |
NodeId | id = 0 |
||
) |
Add a utility variable, it's associate node and it's UT.
The id of the new variable is automatically generated.
The implementation of the Utility is by default a MultiDimArray.
variable | The variable added by copy. |
id | The chosen id. If 0, the NodeGraphPart will choose. |
InvalidAgrument | If variable has more than one label |
DuplicateElement | if id(<>0) is already used |
Definition at line 370 of file influenceDiagram_tpl.h.
Referenced by gum::InfluenceDiagramGenerator< GUM_SCALAR >::generateID().
NodeId gum::InfluenceDiagram< GUM_SCALAR >::addUtilityNode | ( | const DiscreteVariable & | variable, |
MultiDimImplementation< GUM_SCALAR > * | aContent, | ||
NodeId | id = 0 |
||
) |
Add a chance variable, it's associate node and it's CPT.
The id of the new variable is automatically generated.
variable | The variable added by copy. |
aContent | The content used for the variable utility. |
id | The chosen id. If 0, the NodeGraphPart will choose. |
InvalidAgrument | If variable has more than one label |
DuplicateElement | if id(<>0) is already used |
Definition at line 440 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__utilityMap, gum::InfluenceDiagram< GUM_SCALAR >::_addNode(), gum::DiscreteVariable::domainSize(), GUM_ERROR, and gum::InfluenceDiagram< GUM_SCALAR >::variable().
|
inherited |
returns the set of nodes with arc ingoing to a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the arcs returned are pointing |
Definition at line 104 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag, and gum::ArcGraphPart::arcs().
Referenced by gum::EssentialGraph::__buildEssentialGraph(), gum::DAGmodel::__moralGraph(), gum::MarkovBlanket::hasSameStructure(), and gum::DAGmodel::hasSameStructure().
INLINE Size gum::InfluenceDiagram< GUM_SCALAR >::chanceNodeSize | ( | ) | const |
Returns the number of chance nodes.
Definition at line 299 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__potentialMap.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::toString().
INLINE void gum::InfluenceDiagram< GUM_SCALAR >::changeVariableName | ( | NodeId | id, |
const std::string & | new_name | ||
) |
we allow the user to change the name of a variable
DuplicateLabel | if this name already exists |
NotFound | Raised if no nodes matches id. |
Definition at line 525 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__variableMap, and gum::VariableNodeMap::changeName().
returns the set of nodes with arc outgoing from a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is outgoing from the given node.
id | the node which is the tail of the arcs returned |
Definition at line 111 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag, and gum::ArcGraphPart::children().
Referenced by gum::MarkovBlanket::__buildMarkovBlanket(), gum::DAGmodel::parents(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::prm::ClassBayesNet< GUM_SCALAR >::toDot().
|
inlineinherited |
returns the set of nodes with arc ingoing to a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the arcs returned are pointing |
Definition at line 165 of file DAGmodel.h.
References gum::DAGmodel::hasSameStructure(), gum::DAGmodel::idFromName(), gum::DAGmodel::log10DomainSize(), gum::DAGmodel::moralGraph(), gum::DAGmodel::operator=(), gum::DAGmodel::parents(), and gum::DAGmodel::topologicalOrder().
|
finalvirtualinherited |
Get an instantiation over all the variables of the model.
Definition at line 86 of file DAGmodel_inl.h.
References gum::DAGmodel::dag(), and gum::DAGmodel::variable().
|
virtual |
Returns the CPT of a potential variable.
NotFound | If no variable's id matches varId. |
Definition at line 246 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__potentialMap.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::_removeTables(), and gum::InfluenceDiagramGenerator< GUM_SCALAR >::generateID().
|
inherited |
Returns a constant reference to the dag of this Bayes Net.
Definition at line 63 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag.
Referenced by gum::DAGmodel::__moralGraph(), gum::DAGmodel::completeInstantiation(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::learning::genericBNLearner::Database::Database(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), gum::MarginalTargetedInference< GUM_SCALAR >::MarginalTargetedInference(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), gum::DAGmodel::size(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::DAGmodel::topologicalOrder(), gum::InfluenceDiagram< GUM_SCALAR >::toString(), and gum::BayesNetFragment< GUM_SCALAR >::whenArcDeleted().
INLINE Size gum::InfluenceDiagram< GUM_SCALAR >::decisionNodeSize | ( | ) | const |
Returns the number of decision nodes.
Definition at line 307 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__potentialMap, gum::InfluenceDiagram< GUM_SCALAR >::__utilityMap, and gum::DAGmodel::size().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::toString().
bool gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists | ( | ) | const |
True if a directed path exist with all decison nodes.
Definition at line 609 of file influenceDiagram_tpl.h.
References gum::SequenceImplementation< Key, Alloc, Gen >::begin(), gum::SequenceImplementation< Key, Alloc, Gen >::end(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), gum::InfluenceDiagram< GUM_SCALAR >::isDecisionNode(), and gum::DAGmodel::topologicalOrder().
Referenced by gum::InfluenceDiagramGenerator< GUM_SCALAR >::__checkTemporalOrder(), and gum::InfluenceDiagram< GUM_SCALAR >::getDecisionOrder().
|
inherited |
Retursn true if this Directed Graphical Model is empty.
Definition at line 99 of file DAGmodel_inl.h.
References gum::DAGmodel::size().
void gum::InfluenceDiagram< GUM_SCALAR >::erase | ( | NodeId | id | ) |
Erase a Variable from the network and remove the variable from all his childs.
If no variable matches the id, then nothing is done.
id | The id of the variable to erase. |
Definition at line 490 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__potentialMap, gum::InfluenceDiagram< GUM_SCALAR >::__utilityMap, gum::InfluenceDiagram< GUM_SCALAR >::__variableMap, gum::DAGmodel::_dag, gum::ArcGraphPart::children(), gum::VariableNodeMap::erase(), gum::DiGraph::eraseNode(), gum::VariableNodeMap::exists(), gum::InfluenceDiagram< GUM_SCALAR >::isChanceNode(), gum::InfluenceDiagram< GUM_SCALAR >::isUtilityNode(), and gum::InfluenceDiagram< GUM_SCALAR >::variable().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::erase().
INLINE void gum::InfluenceDiagram< GUM_SCALAR >::erase | ( | const DiscreteVariable & | var | ) |
Erase a Variable from the network and remove the variable from all his childs.
If no variable matches, then nothing is done.
var | The reference on the variable to remove. |
Definition at line 518 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__variableMap, gum::InfluenceDiagram< GUM_SCALAR >::erase(), and gum::VariableNodeMap::get().
INLINE void gum::InfluenceDiagram< GUM_SCALAR >::eraseArc | ( | const Arc & | arc | ) |
Removes an arc in the ID, and update diagram's potential nodes cpt if necessary.
If (tail, head) doesn't exist, the nothing happens.
arc | The arc removed. |
Definition at line 558 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__potentialMap, gum::InfluenceDiagram< GUM_SCALAR >::__utilityMap, gum::DAGmodel::_dag, gum::ArcGraphPart::eraseArc(), gum::ArcGraphPart::existsArc(), gum::Arc::head(), gum::InfluenceDiagram< GUM_SCALAR >::isChanceNode(), gum::InfluenceDiagram< GUM_SCALAR >::isUtilityNode(), gum::Arc::tail(), and gum::InfluenceDiagram< GUM_SCALAR >::variable().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::eraseArc().
INLINE void gum::InfluenceDiagram< GUM_SCALAR >::eraseArc | ( | NodeId | tail, |
NodeId | head | ||
) |
RRemoves an arc in the ID, and update diagram's potential nodes cpt if necessary.
If (tail, head) doesn't exist, the nothing happens.
head | and |
tail | as NodeId |
Definition at line 578 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::eraseArc().
bool gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween | ( | NodeId | src, |
NodeId | dest | ||
) | const |
Returns true if a path exists between two nodes.
Definition at line 641 of file influenceDiagram_tpl.h.
References gum::DAGmodel::_dag, gum::ArcGraphPart::children(), gum::List< Val, Alloc >::empty(), gum::List< Val, Alloc >::front(), gum::NodeGraphPart::nodesProperty(), gum::List< Val, Alloc >::popFront(), and gum::List< Val, Alloc >::pushBack().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists().
gum::DAG * gum::InfluenceDiagram< GUM_SCALAR >::getDecisionGraph | ( | ) | const |
Returns the temporal Graph.
Definition at line 677 of file influenceDiagram_tpl.h.
References gum::DAGmodel::_dag, gum::InfluenceDiagram< GUM_SCALAR >::_getChildrenDecision(), gum::DAG::addArc(), gum::NodeGraphPart::addNodeWithId(), gum::NodeGraphPart::existsNode(), gum::InfluenceDiagram< GUM_SCALAR >::isDecisionNode(), and gum::NodeGraphPart::nodes().
std::vector< NodeId > * gum::InfluenceDiagram< GUM_SCALAR >::getDecisionOrder | ( | ) | const |
Returns the sequence of decision nodes in the directed path.
NotFound | if such a path does not exist |
Definition at line 738 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists(), GUM_ERROR, gum::InfluenceDiagram< GUM_SCALAR >::isDecisionNode(), and gum::DAGmodel::topologicalOrder().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder().
const List< NodeSet > & gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder | ( | bool | clear = true | ) | const |
Returns partial temporal ordering.
NotFound | if such a sequence does not exist |
Definition at line 755 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__temporalOrder, gum::DAGmodel::_dag, gum::NodeGraphPart::asNodeSet(), gum::Set< Key, Alloc >::contains(), gum::Set< Key, Alloc >::empty(), gum::Set< Key, Alloc >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::getDecisionOrder(), gum::Set< Key, Alloc >::insert(), gum::InfluenceDiagram< GUM_SCALAR >::isChanceNode(), and gum::ArcGraphPart::parents().
Definition at line 121 of file DAGmodel.cpp.
References gum::DAGmodel::arcs(), gum::Set< Key, Alloc >::exists(), gum::DAGmodel::idFromName(), gum::DAGmodel::nodes(), gum::DAGmodel::size(), gum::DAGmodel::sizeArcs(), and gum::DAGmodel::variable().
Referenced by gum::DAGmodel::children().
|
virtual |
Getter by name.
NotFound | if no such name exists in the graph. |
Implements gum::DAGmodel.
Definition at line 342 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__variableMap, and gum::VariableNodeMap::idFromName().
INLINE bool gum::InfluenceDiagram< GUM_SCALAR >::isChanceNode | ( | NodeId | varId | ) | const |
Returns true if node is a chance one.
Definition at line 283 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__potentialMap.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::_moralGraph(), gum::InfluenceDiagram< GUM_SCALAR >::_removeTables(), gum::InfluenceDiagram< GUM_SCALAR >::addArc(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), gum::InfluenceDiagramGenerator< GUM_SCALAR >::generateID(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), gum::InfluenceDiagram< GUM_SCALAR >::isDecisionNode(), and gum::InfluenceDiagram< GUM_SCALAR >::toDot().
INLINE bool gum::InfluenceDiagram< GUM_SCALAR >::isDecisionNode | ( | NodeId | varId | ) | const |
Returns true if node is a decision one.
Definition at line 271 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::isChanceNode(), and gum::InfluenceDiagram< GUM_SCALAR >::isUtilityNode().
Referenced by gum::InfluenceDiagramGenerator< GUM_SCALAR >::__checkTemporalOrder(), gum::InfluenceDiagram< GUM_SCALAR >::_getChildrenDecision(), gum::InfluenceDiagram< GUM_SCALAR >::_moralGraph(), gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists(), gum::InfluenceDiagram< GUM_SCALAR >::getDecisionGraph(), and gum::InfluenceDiagram< GUM_SCALAR >::getDecisionOrder().
INLINE bool gum::InfluenceDiagram< GUM_SCALAR >::isUtilityNode | ( | NodeId | varId | ) | const |
Returns true if node is a utility one.
Definition at line 263 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__utilityMap.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::_moralGraph(), gum::InfluenceDiagram< GUM_SCALAR >::_removeTables(), gum::InfluenceDiagram< GUM_SCALAR >::addArc(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), gum::InfluenceDiagramGenerator< GUM_SCALAR >::generateID(), gum::InfluenceDiagram< GUM_SCALAR >::isDecisionNode(), and gum::InfluenceDiagram< GUM_SCALAR >::toDot().
|
inherited |
Definition at line 75 of file DAGmodel_inl.h.
References gum::DAGmodel::nodes(), and gum::DAGmodel::variable().
Referenced by gum::DAGmodel::children(), and gum::InfluenceDiagram< GUM_SCALAR >::toString().
The node's id are coherent with the variables and nodes of the topology.
clear | If false returns the previously created moral graph. |
Definition at line 101 of file DAGmodel.cpp.
References gum::DAGmodel::__moralGraph(), gum::DAGmodel::__mutableMoralGraph, and gum::UndiGraph::clear().
Referenced by gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes(), and gum::DAGmodel::children().
|
virtual |
Return id node from discrete var pointer.
NotFound | If no variable matches var. |
Implements gum::DAGmodel.
Definition at line 335 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__variableMap, and gum::VariableNodeMap::get().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::_copyTables().
|
inherited |
Returns a constant reference to the dag of this Bayes Net.
Definition at line 115 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag.
Referenced by gum::credal::CredalNet< GUM_SCALAR >::__bnCopy(), gum::EssentialGraph::__buildEssentialGraph(), gum::MarkovBlanket::__buildMarkovBlanket(), gum::DAGmodel::__moralGraph(), gum::credal::CredalNet< GUM_SCALAR >::__sort_varType(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__verticesSampling(), gum::ImportanceSampling< GUM_SCALAR >::_unsharpenBN(), gum::BayesNetFactory< GUM_SCALAR >::BayesNetFactory(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::disturbBN(), gum::Estimator< GUM_SCALAR >::Estimator(), gum::getMaxModality(), gum::DAGmodel::hasSameStructure(), gum::DAGmodel::log10DomainSize(), gum::prm::InstanceBayesNet< GUM_SCALAR >::modalities(), gum::prm::ClassBayesNet< GUM_SCALAR >::modalities(), gum::Estimator< GUM_SCALAR >::setFromBN(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), gum::prm::ClassBayesNet< GUM_SCALAR >::toDot(), gum::credal::CredalNet< GUM_SCALAR >::toString(), and gum::BayesNetFragment< GUM_SCALAR >::~BayesNetFragment().
InfluenceDiagram< GUM_SCALAR > & gum::InfluenceDiagram< GUM_SCALAR >::operator= | ( | const InfluenceDiagram< GUM_SCALAR > & | source | ) |
Copy Operator.
Definition at line 74 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__potentialMap, gum::InfluenceDiagram< GUM_SCALAR >::__utilityMap, gum::InfluenceDiagram< GUM_SCALAR >::__variableMap, gum::InfluenceDiagram< GUM_SCALAR >::_copyTables(), gum::InfluenceDiagram< GUM_SCALAR >::_removeTables(), and gum::DAGmodel::operator=().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::InfluenceDiagram().
returns the set of nodes with arc ingoing to a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the arcs returned are pointing |
Definition at line 106 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag, and gum::ArcGraphPart::parents().
Referenced by gum::MarkovBlanket::__buildMarkovBlanket(), gum::DAGmodel::__moralGraph(), gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::DAGmodel::children(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), gum::DAGmodel::parents(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::prm::ClassBayesNet< GUM_SCALAR >::toDot().
|
inlineinherited |
returns the set of nodes with arc ingoing to a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the arcs returned are pointing |
Definition at line 156 of file DAGmodel.h.
References gum::DAGmodel::children(), gum::DAGmodel::idFromName(), and gum::DAGmodel::parents().
|
inherited |
Return the value of the property name of this DAGModel.
NotFound | Raised if no name property is found. |
Definition at line 37 of file DAGmodel_inl.h.
References gum::DAGmodel::__properties(), and GUM_ERROR.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::toDot().
|
inherited |
Return the value of the property name of this DAGModel.
return byDefault if the property name is not found
Definition at line 48 of file DAGmodel_inl.h.
References gum::DAGmodel::__properties().
|
inherited |
Add or change a property of this DAGModel.
Definition at line 56 of file DAGmodel_inl.h.
References gum::DAGmodel::__properties(), and gum::HashTable< Key, Val, Alloc >::insert().
Referenced by gum::BayesNet< double >::fastPrototype().
|
inherited |
Returns the number of variables in this Directed Graphical Model.
Definition at line 96 of file DAGmodel_inl.h.
References gum::DAGmodel::dag(), and gum::NodeGraphPart::size().
Referenced by gum::credal::CredalNet< GUM_SCALAR >::__initCNNets(), gum::InfluenceDiagram< GUM_SCALAR >::decisionNodeSize(), gum::DAGmodel::empty(), gum::MarkovBlanket::hasSameStructure(), gum::DAGmodel::hasSameStructure(), gum::IBayesNet< double >::operator==(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::prm::ClassBayesNet< GUM_SCALAR >::toDot().
|
inherited |
Returns the number of arcs in this Directed Graphical Model.
Definition at line 102 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag, and gum::ArcGraphPart::sizeArcs().
Referenced by gum::MarkovBlanket::hasSameStructure(), gum::DAGmodel::hasSameStructure(), and gum::IBayesNet< double >::operator==().
std::string gum::InfluenceDiagram< GUM_SCALAR >::toDot | ( | ) | const |
Definition at line 167 of file influenceDiagram_tpl.h.
References gum::DAGmodel::_dag, gum::ArcGraphPart::children(), gum::InfluenceDiagram< GUM_SCALAR >::isChanceNode(), gum::InfluenceDiagram< GUM_SCALAR >::isUtilityNode(), gum::Variable::name(), gum::NodeGraphPart::nodes(), gum::DAGmodel::property(), gum::Set< Key, Alloc >::size(), and gum::InfluenceDiagram< GUM_SCALAR >::variable().
The topological order stays the same as long as no variable or arcs are added or erased src the topology.
clear | If false returns the previously created topology. |
Definition at line 117 of file DAGmodel.cpp.
References gum::DAGmodel::dag(), and gum::DiGraph::topologicalOrder().
Referenced by gum::EssentialGraph::__buildEssentialGraph(), gum::InfluenceDiagramGenerator< GUM_SCALAR >::__checkTemporalOrder(), gum::DAGmodel::children(), gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists(), and gum::InfluenceDiagram< GUM_SCALAR >::getDecisionOrder().
std::string gum::InfluenceDiagram< GUM_SCALAR >::toString | ( | ) | const |
Definition at line 216 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::chanceNodeSize(), gum::DAGmodel::dag(), gum::InfluenceDiagram< GUM_SCALAR >::decisionNodeSize(), gum::DAGmodel::log10DomainSize(), gum::ArcGraphPart::sizeArcs(), and gum::InfluenceDiagram< GUM_SCALAR >::utilityNodeSize().
|
virtual |
Returns the utility table of a utility node.
NotFound | If no variable's id matches varId. |
Definition at line 255 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__utilityMap.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::_removeTables(), and gum::InfluenceDiagramGenerator< GUM_SCALAR >::generateID().
INLINE Size gum::InfluenceDiagram< GUM_SCALAR >::utilityNodeSize | ( | ) | const |
Returns the number of utility nodes.
Definition at line 291 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__utilityMap.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::toString().
|
virtual |
Returns a constant reference over a variabe given it's node id.
NotFound | If no variable's id matches varId. |
Implements gum::DAGmodel.
Definition at line 326 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__variableMap.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::_copyTables(), gum::InfluenceDiagram< GUM_SCALAR >::addArc(), gum::InfluenceDiagram< GUM_SCALAR >::addChanceNode(), gum::InfluenceDiagram< GUM_SCALAR >::addUtilityNode(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), gum::InfluenceDiagramGenerator< GUM_SCALAR >::generateID(), and gum::InfluenceDiagram< GUM_SCALAR >::toDot().
|
virtual |
Getter by name.
NotFound | if no such name exists in the graph. |
Implements gum::DAGmodel.
Definition at line 348 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__variableMap, and gum::VariableNodeMap::variableFromName().
|
virtual |
Returns a constant reference to the VariableNodeMap of this Influence Diagram.
Implements gum::DAGmodel.
Definition at line 317 of file influenceDiagram_tpl.h.
References gum::InfluenceDiagram< GUM_SCALAR >::__variableMap.
|
private |
Mapping between potential variable's id and their CPT.
Definition at line 387 of file influenceDiagram.h.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::_copyTables(), gum::InfluenceDiagram< GUM_SCALAR >::addArc(), gum::InfluenceDiagram< GUM_SCALAR >::addChanceNode(), gum::InfluenceDiagram< GUM_SCALAR >::chanceNodeSize(), gum::InfluenceDiagram< GUM_SCALAR >::cpt(), gum::InfluenceDiagram< GUM_SCALAR >::decisionNodeSize(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), gum::InfluenceDiagram< GUM_SCALAR >::isChanceNode(), and gum::InfluenceDiagram< GUM_SCALAR >::operator=().
|
mutableprivate |
The temporal order.
Definition at line 392 of file influenceDiagram.h.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder().
|
private |
Mapping between utility variable's id and their utility table.
Definition at line 389 of file influenceDiagram.h.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::_copyTables(), gum::InfluenceDiagram< GUM_SCALAR >::addArc(), gum::InfluenceDiagram< GUM_SCALAR >::addUtilityNode(), gum::InfluenceDiagram< GUM_SCALAR >::decisionNodeSize(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), gum::InfluenceDiagram< GUM_SCALAR >::isUtilityNode(), gum::InfluenceDiagram< GUM_SCALAR >::operator=(), gum::InfluenceDiagram< GUM_SCALAR >::utility(), and gum::InfluenceDiagram< GUM_SCALAR >::utilityNodeSize().
|
private |
Mapping between id and variable.
Definition at line 384 of file influenceDiagram.h.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::_addNode(), gum::InfluenceDiagram< GUM_SCALAR >::changeVariableName(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::idFromName(), gum::InfluenceDiagram< GUM_SCALAR >::nodeId(), gum::InfluenceDiagram< GUM_SCALAR >::operator=(), gum::InfluenceDiagram< GUM_SCALAR >::variable(), gum::InfluenceDiagram< GUM_SCALAR >::variableFromName(), and gum::InfluenceDiagram< GUM_SCALAR >::variableNodeMap().
|
protectedinherited |
The DAG of this Directed Graphical Model.
Definition at line 203 of file DAGmodel.h.
Referenced by gum::prm::ClassBayesNet< GUM_SCALAR >::__get(), gum::InfluenceDiagram< GUM_SCALAR >::_addNode(), gum::InfluenceDiagram< GUM_SCALAR >::_copyTables(), gum::InfluenceDiagram< GUM_SCALAR >::_getChildrenDecision(), gum::BayesNetFragment< GUM_SCALAR >::_installArc(), gum::InfluenceDiagram< GUM_SCALAR >::_moralGraph(), gum::InfluenceDiagram< GUM_SCALAR >::_removeTables(), gum::BayesNetFragment< GUM_SCALAR >::_uninstallArc(), gum::InfluenceDiagram< GUM_SCALAR >::addArc(), gum::DAGmodel::arcs(), gum::DAGmodel::children(), gum::DAGmodel::dag(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), gum::InfluenceDiagram< GUM_SCALAR >::getDecisionGraph(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), gum::BayesNetFragment< GUM_SCALAR >::installNode(), gum::DAGmodel::nodes(), gum::DAGmodel::operator=(), gum::DAGmodel::parents(), gum::DAGmodel::sizeArcs(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallNode().