38 #ifndef GUM_LEARNING_STRUCTURAL_CONSTRAINT_SET_STATIC_H 39 #define GUM_LEARNING_STRUCTURAL_CONSTRAINT_SET_STATIC_H 41 #include <type_traits> 51 #ifndef DOXYGEN_SHOULD_SKIP_THIS 55 struct __StructuralRoot {};
59 template <
typename FIRST_CONSTRAINT,
typename... OTHER_CONSTRAINTS >
60 struct __ConstraintSet;
64 template <
typename SET1,
typename SET2 >
65 struct __ConcatConstraintSet;
70 template <
typename FIRST_CONSTRAINT,
typename... OTHER_CONSTRAINTS >
71 class __StructuralConstraintSetStatic;
76 template <
typename CONSTRAINT,
typename SET >
77 struct __IsInConstraintSet;
79 template <
typename CONSTRAINT,
typename SET >
80 struct __IsInConstraintSet< CONSTRAINT, __ConstraintSet< SET > > {
81 constexpr
static bool value = std::is_same< CONSTRAINT, SET >::value;
84 template <
typename CONSTRAINT,
typename SET1,
typename... SETS >
85 struct __IsInConstraintSet< CONSTRAINT, __ConstraintSet< SET1, SETS... > > {
86 constexpr
static bool value =
87 std::is_same< CONSTRAINT, SET1 >::value
88 || __IsInConstraintSet< CONSTRAINT, __ConstraintSet< SETS... > >::value;
102 template <
typename FIRST_CONSTRAINT,
typename... OTHER_CONSTRAINTS >
103 struct __ConstraintSet :
public __ConstraintSet< OTHER_CONSTRAINTS... > {
104 using minset =
typename std::conditional<
105 __IsInConstraintSet< FIRST_CONSTRAINT,
106 __ConstraintSet< OTHER_CONSTRAINTS... > >::value,
107 typename __ConstraintSet< OTHER_CONSTRAINTS... >::minset,
108 typename __ConcatConstraintSet<
110 typename __ConstraintSet< OTHER_CONSTRAINTS... >::minset >::type >::
113 __StructuralConstraintSetStatic< FIRST_CONSTRAINT, OTHER_CONSTRAINTS... >;
116 template <
typename CONSTRAINT >
117 struct __ConstraintSet< CONSTRAINT > {
118 using minset = __ConstraintSet< CONSTRAINT >;
119 using set = __StructuralConstraintSetStatic< CONSTRAINT >;
125 template <
typename SET1,
typename SET2 >
126 struct __ConcatConstraintSet;
128 template <
typename CONSTRAINT1,
typename CONSTRAINT2 >
129 struct __ConcatConstraintSet< CONSTRAINT1, __ConstraintSet< CONSTRAINT2 > > {
130 using type = __ConstraintSet< CONSTRAINT1, CONSTRAINT2 >;
133 template <
typename CONSTRAINT1,
typename CONSTRAINT2 >
134 struct __ConcatConstraintSet< __ConstraintSet< CONSTRAINT1 >,
135 __ConstraintSet< CONSTRAINT2 > > {
136 using type = __ConstraintSet< CONSTRAINT1, CONSTRAINT2 >;
139 template <
typename CONSTRAINT1,
140 typename CONSTRAINT2,
141 typename... OTHER_CONSTRAINT2 >
142 struct __ConcatConstraintSet<
144 __ConstraintSet< CONSTRAINT2, OTHER_CONSTRAINT2... > > {
146 __ConstraintSet< CONSTRAINT1, CONSTRAINT2, OTHER_CONSTRAINT2... >;
149 template <
typename CONSTRAINT1,
150 typename CONSTRAINT2,
151 typename... OTHER_CONSTRAINT1 >
152 struct __ConcatConstraintSet<
153 __ConstraintSet< CONSTRAINT1, OTHER_CONSTRAINT1... >,
154 __ConstraintSet< CONSTRAINT2 > > {
156 __ConstraintSet< CONSTRAINT1, OTHER_CONSTRAINT1..., CONSTRAINT2 >;
159 template <
typename CONSTRAINT1,
160 typename CONSTRAINT2,
161 typename... OTHER_CONSTR1,
162 typename... OTHER_CONSTR2 >
163 struct __ConcatConstraintSet<
164 __ConstraintSet< CONSTRAINT1, OTHER_CONSTR1... >,
165 __ConstraintSet< CONSTRAINT2, OTHER_CONSTR2... > > {
166 using type = __ConstraintSet< CONSTRAINT1,
176 template <
typename CONSTRAINT1,
typename... OTHER_CONSTRAINTS >
177 class __StructuralConstraintSetStatic
178 :
public virtual CONSTRAINT1
179 ,
public virtual __StructuralConstraintSetStatic< OTHER_CONSTRAINTS... > {
182 using first_constraint = CONSTRAINT1;
185 using next_constraints =
186 __StructuralConstraintSetStatic< OTHER_CONSTRAINTS... >;
190 using allConstraints =
typename __ConcatConstraintSet<
191 typename std::conditional<
192 std::is_base_of< __StructuralRoot, CONSTRAINT1 >::value,
193 typename __ConcatConstraintSet<
195 typename CONSTRAINT1::allConstraints >::type,
196 __ConstraintSet< CONSTRAINT1 > >::type,
197 typename next_constraints::allConstraints >::type;
207 using minConstraints =
typename allConstraints::minset::set;
215 __StructuralConstraintSetStatic();
218 __StructuralConstraintSetStatic(
219 const __StructuralConstraintSetStatic< CONSTRAINT1,
220 OTHER_CONSTRAINTS... >&);
223 ~__StructuralConstraintSetStatic();
233 __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >&
234 operator=(
const __StructuralConstraintSetStatic< CONSTRAINT1,
235 OTHER_CONSTRAINTS... >&);
245 void setGraph(
const DiGraph& graph);
248 void modifyGraph(
const ArcAddition& change);
251 void modifyGraph(
const ArcDeletion& change);
254 void modifyGraph(
const ArcReversal& change);
257 void modifyGraph(
const GraphChange& change);
260 bool isAlwaysInvalid(
const GraphChange& change)
const;
272 bool checkModification(
const ArcAddition& change)
const;
275 bool checkModification(
const ArcDeletion& change)
const;
278 bool checkModification(
const ArcReversal& change)
const;
281 bool checkModification(
const GraphChange& change)
const;
286 template <
typename CONSTRAINT >
287 class __StructuralConstraintSetStatic< CONSTRAINT >
288 :
public virtual CONSTRAINT
289 ,
public virtual __StructuralRoot {
292 using first_constraint = CONSTRAINT;
295 using next_constraints = __StructuralRoot;
301 using allConstraints =
typename std::conditional<
302 std::is_base_of< __StructuralRoot, CONSTRAINT >::value,
303 typename __ConcatConstraintSet<
305 typename CONSTRAINT::allConstraints >::type,
306 __ConstraintSet< CONSTRAINT > >::type;
316 using minConstraints =
typename allConstraints::minset::set;
324 __StructuralConstraintSetStatic();
327 __StructuralConstraintSetStatic(
328 const __StructuralConstraintSetStatic< CONSTRAINT >&);
331 ~__StructuralConstraintSetStatic();
341 __StructuralConstraintSetStatic< CONSTRAINT >&
342 operator=(
const __StructuralConstraintSetStatic< CONSTRAINT >&);
352 void setGraph(
const DiGraph& graph);
355 void modifyGraph(
const ArcAddition& change);
358 void modifyGraph(
const ArcDeletion& change);
361 void modifyGraph(
const ArcReversal& change);
364 void modifyGraph(
const GraphChange& change);
367 bool isAlwaysInvalid(
const GraphChange& change)
const;
379 bool checkModification(
const ArcAddition& change)
const;
382 bool checkModification(
const ArcDeletion& change)
const;
385 bool checkModification(
const ArcReversal& change)
const;
388 bool checkModification(
const GraphChange& change)
const;
422 template <
typename CONSTRAINT1,
typename... OTHER_CONSTRAINTS >
424 :
public virtual __StructuralConstraintSetStatic<
426 OTHER_CONSTRAINTS... >::minConstraints {
428 using constraints =
typename __StructuralConstraintSetStatic<
430 OTHER_CONSTRAINTS... >::minConstraints;
443 OTHER_CONSTRAINTS... >&);
458 OTHER_CONSTRAINTS... >&);
468 void setGraph(
const DiGraph& graph);
483 bool isAlwaysInvalid(
const GraphChange& change)
const;
495 bool checkModification(
const ArcAddition& change)
const;
498 bool checkModification(
const ArcDeletion& change)
const;
501 bool checkModification(
const ArcReversal& change)
const;
504 bool checkModification(
const GraphChange& change)
const;
509 #ifndef DOXYGEN_SHOULD_SKIP_THIS 511 template <
typename CONSTRAINT >
513 :
public virtual __StructuralConstraintSetStatic<
514 CONSTRAINT >::minConstraints {
517 typename __StructuralConstraintSetStatic< CONSTRAINT >::minConstraints;
553 void setGraph(
const DiGraph& graph);
568 bool isAlwaysInvalid(
const GraphChange& change)
const;
580 bool checkModification(
const ArcAddition& change)
const;
583 bool checkModification(
const ArcDeletion& change)
const;
586 bool checkModification(
const ArcReversal& change)
const;
589 bool checkModification(
const GraphChange& change)
const;
Base classes for oriented graphs.
the classes to account for structure changes in a graph
The class for notifying learning algorithms of new arc additionsThis class is convenient to know at c...
The class for notifying learning algorithms of arc removalsThis class is convenient to know at compil...
gum is the global namespace for all aGrUM entities
typename __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::minConstraints constraints
the "meta-programming" class for storing structural constraintsIn aGrUM, there are two ways to store ...
Base class for all oriented graphs.
The class for notifying learning algorithms of arc reversalsThis class is convenient to know at compi...
Size NodeId
Type for node ids.
the "meta-programming" class for storing several structural constraints