41 #ifndef GUM_LEARNING_STRUCTURAL_CONSTRAINT_SET_STATIC_H 42 #define GUM_LEARNING_STRUCTURAL_CONSTRAINT_SET_STATIC_H 44 #include <type_traits> 54 #ifndef DOXYGEN_SHOULD_SKIP_THIS 58 struct __StructuralRoot {};
62 template <
typename FIRST_CONSTRAINT,
typename... OTHER_CONSTRAINTS >
63 struct __ConstraintSet;
67 template <
typename SET1,
typename SET2 >
68 struct __ConcatConstraintSet;
73 template <
typename FIRST_CONSTRAINT,
typename... OTHER_CONSTRAINTS >
74 class __StructuralConstraintSetStatic;
79 template <
typename CONSTRAINT,
typename SET >
80 struct __IsInConstraintSet;
82 template <
typename CONSTRAINT,
typename SET >
83 struct __IsInConstraintSet< CONSTRAINT, __ConstraintSet< SET > > {
84 constexpr
static bool value = std::is_same< CONSTRAINT, SET >::value;
87 template <
typename CONSTRAINT,
typename SET1,
typename... SETS >
88 struct __IsInConstraintSet< CONSTRAINT, __ConstraintSet< SET1, SETS... > > {
89 constexpr
static bool value =
90 std::is_same< CONSTRAINT, SET1 >::value
91 || __IsInConstraintSet< CONSTRAINT, __ConstraintSet< SETS... > >::value;
105 template <
typename FIRST_CONSTRAINT,
typename... OTHER_CONSTRAINTS >
106 struct __ConstraintSet :
public __ConstraintSet< OTHER_CONSTRAINTS... > {
107 using minset =
typename std::conditional<
108 __IsInConstraintSet< FIRST_CONSTRAINT,
109 __ConstraintSet< OTHER_CONSTRAINTS... > >::value,
110 typename __ConstraintSet< OTHER_CONSTRAINTS... >::minset,
111 typename __ConcatConstraintSet<
113 typename __ConstraintSet< OTHER_CONSTRAINTS... >::minset >::type >::
116 __StructuralConstraintSetStatic< FIRST_CONSTRAINT, OTHER_CONSTRAINTS... >;
119 template <
typename CONSTRAINT >
120 struct __ConstraintSet< CONSTRAINT > {
121 using minset = __ConstraintSet< CONSTRAINT >;
122 using set = __StructuralConstraintSetStatic< CONSTRAINT >;
128 template <
typename SET1,
typename SET2 >
129 struct __ConcatConstraintSet;
131 template <
typename CONSTRAINT1,
typename CONSTRAINT2 >
132 struct __ConcatConstraintSet< CONSTRAINT1, __ConstraintSet< CONSTRAINT2 > > {
133 using type = __ConstraintSet< CONSTRAINT1, CONSTRAINT2 >;
136 template <
typename CONSTRAINT1,
typename CONSTRAINT2 >
137 struct __ConcatConstraintSet< __ConstraintSet< CONSTRAINT1 >,
138 __ConstraintSet< CONSTRAINT2 > > {
139 using type = __ConstraintSet< CONSTRAINT1, CONSTRAINT2 >;
142 template <
typename CONSTRAINT1,
143 typename CONSTRAINT2,
144 typename... OTHER_CONSTRAINT2 >
145 struct __ConcatConstraintSet<
147 __ConstraintSet< CONSTRAINT2, OTHER_CONSTRAINT2... > > {
149 __ConstraintSet< CONSTRAINT1, CONSTRAINT2, OTHER_CONSTRAINT2... >;
152 template <
typename CONSTRAINT1,
153 typename CONSTRAINT2,
154 typename... OTHER_CONSTRAINT1 >
155 struct __ConcatConstraintSet<
156 __ConstraintSet< CONSTRAINT1, OTHER_CONSTRAINT1... >,
157 __ConstraintSet< CONSTRAINT2 > > {
159 __ConstraintSet< CONSTRAINT1, OTHER_CONSTRAINT1..., CONSTRAINT2 >;
162 template <
typename CONSTRAINT1,
163 typename CONSTRAINT2,
164 typename... OTHER_CONSTR1,
165 typename... OTHER_CONSTR2 >
166 struct __ConcatConstraintSet<
167 __ConstraintSet< CONSTRAINT1, OTHER_CONSTR1... >,
168 __ConstraintSet< CONSTRAINT2, OTHER_CONSTR2... > > {
169 using type = __ConstraintSet< CONSTRAINT1,
179 template <
typename CONSTRAINT1,
typename... OTHER_CONSTRAINTS >
180 class __StructuralConstraintSetStatic
181 :
public virtual CONSTRAINT1
182 ,
public virtual __StructuralConstraintSetStatic< OTHER_CONSTRAINTS... > {
185 using first_constraint = CONSTRAINT1;
188 using next_constraints =
189 __StructuralConstraintSetStatic< OTHER_CONSTRAINTS... >;
193 using allConstraints =
typename __ConcatConstraintSet<
194 typename std::conditional<
195 std::is_base_of< __StructuralRoot, CONSTRAINT1 >::value,
196 typename __ConcatConstraintSet<
198 typename CONSTRAINT1::allConstraints >::type,
199 __ConstraintSet< CONSTRAINT1 > >::type,
200 typename next_constraints::allConstraints >::type;
210 using minConstraints =
typename allConstraints::minset::set;
218 __StructuralConstraintSetStatic();
221 __StructuralConstraintSetStatic(
222 const __StructuralConstraintSetStatic< CONSTRAINT1,
223 OTHER_CONSTRAINTS... >&);
226 ~__StructuralConstraintSetStatic();
236 __StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >&
237 operator=(
const __StructuralConstraintSetStatic< CONSTRAINT1,
238 OTHER_CONSTRAINTS... >&);
248 void setGraph(
const DiGraph& graph);
251 void modifyGraph(
const ArcAddition& change);
254 void modifyGraph(
const ArcDeletion& change);
257 void modifyGraph(
const ArcReversal& change);
260 void modifyGraph(
const GraphChange& change);
263 bool isAlwaysInvalid(
const GraphChange& change)
const;
275 bool checkModification(
const ArcAddition& change)
const;
278 bool checkModification(
const ArcDeletion& change)
const;
281 bool checkModification(
const ArcReversal& change)
const;
284 bool checkModification(
const GraphChange& change)
const;
289 template <
typename CONSTRAINT >
290 class __StructuralConstraintSetStatic< CONSTRAINT >
291 :
public virtual CONSTRAINT
292 ,
public virtual __StructuralRoot {
295 using first_constraint = CONSTRAINT;
298 using next_constraints = __StructuralRoot;
304 using allConstraints =
typename std::conditional<
305 std::is_base_of< __StructuralRoot, CONSTRAINT >::value,
306 typename __ConcatConstraintSet<
308 typename CONSTRAINT::allConstraints >::type,
309 __ConstraintSet< CONSTRAINT > >::type;
319 using minConstraints =
typename allConstraints::minset::set;
327 __StructuralConstraintSetStatic();
330 __StructuralConstraintSetStatic(
331 const __StructuralConstraintSetStatic< CONSTRAINT >&);
334 ~__StructuralConstraintSetStatic();
344 __StructuralConstraintSetStatic< CONSTRAINT >&
345 operator=(
const __StructuralConstraintSetStatic< CONSTRAINT >&);
355 void setGraph(
const DiGraph& graph);
358 void modifyGraph(
const ArcAddition& change);
361 void modifyGraph(
const ArcDeletion& change);
364 void modifyGraph(
const ArcReversal& change);
367 void modifyGraph(
const GraphChange& change);
370 bool isAlwaysInvalid(
const GraphChange& change)
const;
382 bool checkModification(
const ArcAddition& change)
const;
385 bool checkModification(
const ArcDeletion& change)
const;
388 bool checkModification(
const ArcReversal& change)
const;
391 bool checkModification(
const GraphChange& change)
const;
425 template <
typename CONSTRAINT1,
typename... OTHER_CONSTRAINTS >
427 :
public virtual __StructuralConstraintSetStatic<
429 OTHER_CONSTRAINTS... >::minConstraints {
431 using constraints =
typename __StructuralConstraintSetStatic<
433 OTHER_CONSTRAINTS... >::minConstraints;
446 OTHER_CONSTRAINTS... >&);
461 OTHER_CONSTRAINTS... >&);
471 void setGraph(
const DiGraph& graph);
486 bool isAlwaysInvalid(
const GraphChange& change)
const;
498 bool checkModification(
const ArcAddition& change)
const;
501 bool checkModification(
const ArcDeletion& change)
const;
504 bool checkModification(
const ArcReversal& change)
const;
507 bool checkModification(
const GraphChange& change)
const;
512 #ifndef DOXYGEN_SHOULD_SKIP_THIS 514 template <
typename CONSTRAINT >
516 :
public virtual __StructuralConstraintSetStatic<
517 CONSTRAINT >::minConstraints {
520 typename __StructuralConstraintSetStatic< CONSTRAINT >::minConstraints;
556 void setGraph(
const DiGraph& graph);
571 bool isAlwaysInvalid(
const GraphChange& change)
const;
583 bool checkModification(
const ArcAddition& change)
const;
586 bool checkModification(
const ArcDeletion& change)
const;
589 bool checkModification(
const ArcReversal& change)
const;
592 bool checkModification(
const GraphChange& change)
const;
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.