aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
gum::learning::StructuralConstraintMandatoryArcs Class Reference

the structural constraint indicating that some arcs shall never be removed or reversed More...

#include <structuralConstraintMandatoryArcs.h>

Inheritance diagram for gum::learning::StructuralConstraintMandatoryArcs:
Collaboration diagram for gum::learning::StructuralConstraintMandatoryArcs:

Public Types

using allConstraints = _ConstraintSet_< void >

Public Member Functions

Constructors / Destructors
 StructuralConstraintMandatoryArcs ()
 default constructor
 StructuralConstraintMandatoryArcs (const DiGraph &graph)
 constructor starting with a given graph
 StructuralConstraintMandatoryArcs (const StructuralConstraintMandatoryArcs &from)
 copy constructor
 StructuralConstraintMandatoryArcs (StructuralConstraintMandatoryArcs &&from)
 move constructor
virtual ~StructuralConstraintMandatoryArcs ()
 destructor
Operators
StructuralConstraintMandatoryArcsoperator= (const StructuralConstraintMandatoryArcs &from)
 copy operator
StructuralConstraintMandatoryArcsoperator= (StructuralConstraintMandatoryArcs &&from)
 move operator
Specific Accessors / Modifiers
void setArcs (const ArcSet &set)
 assign a set of forbidden arcs
void addArc (const Arc &arc)
 assign a new forbidden arc
void eraseArc (const Arc &arc)
 remove a forbidden arc
const ArcSetarcs () const
 returns the set of mandatory arcs
void setGraphAlone (const DiGraph &graph)
 sets a new graph from which we will perform checkings
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

ArcSet _MandatoryArcs_mandatory_arcs_
 the MandatoryArcs on which we perform checks

Detailed Description

the structural constraint indicating that some arcs shall never be removed or reversed

Definition at line 64 of file structuralConstraintMandatoryArcs.h.

Member Typedef Documentation

◆ allConstraints

using gum::learning::StructuralConstraintEmpty::allConstraints = _ConstraintSet_< void >
inherited

Definition at line 61 of file structuralConstraint.h.

Constructor & Destructor Documentation

◆ StructuralConstraintMandatoryArcs() [1/4]

gum::learning::StructuralConstraintMandatoryArcs::StructuralConstraintMandatoryArcs ( )

default constructor

Definition at line 61 of file structuralConstraintMandatoryArcs.cpp.

References StructuralConstraintMandatoryArcs().

Referenced by StructuralConstraintMandatoryArcs(), StructuralConstraintMandatoryArcs(), StructuralConstraintMandatoryArcs(), StructuralConstraintMandatoryArcs(), ~StructuralConstraintMandatoryArcs(), operator=(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StructuralConstraintMandatoryArcs() [2/4]

gum::learning::StructuralConstraintMandatoryArcs::StructuralConstraintMandatoryArcs ( const DiGraph & graph)

constructor starting with a given graph

Definition at line 66 of file structuralConstraintMandatoryArcs.cpp.

66 {
67 setGraph(graph);
68 GUM_CONSTRUCTOR(StructuralConstraintMandatoryArcs);
69 }

References StructuralConstraintMandatoryArcs().

Here is the call graph for this function:

◆ StructuralConstraintMandatoryArcs() [3/4]

gum::learning::StructuralConstraintMandatoryArcs::StructuralConstraintMandatoryArcs ( const StructuralConstraintMandatoryArcs & from)

copy constructor

Definition at line 72 of file structuralConstraintMandatoryArcs.cpp.

73 :
74 _MandatoryArcs_mandatory_arcs_(from._MandatoryArcs_mandatory_arcs_) {
76 }
ArcSet _MandatoryArcs_mandatory_arcs_
the MandatoryArcs on which we perform checks

References StructuralConstraintMandatoryArcs(), and _MandatoryArcs_mandatory_arcs_.

Here is the call graph for this function:

◆ StructuralConstraintMandatoryArcs() [4/4]

gum::learning::StructuralConstraintMandatoryArcs::StructuralConstraintMandatoryArcs ( StructuralConstraintMandatoryArcs && from)

move constructor

Definition at line 79 of file structuralConstraintMandatoryArcs.cpp.

80 :
81 _MandatoryArcs_mandatory_arcs_(std::move(from._MandatoryArcs_mandatory_arcs_)) {
83 }

References StructuralConstraintMandatoryArcs(), and _MandatoryArcs_mandatory_arcs_.

Here is the call graph for this function:

◆ ~StructuralConstraintMandatoryArcs()

gum::learning::StructuralConstraintMandatoryArcs::~StructuralConstraintMandatoryArcs ( )
virtual

destructor

Definition at line 86 of file structuralConstraintMandatoryArcs.cpp.

86 {
88 }

References StructuralConstraintMandatoryArcs().

Here is the call graph for this function:

Member Function Documentation

◆ addArc()

void gum::learning::StructuralConstraintMandatoryArcs::addArc ( const Arc & arc)

assign a new forbidden arc

◆ arcs()

const ArcSet & gum::learning::StructuralConstraintMandatoryArcs::arcs ( ) const

returns the set of mandatory arcs

◆ checkArcAdditionAlone()

bool gum::learning::StructuralConstraintMandatoryArcs::checkArcAdditionAlone ( NodeId x,
NodeId y ) const

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().

Here is the caller graph for this function:

◆ checkArcDeletionAlone()

bool gum::learning::StructuralConstraintMandatoryArcs::checkArcDeletionAlone ( NodeId x,
NodeId y ) const

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(), and isAlwaysInvalidAlone().

Here is the caller graph for this function:

◆ checkArcReversalAlone()

bool gum::learning::StructuralConstraintMandatoryArcs::checkArcReversalAlone ( NodeId x,
NodeId y ) const

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(), and isAlwaysInvalidAlone().

Here is the caller graph for this function:

◆ checkArcTriangleDeletion1Alone()

bool gum::learning::StructuralConstraintMandatoryArcs::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(), and isAlwaysInvalidAlone().

Here is the caller graph for this function:

◆ checkArcTriangleDeletion2Alone()

bool gum::learning::StructuralConstraintMandatoryArcs::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(), and isAlwaysInvalidAlone().

Here is the caller graph for this function:

◆ checkModificationAlone() [1/6]

bool gum::learning::StructuralConstraintMandatoryArcs::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.

◆ checkModificationAlone() [2/6]

bool gum::learning::StructuralConstraintMandatoryArcs::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.

◆ checkModificationAlone() [3/6]

bool gum::learning::StructuralConstraintMandatoryArcs::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.

◆ checkModificationAlone() [4/6]

bool gum::learning::StructuralConstraintMandatoryArcs::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

◆ checkModificationAlone() [5/6]

bool gum::learning::StructuralConstraintMandatoryArcs::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

◆ checkModificationAlone() [6/6]

bool gum::learning::StructuralConstraintMandatoryArcs::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 107 of file structuralConstraintMandatoryArcs.cpp.

107 {
108 switch (change.type()) {
110 return checkArcAdditionAlone(change.node1(), change.node2());
111
113 return checkArcDeletionAlone(change.node1(), change.node2());
114
116 return checkArcReversalAlone(change.node1(), change.node2());
117
119 return checkArcTriangleDeletion1Alone(change.node1(), change.node2(), change.node3());
120
122 return checkArcTriangleDeletion2Alone(change.node1(), change.node2(), change.node3());
123
124 default :
125 GUM_ERROR(OperationNotAllowed,
126 "Graph change operation "
127 << change.typeAsString()
128 << " is not supported by the Mandatory Arcs structural constraint");
129 }
130 }
bool checkArcReversalAlone(NodeId x, NodeId y) const
checks whether the constraints enable to reverse arc (x,y)
bool checkArcDeletionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to remove 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 checkArcAdditionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to add arc (x,y)
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

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().

Here is the call graph for this function:

◆ eraseArc()

void gum::learning::StructuralConstraintMandatoryArcs::eraseArc ( const Arc & arc)

remove a forbidden arc

◆ isAlwaysInvalidAlone()

bool gum::learning::StructuralConstraintMandatoryArcs::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.

Definition at line 132 of file structuralConstraintMandatoryArcs.cpp.

132 {
133 switch (change.type()) {
134 case GraphChangeType::ARC_ADDITION : return false;
135
137 return !checkArcDeletionAlone(change.node1(), change.node2());
138
140 return !checkArcReversalAlone(change.node1(), change.node2());
141
143 return !checkArcTriangleDeletion1Alone(change.node1(), change.node2(), change.node3());
144
146 return !checkArcTriangleDeletion2Alone(change.node1(), change.node2(), change.node3());
147
148 default :
149 GUM_ERROR(OperationNotAllowed,
150 "Graph change operation "
151 << change.typeAsString()
152 << " is not supported by the Mandatory Arcs structural constraint");
153 }
154 }

References gum::learning::ARC_ADDITION, gum::learning::ARC_DELETION, gum::learning::ARC_REVERSAL, gum::learning::ARC_TRIANGLE_DELETION1, gum::learning::ARC_TRIANGLE_DELETION2, 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().

Here is the call graph for this function:

◆ modifyGraphAlone() [1/6]

void gum::learning::StructuralConstraintMandatoryArcs::modifyGraphAlone ( const ArcAddition & change)

notify the constraint of a modification of the graph

Warning
If an already existing arc is added nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeexception is thrown if an arc (x,y) is added and x or y does not belong to the graph nodes

◆ modifyGraphAlone() [2/6]

void gum::learning::StructuralConstraintMandatoryArcs::modifyGraphAlone ( const ArcDeletion & change)

notify the constraint of a modification of the graph

Warning
If a nonexisting arc is removed, nothing is done. In particular, no exception is raised.

◆ modifyGraphAlone() [3/6]

void gum::learning::StructuralConstraintMandatoryArcs::modifyGraphAlone ( const ArcReversal & change)

notify the constraint of a modification of the graph

Warning
If an already existing arc is added, or if a nonexisting arc is removed, nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeexception is thrown if at least one extremity of the arc does not belong to the graph nodes

◆ modifyGraphAlone() [4/6]

void gum::learning::StructuralConstraintMandatoryArcs::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

◆ modifyGraphAlone() [5/6]

void gum::learning::StructuralConstraintMandatoryArcs::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

◆ modifyGraphAlone() [6/6]

void gum::learning::StructuralConstraintMandatoryArcs::modifyGraphAlone ( const GraphChange & change)

notify the constraint of a modification of the graph

Warning
If an already existing arc is added, or if a nonexisting arc is removed, nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeexception is thrown if an arc (x,y) is added and x or y does not belong to the graph nodes

◆ operator=() [1/2]

StructuralConstraintMandatoryArcs & gum::learning::StructuralConstraintMandatoryArcs::operator= ( const StructuralConstraintMandatoryArcs & from)

copy operator

Definition at line 91 of file structuralConstraintMandatoryArcs.cpp.

92 {
93 if (this != &from) { _MandatoryArcs_mandatory_arcs_ = from._MandatoryArcs_mandatory_arcs_; }
94 return *this;
95 }

References StructuralConstraintMandatoryArcs(), and _MandatoryArcs_mandatory_arcs_.

Here is the call graph for this function:

◆ operator=() [2/2]

StructuralConstraintMandatoryArcs & gum::learning::StructuralConstraintMandatoryArcs::operator= ( StructuralConstraintMandatoryArcs && from)

move operator

Definition at line 99 of file structuralConstraintMandatoryArcs.cpp.

99 {
100 if (this != &from) {
101 _MandatoryArcs_mandatory_arcs_ = std::move(from._MandatoryArcs_mandatory_arcs_);
102 }
103 return *this;
104 }

References StructuralConstraintMandatoryArcs(), and _MandatoryArcs_mandatory_arcs_.

Here is the call graph for this function:

◆ setArcs()

void gum::learning::StructuralConstraintMandatoryArcs::setArcs ( const ArcSet & set)

assign a set of forbidden arcs

◆ setGraphAlone()

void gum::learning::StructuralConstraintMandatoryArcs::setGraphAlone ( const DiGraph & graph)

sets a new graph from which we will perform checkings

Member Data Documentation

◆ _MandatoryArcs_mandatory_arcs_

ArcSet gum::learning::StructuralConstraintMandatoryArcs::_MandatoryArcs_mandatory_arcs_
protected

the MandatoryArcs on which we perform checks

Definition at line 248 of file structuralConstraintMandatoryArcs.h.

Referenced by StructuralConstraintMandatoryArcs(), StructuralConstraintMandatoryArcs(), operator=(), and operator=().


The documentation for this class was generated from the following files: