aGrUM  0.16.0
structuralConstraintTabuList_inl.h
Go to the documentation of this file.
1 
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 
31 namespace gum {
32 
33  namespace learning {
34 
36  INLINE
38  if (new_size == _TabuList__changes.size()) return;
39 
40  if (_TabuList__changes.size() > new_size) {
41  // remove the oldest elements, so that only newsize elements remain
42  while (_TabuList__changes.size() > new_size) {
45  }
46  } else {
47  // add dummy elements
48  while (_TabuList__changes.size() < new_size) {
50  _TabuList__changes.insert(
51  ArcAddition(std::numeric_limits< NodeId >::max() - _TabuList__offset,
52  std::numeric_limits< NodeId >::max()),
54  }
55  }
56  }
57 
59  INLINE void StructuralConstraintTabuList::setGraphAlone(const DiGraph& graph) {
60  }
61 
63  INLINE bool
65  NodeId y) const {
66  return !_TabuList__changes.existsFirst(ArcDeletion(x, y))
67  && !_TabuList__changes.existsFirst(ArcAddition(x, y));
68  }
69 
71  INLINE bool
73  NodeId y) const {
74  return !_TabuList__changes.existsFirst(ArcAddition(x, y))
75  && !_TabuList__changes.existsFirst(ArcDeletion(x, y));
76  }
77 
79  INLINE bool
81  NodeId y) const {
82  return !_TabuList__changes.existsFirst(ArcReversal(y, x))
83  && !_TabuList__changes.existsFirst(ArcReversal(x, y));
84  }
85 
88  const ArcAddition& change) const {
89  return checkArcAdditionAlone(change.node1(), change.node2());
90  }
91 
94  const ArcDeletion& change) const {
95  return checkArcDeletionAlone(change.node1(), change.node2());
96  }
97 
100  const ArcReversal& change) const {
101  return checkArcReversalAlone(change.node1(), change.node2());
102  }
103 
106  const GraphChange& change) const {
107  switch (change.type()) {
109  return checkArcAdditionAlone(change.node1(), change.node2());
110 
112  return checkArcDeletionAlone(change.node1(), change.node2());
113 
115  return checkArcReversalAlone(change.node1(), change.node2());
116 
117  default:
118  GUM_ERROR(OperationNotAllowed,
119  "edge modifications are not "
120  "supported by StructuralConstraintTabuList");
121  }
122  }
123 
125  INLINE void
126  StructuralConstraintTabuList::modifyGraphAlone(const ArcAddition& change) {
129  _TabuList__changes.insert(
130  change, NodeId(_TabuList__offset + _TabuList__changes.size()));
131  }
132 
134  INLINE void
135  StructuralConstraintTabuList::modifyGraphAlone(const ArcDeletion& change) {
138  _TabuList__changes.insert(
139  change, _TabuList__offset + NodeId(_TabuList__changes.size()));
140  }
141 
143  INLINE void
144  StructuralConstraintTabuList::modifyGraphAlone(const ArcReversal& change) {
147  _TabuList__changes.insert(
148  change, _TabuList__offset + NodeId(_TabuList__changes.size()));
149  }
150 
152  INLINE void
153  StructuralConstraintTabuList::modifyGraphAlone(const GraphChange& change) {
154  switch (change.type()) {
156  modifyGraphAlone(static_cast< const ArcAddition& >(change));
157  break;
158 
160  modifyGraphAlone(static_cast< const ArcDeletion& >(change));
161  break;
162 
164  modifyGraphAlone(static_cast< const ArcReversal& >(change));
165  break;
166 
167  default:
168  GUM_ERROR(OperationNotAllowed,
169  "edge modifications are not supported by digraph constraint");
170  }
171  }
172 
175  const GraphChange&) const {
176  return false;
177  }
178 
179 // include all the methods applicable to the whole class hierarchy
180 # define GUM_CONSTRAINT_CLASS_NAME StructuralConstraintTabuList
182 # undef GUM_CONSTRAINT_CLASS_NAME
183 
184  } /* namespace learning */
185 
186 } /* namespace gum */
187 
188 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
void setTabuListSize(Size new_size)
sets the size of the tabu list
bool checkModificationAlone(const GraphChange &change) const
checks whether the constraints enable to perform a graph change
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
NodeId _TabuList__offset
the index of the oldest element
void setGraphAlone(const DiGraph &graph)
sets a new graph from which we will perform checkings
bool checkArcReversalAlone(NodeId x, NodeId y) const
checks whether the constraints enable to reverse arc (x,y)
void modifyGraphAlone(const ArcAddition &change)
notify the constraint of a modification of the graph
bool checkArcDeletionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to remove arc (x,y)
Bijection< GraphChange, NodeId > _TabuList__changes
the tabu list
bool isAlwaysInvalidAlone(const GraphChange &change) const
indicates whether a change will always violate the constraint
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
bool checkArcAdditionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to add arc (x,y)
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55