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

the structural constraint for forbidding children for some nodes More...

#include <structuralConstraintNoChildrenNodes.h>

Inheritance diagram for gum::learning::StructuralConstraintNoChildrenNodes:
Collaboration diagram for gum::learning::StructuralConstraintNoChildrenNodes:

Public Types

using allConstraints = _ConstraintSet_< void >

Public Member Functions

Constructors / Destructors
 StructuralConstraintNoChildrenNodes ()
 default constructor
 StructuralConstraintNoChildrenNodes (const DiGraph &graph)
 constructor starting with a given graph
 StructuralConstraintNoChildrenNodes (const StructuralConstraintNoChildrenNodes &from)
 copy constructor
 StructuralConstraintNoChildrenNodes (StructuralConstraintNoChildrenNodes &&from)
 move constructor
virtual ~StructuralConstraintNoChildrenNodes ()
 destructor
Operators
StructuralConstraintNoChildrenNodesoperator= (const StructuralConstraintNoChildrenNodes &from)
 copy operator
StructuralConstraintNoChildrenNodesoperator= (StructuralConstraintNoChildrenNodes &&from)
 move operator
Specific Accessors / Modifiers
void setNodes (const NodeSet &set)
 assign a set of nodes without children
void addNode (NodeId node)
 assign a new node without children
void eraseNode (NodeId node)
 remove a forbidden w node without children
const NodeSetnodes () const
 returns the set of w nodes without children
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

NodeSet _noChildrenNodes_
 the set of w nodes without children on which we perform checks

Detailed Description

the structural constraint for forbidding children for some nodes

Definition at line 61 of file structuralConstraintNoChildrenNodes.h.

Member Typedef Documentation

◆ allConstraints

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

Definition at line 61 of file structuralConstraint.h.

Constructor & Destructor Documentation

◆ StructuralConstraintNoChildrenNodes() [1/4]

gum::learning::StructuralConstraintNoChildrenNodes::StructuralConstraintNoChildrenNodes ( )

default constructor

Definition at line 59 of file structuralConstraintNoChildrenNodes.cpp.

References StructuralConstraintNoChildrenNodes().

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

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

◆ StructuralConstraintNoChildrenNodes() [2/4]

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

constructor starting with a given graph

Definition at line 64 of file structuralConstraintNoChildrenNodes.cpp.

64 {
65 setGraph(graph);
67 }

References StructuralConstraintNoChildrenNodes().

Here is the call graph for this function:

◆ StructuralConstraintNoChildrenNodes() [3/4]

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

copy constructor

Definition at line 70 of file structuralConstraintNoChildrenNodes.cpp.

71 : _noChildrenNodes_(from._noChildrenNodes_) {
73 }
NodeSet _noChildrenNodes_
the set of w nodes without children on which we perform checks

References StructuralConstraintNoChildrenNodes(), and _noChildrenNodes_.

Here is the call graph for this function:

◆ StructuralConstraintNoChildrenNodes() [4/4]

gum::learning::StructuralConstraintNoChildrenNodes::StructuralConstraintNoChildrenNodes ( StructuralConstraintNoChildrenNodes && from)

move constructor

Definition at line 76 of file structuralConstraintNoChildrenNodes.cpp.

77 :
78 _noChildrenNodes_(std::move(from._noChildrenNodes_)) {
80 }

References StructuralConstraintNoChildrenNodes(), and _noChildrenNodes_.

Here is the call graph for this function:

◆ ~StructuralConstraintNoChildrenNodes()

gum::learning::StructuralConstraintNoChildrenNodes::~StructuralConstraintNoChildrenNodes ( )
virtual

destructor

Definition at line 83 of file structuralConstraintNoChildrenNodes.cpp.

83 {
85 }

References StructuralConstraintNoChildrenNodes().

Here is the call graph for this function:

Member Function Documentation

◆ addNode()

void gum::learning::StructuralConstraintNoChildrenNodes::addNode ( NodeId node)

assign a new node without children

◆ checkArcAdditionAlone()

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

checks whether the constraints enable to add arc (x,y)

Referenced by checkModificationAlone().

Here is the caller graph for this function:

◆ checkArcDeletionAlone()

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

checks whether the constraints enable to remove arc (x,y)

Referenced by checkModificationAlone().

Here is the caller graph for this function:

◆ checkArcReversalAlone()

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

checks whether the constraints enable to reverse arc (x,y)

Referenced by checkModificationAlone().

Here is the caller graph for this function:

◆ checkArcTriangleDeletion1Alone()

bool gum::learning::StructuralConstraintNoChildrenNodes::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().

Here is the caller graph for this function:

◆ checkArcTriangleDeletion2Alone()

bool gum::learning::StructuralConstraintNoChildrenNodes::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().

Here is the caller graph for this function:

◆ checkModificationAlone() [1/6]

bool gum::learning::StructuralConstraintNoChildrenNodes::checkModificationAlone ( const ArcAddition & change) const

checks whether the constraints enable to add an arc

◆ checkModificationAlone() [2/6]

bool gum::learning::StructuralConstraintNoChildrenNodes::checkModificationAlone ( const ArcDeletion & change) const

checks whether the constraints enable to remove an arc

◆ checkModificationAlone() [3/6]

bool gum::learning::StructuralConstraintNoChildrenNodes::checkModificationAlone ( const ArcReversal & change) const

checks whether the constraints enable to reverse an arc

◆ checkModificationAlone() [4/6]

bool gum::learning::StructuralConstraintNoChildrenNodes::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::StructuralConstraintNoChildrenNodes::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::StructuralConstraintNoChildrenNodes::checkModificationAlone ( const GraphChange & change) const

checks whether the constraints enable to perform a graph change

Definition at line 102 of file structuralConstraintNoChildrenNodes.cpp.

102 {
103 switch (change.type()) {
105 return checkArcAdditionAlone(change.node1(), change.node2());
106
108 return checkArcDeletionAlone(change.node1(), change.node2());
109
111 return checkArcReversalAlone(change.node1(), change.node2());
112
114 return checkArcTriangleDeletion1Alone(change.node1(), change.node2(), change.node3());
115
117 return checkArcTriangleDeletion2Alone(change.node1(), change.node2(), change.node3());
118
119 default :
120 GUM_ERROR(OperationNotAllowed,
121 "edge modifications are not "
122 "supported by the No-Children Nodes structural constraint");
123 }
124 }
bool checkArcReversalAlone(NodeId x, NodeId y) const
checks whether the constraints enable to reverse arc (x,y)
bool checkArcTriangleDeletion2Alone(NodeId node1, NodeId node2, NodeId node3) const
checks whether the constraints enable to apply an ArcTriangleDeletion2
bool checkArcTriangleDeletion1Alone(NodeId node1, NodeId node2, NodeId node3) const
checks whether the constraints enable to apply an ArcTriangleDeletion1
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)
#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(), and gum::learning::GraphChange::type().

Here is the call graph for this function:

◆ eraseNode()

void gum::learning::StructuralConstraintNoChildrenNodes::eraseNode ( NodeId node)

remove a forbidden w node without children

◆ isAlwaysInvalidAlone()

bool gum::learning::StructuralConstraintNoChildrenNodes::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 126 of file structuralConstraintNoChildrenNodes.cpp.

126 {
127 switch (change.type()) {
128 case GraphChangeType::ARC_ADDITION : return _noChildrenNodes_.exists(change.node1());
129
130 case GraphChangeType::ARC_DELETION : return false;
131
132 case GraphChangeType::ARC_REVERSAL : return _noChildrenNodes_.exists(change.node2());
133
135 return _noChildrenNodes_.exists(change.node2()) || _noChildrenNodes_.exists(change.node3());
136
138 return _noChildrenNodes_.exists(change.node1()) || _noChildrenNodes_.exists(change.node3());
139
140 default :
141 GUM_ERROR(OperationNotAllowed,
142 "edge modifications are not supported "
143 "by the No-Children Nodes structural constraint");
144 }
145 }

References _noChildrenNodes_, gum::learning::ARC_ADDITION, gum::learning::ARC_DELETION, gum::learning::ARC_REVERSAL, gum::learning::ARC_TRIANGLE_DELETION1, gum::learning::ARC_TRIANGLE_DELETION2, GUM_ERROR, gum::learning::GraphChange::node1(), gum::learning::GraphChange::node2(), gum::learning::GraphChange::node3(), and gum::learning::GraphChange::type().

Here is the call graph for this function:

◆ modifyGraphAlone() [1/6]

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

notify the constraint of a modification of the graph

◆ modifyGraphAlone() [2/6]

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

notify the constraint of a modification of the graph

◆ modifyGraphAlone() [3/6]

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

notify the constraint of a modification of the graph

◆ modifyGraphAlone() [4/6]

void gum::learning::StructuralConstraintNoChildrenNodes::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::StructuralConstraintNoChildrenNodes::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::StructuralConstraintNoChildrenNodes::modifyGraphAlone ( const GraphChange & change)

notify the constraint of a modification of the graph

◆ nodes()

const NodeSet & gum::learning::StructuralConstraintNoChildrenNodes::nodes ( ) const

returns the set of w nodes without children

◆ operator=() [1/2]

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

copy operator

Definition at line 88 of file structuralConstraintNoChildrenNodes.cpp.

89 {
90 if (this != &from) { _noChildrenNodes_ = from._noChildrenNodes_; }
91 return *this;
92 }

References StructuralConstraintNoChildrenNodes(), and _noChildrenNodes_.

Here is the call graph for this function:

◆ operator=() [2/2]

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

move operator

Definition at line 96 of file structuralConstraintNoChildrenNodes.cpp.

96 {
97 if (this != &from) { _noChildrenNodes_ = std::move(from._noChildrenNodes_); }
98 return *this;
99 }

References StructuralConstraintNoChildrenNodes(), and _noChildrenNodes_.

Here is the call graph for this function:

◆ setGraphAlone()

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

sets a new graph from which we will perform checkings

◆ setNodes()

void gum::learning::StructuralConstraintNoChildrenNodes::setNodes ( const NodeSet & set)

assign a set of nodes without children

Member Data Documentation

◆ _noChildrenNodes_

NodeSet gum::learning::StructuralConstraintNoChildrenNodes::_noChildrenNodes_
protected

the set of w nodes without children on which we perform checks

Definition at line 216 of file structuralConstraintNoChildrenNodes.h.

Referenced by StructuralConstraintNoChildrenNodes(), StructuralConstraintNoChildrenNodes(), isAlwaysInvalidAlone(), operator=(), and operator=().


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