![]() |
aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
|
The base class for structural constraints used by learning algorithms that learn a directed graph structure. More...
#include <structuralConstraintDiGraph.h>
Public Types | |
| using | allConstraints = _ConstraintSet_< void > |
Public Member Functions | |
Constructors / Destructors | |
| StructuralConstraintDiGraph () | |
| default constructor | |
| StructuralConstraintDiGraph (Size nb_nodes) | |
| constructor starting with an empty graph with a given number of nodes | |
| StructuralConstraintDiGraph (const DiGraph &graph) | |
| constructor starting with a given graph | |
| StructuralConstraintDiGraph (const StructuralConstraintDiGraph &from) | |
| copy constructor | |
| StructuralConstraintDiGraph (StructuralConstraintDiGraph &&from) noexcept | |
| move constructor | |
| virtual | ~StructuralConstraintDiGraph () |
| destructor | |
Operators | |
| StructuralConstraintDiGraph & | operator= (const StructuralConstraintDiGraph &from) |
| copy operator | |
| StructuralConstraintDiGraph & | operator= (StructuralConstraintDiGraph &&from) |
| move operator | |
Specific Accessors / Modifiers | |
| void | setGraph (Size nb_nodes) |
| sets a new empty graph from which we will perform checking | |
| void | setGraphAlone (const DiGraph &graph) |
| sets a new graph from which we will perform checking | |
| void | modifyGraphAlone (const ArcAddition &change) |
| notify the constraint of a modification of the graph | |
| void | modifyGraphAlone (const ArcDeletion &change) |
| notify the constraint of a modification of the graph | |
| void | modifyGraphAlone (const ArcReversal &change) |
| notify the constraint of a modification of the graph | |
| void | modifyGraphAlone (const ArcTriangleDeletion1 &change) |
| notify the constraint of a modification of the graph | |
| void | modifyGraphAlone (const ArcTriangleDeletion2 &change) |
| notify the constraint of a modification of the graph | |
| void | modifyGraphAlone (const GraphChange &change) |
| notify the constraint of a modification of the graph | |
| bool | isAlwaysInvalidAlone (const GraphChange &change) const |
| indicates whether a change will always violate the constraint | |
| bool | checkArcAdditionAlone (NodeId x, NodeId y) const |
| checks whether the constraints enable to add arc (x,y) | |
| bool | checkArcDeletionAlone (NodeId x, NodeId y) const |
| checks whether the constraints enable to remove arc (x,y) | |
| bool | checkArcReversalAlone (NodeId x, NodeId y) const |
| checks whether the constraints enable to reverse arc (x,y) | |
| bool | checkArcTriangleDeletion1Alone (NodeId node1, NodeId node2, NodeId node3) const |
| checks whether the constraints enable to apply an ArcTriangleDeletion1 | |
| bool | checkArcTriangleDeletion2Alone (NodeId node1, NodeId node2, NodeId node3) const |
| checks whether the constraints enable to apply an ArcTriangleDeletion2 | |
| bool | checkModificationAlone (const GraphChange &change) const |
| checks whether the constraints enable to perform a graph change | |
| bool | checkModificationAlone (const ArcAddition &change) const |
| checks whether the constraints enable to add an arc | |
| bool | checkModificationAlone (const ArcDeletion &change) const |
| checks whether the constraints enable to remove an arc | |
| bool | checkModificationAlone (const ArcReversal &change) const |
| checks whether the constraints enable to reverse an arc | |
| bool | checkModificationAlone (const ArcTriangleDeletion1 &change) const |
| checks whether the constraints enable to apply an ArcTriangleDeletion1 | |
| bool | checkModificationAlone (const ArcTriangleDeletion2 &change) const |
| checks whether the constraints enable to apply an ArcTriangleDeletion2 | |
Protected Attributes | |
| DiGraph | _graph_ |
| the DiGraph on which we perform checks | |
The base class for structural constraints used by learning algorithms that learn a directed graph structure.
This base should always be a virtual parents of the structural constraints classes. This will allow to combine different constraints into a single class
Definition at line 68 of file structuralConstraintDiGraph.h.
|
inherited |
Definition at line 61 of file structuralConstraint.h.
| gum::learning::StructuralConstraintDiGraph::StructuralConstraintDiGraph | ( | ) |
default constructor
Definition at line 61 of file structuralConstraintDiGraph.cpp.
References StructuralConstraintDiGraph().
Referenced by StructuralConstraintDiGraph(), StructuralConstraintDiGraph(), StructuralConstraintDiGraph(), StructuralConstraintDiGraph(), StructuralConstraintDiGraph(), ~StructuralConstraintDiGraph(), operator=(), and operator=().
| gum::learning::StructuralConstraintDiGraph::StructuralConstraintDiGraph | ( | Size | nb_nodes | ) |
constructor starting with an empty graph with a given number of nodes
Definition at line 66 of file structuralConstraintDiGraph.cpp.
References StructuralConstraintDiGraph(), and setGraph().
| gum::learning::StructuralConstraintDiGraph::StructuralConstraintDiGraph | ( | const DiGraph & | graph | ) |
constructor starting with a given graph
Definition at line 72 of file structuralConstraintDiGraph.cpp.
References StructuralConstraintDiGraph(), and setGraph().
| gum::learning::StructuralConstraintDiGraph::StructuralConstraintDiGraph | ( | const StructuralConstraintDiGraph & | from | ) |
copy constructor
Definition at line 78 of file structuralConstraintDiGraph.cpp.
References StructuralConstraintDiGraph(), and _graph_.
|
noexcept |
move constructor
Definition at line 84 of file structuralConstraintDiGraph.cpp.
References StructuralConstraintDiGraph(), and _graph_.
|
virtual |
destructor
Definition at line 90 of file structuralConstraintDiGraph.cpp.
References StructuralConstraintDiGraph().
checks whether the constraints enable to add arc (x,y)
an arc can be added if and only if its extremal nodes belong to the graph and the arc does not already exist.
Referenced by checkModificationAlone().
checks whether the constraints enable to remove arc (x,y)
an arc can be removed if and only if the arc exists.
Referenced by checkModificationAlone().
checks whether the constraints enable to reverse arc (x,y)
an arc can be reversed if and only if it exists and arc (y,x) does not.
Referenced by checkModificationAlone().
| bool gum::learning::StructuralConstraintDiGraph::checkArcTriangleDeletion1Alone | ( | NodeId | node1, |
| NodeId | node2, | ||
| NodeId | node3 ) const |
checks whether the constraints enable to apply an ArcTriangleDeletion1
An arc triangle deletion1 substitutes triangle node1 -> node2 -> node3 + node1 -> node3 into v-structure node2 -> node1 <- node3
Referenced by checkModificationAlone().
| bool gum::learning::StructuralConstraintDiGraph::checkArcTriangleDeletion2Alone | ( | NodeId | node1, |
| NodeId | node2, | ||
| NodeId | node3 ) const |
checks whether the constraints enable to apply an ArcTriangleDeletion2
An arc triangle deletion1 substitutes triangle node1 -> node2 -> node3 + node1 -> node3 into v-structure node1 -> node2 <- node3
Referenced by checkModificationAlone().
| bool gum::learning::StructuralConstraintDiGraph::checkModificationAlone | ( | const ArcAddition & | change | ) | const |
checks whether the constraints enable to add an arc
an arc can be added if and only if its extremal nodes belong to the graph and the arc does not already exist.
| bool gum::learning::StructuralConstraintDiGraph::checkModificationAlone | ( | const ArcDeletion & | change | ) | const |
checks whether the constraints enable to remove an arc
an arc can be removed if and only if the arc exists.
| bool gum::learning::StructuralConstraintDiGraph::checkModificationAlone | ( | const ArcReversal & | change | ) | const |
checks whether the constraints enable to reverse an arc
an arc (x,y) can be reversed if and only if it exists and arc (y,x) does not.
| bool gum::learning::StructuralConstraintDiGraph::checkModificationAlone | ( | const ArcTriangleDeletion1 & | change | ) | const |
checks whether the constraints enable to apply an ArcTriangleDeletion1
An arc triangle deletion1 substitutes triangle node1 -> node2 -> node3 + node1 -> node3 into v-structure node2 -> node1 <- node3
| bool gum::learning::StructuralConstraintDiGraph::checkModificationAlone | ( | const ArcTriangleDeletion2 & | change | ) | const |
checks whether the constraints enable to apply an ArcTriangleDeletion2
An arc triangle deletion1 substitutes triangle node1 -> node2 -> node3 + node1 -> node3 into v-structure node1 -> node2 <- node3
| bool gum::learning::StructuralConstraintDiGraph::checkModificationAlone | ( | const GraphChange & | change | ) | const |
checks whether the constraints enable to perform a graph change
An arc can be added if and only if its extremal nodes belong to the graph and the arc does not already exist. An arc can be removed if and only if the arc exists. An arc (x,y) can be reversed if and only if it exists and arc (y,x) does not.
Definition at line 108 of file structuralConstraintDiGraph.cpp.
References gum::learning::ARC_ADDITION, gum::learning::ARC_DELETION, gum::learning::ARC_REVERSAL, gum::learning::ARC_TRIANGLE_DELETION1, gum::learning::ARC_TRIANGLE_DELETION2, checkArcAdditionAlone(), checkArcDeletionAlone(), checkArcReversalAlone(), checkArcTriangleDeletion1Alone(), checkArcTriangleDeletion2Alone(), GUM_ERROR, gum::learning::GraphChange::node1(), gum::learning::GraphChange::node2(), gum::learning::GraphChange::node3(), gum::learning::GraphChange::type(), and gum::learning::GraphChange::typeAsString().
| bool gum::learning::StructuralConstraintDiGraph::isAlwaysInvalidAlone | ( | const GraphChange & | change | ) | const |
indicates whether a change will always violate the constraint
Some learning algorithms need examine several times whether a given graph change can be applied. For instance, the first time arc (X,Y) addition is considered, the learning algorithm may discard this change because it violates the structural constraint (e.g., if the latter enforces a DAG structure, this arc addition might induce a directed cycle), but, later on, other arc removal may induce that the arc addition is now possible. Such change is thus not always invalid. Conversely, there are changes that can be discarded once and for all. For instance, in a 2TBN structure, it is always impossible to add a backward-time arc. Such graph changes are always invalid and are therefore tagged as such by the isAlwaysInvalid method.
| void gum::learning::StructuralConstraintDiGraph::modifyGraphAlone | ( | const ArcAddition & | change | ) |
notify the constraint of a modification of the graph
| InvalidNode | exception is thrown if an arc (x,y) is added and x or y does not belong to the graph nodes |
Referenced by modifyGraphAlone().
| void gum::learning::StructuralConstraintDiGraph::modifyGraphAlone | ( | const ArcDeletion & | change | ) |
notify the constraint of a modification of the graph
| void gum::learning::StructuralConstraintDiGraph::modifyGraphAlone | ( | const ArcReversal & | change | ) |
notify the constraint of a modification of the graph
| InvalidNode | exception is thrown if at least one extremity of the arc does not belong to the graph nodes |
| void gum::learning::StructuralConstraintDiGraph::modifyGraphAlone | ( | const ArcTriangleDeletion1 & | change | ) |
notify the constraint of a modification of the graph
An arc triangle deletion1 substitutes triangle node1 -> node2 -> node3 + node1 -> node3 into v-structure node2 -> node1 <- node3
| void gum::learning::StructuralConstraintDiGraph::modifyGraphAlone | ( | const ArcTriangleDeletion2 & | change | ) |
notify the constraint of a modification of the graph
An arc triangle deletion1 substitutes triangle node1 -> node2 -> node3 + node1 -> node3 into v-structure node1 -> node2 <- node3
| void gum::learning::StructuralConstraintDiGraph::modifyGraphAlone | ( | const GraphChange & | change | ) |
notify the constraint of a modification of the graph
| InvalidNode | exception is thrown if an arc (x,y) is added and x or y does not belong to the graph nodes |
Definition at line 133 of file structuralConstraintDiGraph.cpp.
References gum::learning::ARC_ADDITION, gum::learning::ARC_DELETION, gum::learning::ARC_REVERSAL, gum::learning::ARC_TRIANGLE_DELETION1, gum::learning::ARC_TRIANGLE_DELETION2, GUM_ERROR, modifyGraphAlone(), gum::learning::GraphChange::type(), and gum::learning::GraphChange::typeAsString().
| StructuralConstraintDiGraph & gum::learning::StructuralConstraintDiGraph::operator= | ( | const StructuralConstraintDiGraph & | from | ) |
copy operator
Definition at line 96 of file structuralConstraintDiGraph.cpp.
References StructuralConstraintDiGraph(), and _graph_.
Referenced by gum::learning::StructuralConstraintIndegree::operator=(), gum::learning::StructuralConstraintIndegree::operator=(), gum::learning::StructuralConstraintSliceOrder::operator=(), and gum::learning::StructuralConstraintSliceOrder::operator=().
| StructuralConstraintDiGraph & gum::learning::StructuralConstraintDiGraph::operator= | ( | StructuralConstraintDiGraph && | from | ) |
move operator
Definition at line 103 of file structuralConstraintDiGraph.cpp.
References StructuralConstraintDiGraph(), and _graph_.
| void gum::learning::StructuralConstraintDiGraph::setGraph | ( | Size | nb_nodes | ) |
sets a new empty graph from which we will perform checking
Referenced by StructuralConstraintDiGraph(), and StructuralConstraintDiGraph().
| void gum::learning::StructuralConstraintDiGraph::setGraphAlone | ( | const DiGraph & | graph | ) |
sets a new graph from which we will perform checking
|
protected |
the DiGraph on which we perform checks
Definition at line 246 of file structuralConstraintDiGraph.h.
Referenced by StructuralConstraintDiGraph(), StructuralConstraintDiGraph(), operator=(), and operator=().