![]() |
aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
|
The base class for structural constraints imposed by DAGs. More...
#include <structuralConstraintDAG.h>
Public Types | |
| using | allConstraints = _ConstraintSet_< void > |
Public Member Functions | |
Constructors / Destructors | |
| StructuralConstraintDAG () | |
| default constructor | |
| StructuralConstraintDAG (Size nb_nodes) | |
| constructor starting with an empty graph with a given number of nodes | |
| StructuralConstraintDAG (const DAG &graph) | |
| constructor starting with a given graph | |
| StructuralConstraintDAG (const StructuralConstraintDAG &from) | |
| copy constructor | |
| StructuralConstraintDAG (StructuralConstraintDAG &&from) noexcept | |
| move constructor | |
| virtual | ~StructuralConstraintDAG () |
| destructor | |
Operators | |
| StructuralConstraintDAG & | operator= (const StructuralConstraintDAG &from) |
| copy operator | |
| StructuralConstraintDAG & | operator= (StructuralConstraintDAG &&from) |
| move operator | |
Specific Accessors / Modifiers | |
| void | setGraphAlone (const DiGraph &graph) |
| sets a new graph from which we will perform checking | |
| void | setGraphAlone (Size nb_nodes) |
| sets a new empty 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 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 | |
| bool | checkModificationAlone (const GraphChange &change) const |
| checks whether the constraints enable to perform a graph change | |
| void | setGraph (const DAG &graph) |
| sets a new graph from which we will perform checking | |
| void | setGraph (Size nb_nodes) |
| sets a new empty graph from which we will perform checking | |
Private Member Functions | |
| void | _lock_ () const |
| the method to lock a critical region in order to modify graph | |
| void | _unlock_ () const |
| the methode to release a critical region used to modify graph | |
Private Attributes | |
| DiGraph | _graph_ |
| std::atomic_flag | _lock_flag_ = ATOMIC_FLAG_INIT |
The base class for structural constraints imposed by DAGs.
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 69 of file structuralConstraintDAG.h.
|
inherited |
Definition at line 61 of file structuralConstraint.h.
| gum::learning::StructuralConstraintDAG::StructuralConstraintDAG | ( | ) |
default constructor
Definition at line 59 of file structuralConstraintDAG.cpp.
References StructuralConstraintDAG().
Referenced by StructuralConstraintDAG(), StructuralConstraintDAG(), StructuralConstraintDAG(), StructuralConstraintDAG(), StructuralConstraintDAG(), ~StructuralConstraintDAG(), operator=(), and operator=().
| gum::learning::StructuralConstraintDAG::StructuralConstraintDAG | ( | Size | nb_nodes | ) |
constructor starting with an empty graph with a given number of nodes
Definition at line 62 of file structuralConstraintDAG.cpp.
References StructuralConstraintDAG(), and setGraph().
| gum::learning::StructuralConstraintDAG::StructuralConstraintDAG | ( | const DAG & | graph | ) |
constructor starting with a given graph
Definition at line 68 of file structuralConstraintDAG.cpp.
References StructuralConstraintDAG(), and setGraph().
| gum::learning::StructuralConstraintDAG::StructuralConstraintDAG | ( | const StructuralConstraintDAG & | from | ) |
copy constructor
Definition at line 74 of file structuralConstraintDAG.cpp.
References StructuralConstraintDAG(), and _graph_.
|
noexcept |
move constructor
Definition at line 80 of file structuralConstraintDAG.cpp.
References StructuralConstraintDAG(), and _graph_.
|
virtual |
destructor
Definition at line 86 of file structuralConstraintDAG.cpp.
References StructuralConstraintDAG().
|
private |
the method to lock a critical region in order to modify graph
|
private |
the methode to release a critical region used to modify graph
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 and would not create a cycle
Referenced by checkModificationAlone().
checks whether the constraints enable to remove arc (x,y)
Referenced by checkModificationAlone().
checks whether the constraints enable to reverse arc (x,y)
An arc (x,y) can be reversed if and only if it exists and, after deleting it, the addition of arc (y,x) does not induce a directed cycle.
Referenced by checkModificationAlone().
| bool gum::learning::StructuralConstraintDAG::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::StructuralConstraintDAG::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::StructuralConstraintDAG::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::StructuralConstraintDAG::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::StructuralConstraintDAG::checkModificationAlone | ( | const ArcReversal & | change | ) | const |
checks whether the constraints enable to reverse an arc
An arc can be reversed if, after deleting arc (x,y), the addition of arc (y,x) does not induce a directed cycle.
| bool gum::learning::StructuralConstraintDAG::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::StructuralConstraintDAG::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::StructuralConstraintDAG::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 and would not create a cycle. An arc can be removed if and only if the arc exists. An arc can be reversed if, after deleting arc (x,y), the addition of arc (y,x) does not induce a directed cycle.
Definition at line 120 of file structuralConstraintDAG.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::StructuralConstraintDAG::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::StructuralConstraintDAG::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 |
| InvalidDirectedCycle | exception is thrown if any (directed) cycle is created by the arc addition. |
Referenced by modifyGraphAlone().
| void gum::learning::StructuralConstraintDAG::modifyGraphAlone | ( | const ArcDeletion & | change | ) |
notify the constraint of a modification of the graph
| void gum::learning::StructuralConstraintDAG::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 |
| InvalidDirectedCycle | exception is thrown if any (directed) cycle is created by the arc reversal. |
| void gum::learning::StructuralConstraintDAG::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::StructuralConstraintDAG::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::StructuralConstraintDAG::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 |
| InvalidDirectedCycle | exception is thrown if any (directed) cycle is created by an arc addition or reversal. |
Definition at line 145 of file structuralConstraintDAG.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().
| StructuralConstraintDAG & gum::learning::StructuralConstraintDAG::operator= | ( | const StructuralConstraintDAG & | from | ) |
copy operator
Definition at line 90 of file structuralConstraintDAG.cpp.
References StructuralConstraintDAG(), and _graph_.
| StructuralConstraintDAG & gum::learning::StructuralConstraintDAG::operator= | ( | StructuralConstraintDAG && | from | ) |
move operator
Definition at line 96 of file structuralConstraintDAG.cpp.
References StructuralConstraintDAG(), and _graph_.
| void gum::learning::StructuralConstraintDAG::setGraph | ( | const DAG & | graph | ) |
sets a new graph from which we will perform checking
Referenced by StructuralConstraintDAG(), and StructuralConstraintDAG().
| void gum::learning::StructuralConstraintDAG::setGraph | ( | Size | nb_nodes | ) |
sets a new empty graph from which we will perform checking
| void gum::learning::StructuralConstraintDAG::setGraphAlone | ( | const DiGraph & | graph | ) |
sets a new graph from which we will perform checking
Definition at line 101 of file structuralConstraintDAG.cpp.
References _graph_, gum::DiGraph::addArc(), gum::NodeGraphPart::addNodeWithId(), GUM_ERROR, and gum::graph::hasDirectedPath().
| void gum::learning::StructuralConstraintDAG::setGraphAlone | ( | Size | nb_nodes | ) |
sets a new empty graph from which we will perform checking
|
mutableprivate |
Definition at line 268 of file structuralConstraintDAG.h.
Referenced by StructuralConstraintDAG(), StructuralConstraintDAG(), operator=(), operator=(), and setGraphAlone().
|
mutableprivate |
Definition at line 277 of file structuralConstraintDAG.h.