aGrUM  0.16.0
gum::learning::StructuralConstraintTabuList Class Reference

The class imposing a N-sized tabu list as a structural constraints for learning algorithms. More...

#include <structuralConstraintTabuList.h>

+ Inheritance diagram for gum::learning::StructuralConstraintTabuList:
+ Collaboration diagram for gum::learning::StructuralConstraintTabuList:

Public Member Functions

Constructors / Destructors
 StructuralConstraintTabuList ()
 default constructor More...
 
 StructuralConstraintTabuList (const DiGraph &graph)
 constructor starting with a given graph More...
 
 StructuralConstraintTabuList (const StructuralConstraintTabuList &from)
 copy constructor More...
 
 StructuralConstraintTabuList (StructuralConstraintTabuList &&from)
 move constructor More...
 
virtual ~StructuralConstraintTabuList ()
 destructor More...
 
Operators
StructuralConstraintTabuListoperator= (const StructuralConstraintTabuList &from)
 copy operator More...
 
StructuralConstraintTabuListoperator= (StructuralConstraintTabuList &&from)
 move operator More...
 
Specific Accessors / Modifiers
void setTabuListSize (Size new_size)
 sets the size of the tabu list More...
 
void setGraphAlone (const DiGraph &graph)
 sets a new graph from which we will perform checkings More...
 
void modifyGraphAlone (const ArcAddition &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraphAlone (const ArcDeletion &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraphAlone (const ArcReversal &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraphAlone (const GraphChange &change)
 notify the constraint of a modification of the graph More...
 
bool isAlwaysInvalidAlone (const GraphChange &change) const
 indicates whether a change will always violate the constraint More...
 
bool checkArcAdditionAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to add arc (x,y) More...
 
bool checkArcDeletionAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to remove arc (x,y) More...
 
bool checkArcReversalAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to reverse arc (x,y) More...
 
bool checkModificationAlone (const GraphChange &change) const
 checks whether the constraints enable to perform a graph change More...
 
bool checkModificationAlone (const ArcAddition &change) const
 checks whether the constraints enable to add an arc More...
 
bool checkModificationAlone (const ArcDeletion &change) const
 checks whether the constraints enable to remove an arc More...
 
bool checkModificationAlone (const ArcReversal &change) const
 checks whether the constraints enable to reverse an arc More...
 

Public Types

using allConstraints = __ConstraintSet< void >
 

Protected Attributes

Bijection< GraphChange, NodeId_TabuList__changes
 the tabu list More...
 
NodeId _TabuList__offset {0}
 the index of the oldest element More...
 

Detailed Description

The class imposing a N-sized tabu list as a structural constraints for learning algorithms.

By default, the size of the tabu list is 2, but it can be changed by the user using method setTabuSize (). Each time you modify the graph you learn, the inverse change is put into the tabu list. For instance, if the learning algorithm adds an arc (X, Y), then the "Deletion of Arc (X,Y)" operation is inserted into the tabu list. If the operation performed is an arc (X,Y) reversal, then the "Reversal of Arc (Y,X)" operation is added to the tabu list.

Definition at line 69 of file structuralConstraintTabuList.h.

Member Typedef Documentation

◆ allConstraints

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

Definition at line 42 of file structuralConstraint.h.

Constructor & Destructor Documentation

◆ StructuralConstraintTabuList() [1/4]

gum::learning::StructuralConstraintTabuList::StructuralConstraintTabuList ( )

default constructor

Definition at line 42 of file structuralConstraintTabuList.cpp.

References _TabuList__changes, and GUM_STRUCTURAL_CONSTRAINT_TABU_LIST_DEFAULT_SIZE.

42  :
44  // put dummy elements into the list (this avoids having tests to do
45  // afterwards)
47  ++i) {
48  _TabuList__changes.insert(
49  ArcAddition(std::numeric_limits< NodeId >::max() - i,
50  std::numeric_limits< NodeId >::max()),
51  i);
52  }
53 
54  GUM_CONSTRUCTOR(StructuralConstraintTabuList);
55  }
#define GUM_STRUCTURAL_CONSTRAINT_TABU_LIST_DEFAULT_SIZE
Bijection< GraphChange, NodeId > _TabuList__changes
the tabu list
Size NodeId
Type for node ids.
Definition: graphElements.h:98

◆ StructuralConstraintTabuList() [2/4]

gum::learning::StructuralConstraintTabuList::StructuralConstraintTabuList ( const DiGraph graph)

constructor starting with a given graph

Definition at line 58 of file structuralConstraintTabuList.cpp.

References _TabuList__changes, and GUM_STRUCTURAL_CONSTRAINT_TABU_LIST_DEFAULT_SIZE.

59  :
61  // put dummy elements into the list (this avoids having tests to do
62  // afterwards)
64  ++i) {
65  _TabuList__changes.insert(
66  ArcAddition(std::numeric_limits< NodeId >::max() - i,
67  std::numeric_limits< NodeId >::max()),
68  i);
69  }
70 
71  GUM_CONSTRUCTOR(StructuralConstraintTabuList);
72  }
#define GUM_STRUCTURAL_CONSTRAINT_TABU_LIST_DEFAULT_SIZE
Bijection< GraphChange, NodeId > _TabuList__changes
the tabu list
Size NodeId
Type for node ids.
Definition: graphElements.h:98

◆ StructuralConstraintTabuList() [3/4]

gum::learning::StructuralConstraintTabuList::StructuralConstraintTabuList ( const StructuralConstraintTabuList from)

copy constructor

Definition at line 75 of file structuralConstraintTabuList.cpp.

76  :
77  _TabuList__changes(from._TabuList__changes),
78  _TabuList__offset(from._TabuList__offset) {
79  GUM_CONS_CPY(StructuralConstraintTabuList);
80  }
NodeId _TabuList__offset
the index of the oldest element
Bijection< GraphChange, NodeId > _TabuList__changes
the tabu list

◆ StructuralConstraintTabuList() [4/4]

gum::learning::StructuralConstraintTabuList::StructuralConstraintTabuList ( StructuralConstraintTabuList &&  from)

move constructor

Definition at line 83 of file structuralConstraintTabuList.cpp.

84  :
85  _TabuList__changes(std::move(from._TabuList__changes)),
86  _TabuList__offset(std::move(from._TabuList__offset)) {
87  GUM_CONS_MOV(StructuralConstraintTabuList);
88  }
NodeId _TabuList__offset
the index of the oldest element
Bijection< GraphChange, NodeId > _TabuList__changes
the tabu list

◆ ~StructuralConstraintTabuList()

gum::learning::StructuralConstraintTabuList::~StructuralConstraintTabuList ( )
virtual

destructor

Definition at line 91 of file structuralConstraintTabuList.cpp.

References operator=().

91  {
92  GUM_DESTRUCTOR(StructuralConstraintTabuList);
93  }
+ Here is the call graph for this function:

Member Function Documentation

◆ checkArcAdditionAlone()

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

◆ checkArcDeletionAlone()

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

◆ checkArcReversalAlone()

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

◆ checkModificationAlone() [1/4]

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

◆ checkModificationAlone() [2/4]

bool gum::learning::StructuralConstraintTabuList::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() [3/4]

bool gum::learning::StructuralConstraintTabuList::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() [4/4]

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

◆ isAlwaysInvalidAlone()

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

◆ modifyGraphAlone() [1/4]

void gum::learning::StructuralConstraintTabuList::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/4]

void gum::learning::StructuralConstraintTabuList::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/4]

void gum::learning::StructuralConstraintTabuList::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/4]

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

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

copy operator

Definition at line 97 of file structuralConstraintTabuList.cpp.

References _TabuList__changes, and _TabuList__offset.

Referenced by ~StructuralConstraintTabuList().

97  {
98  if (this != &from) {
99  _TabuList__changes = from._TabuList__changes;
100  _TabuList__offset = from._TabuList__offset;
101  }
102  return *this;
103  }
NodeId _TabuList__offset
the index of the oldest element
Bijection< GraphChange, NodeId > _TabuList__changes
the tabu list
+ Here is the caller graph for this function:

◆ operator=() [2/2]

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

move operator

Definition at line 107 of file structuralConstraintTabuList.cpp.

References _TabuList__changes, and _TabuList__offset.

107  {
108  if (this != &from) {
109  _TabuList__changes = std::move(from._TabuList__changes);
110  _TabuList__offset = std::move(from._TabuList__offset);
111  }
112  return *this;
113  }
NodeId _TabuList__offset
the index of the oldest element
Bijection< GraphChange, NodeId > _TabuList__changes
the tabu list

◆ setGraphAlone()

void gum::learning::StructuralConstraintTabuList::setGraphAlone ( const DiGraph graph)

sets a new graph from which we will perform checkings

◆ setTabuListSize()

void gum::learning::StructuralConstraintTabuList::setTabuListSize ( Size  new_size)

sets the size of the tabu list

Referenced by gum::learning::genericBNLearner::useLocalSearchWithTabuList().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _TabuList__changes

Bijection< GraphChange, NodeId > gum::learning::StructuralConstraintTabuList::_TabuList__changes
protected

the tabu list

Definition at line 209 of file structuralConstraintTabuList.h.

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

◆ _TabuList__offset

NodeId gum::learning::StructuralConstraintTabuList::_TabuList__offset {0}
protected

the index of the oldest element

Definition at line 212 of file structuralConstraintTabuList.h.

Referenced by operator=().


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