60#ifndef GUM_LEARNING_STRUCTURAL_CONSTRAINT_SET_STATIC_H
61#define GUM_LEARNING_STRUCTURAL_CONSTRAINT_SET_STATIC_H
74#ifndef DOXYGEN_SHOULD_SKIP_THIS
78 struct _StructuralRoot_ {};
82 template <
typename FIRST_CONSTRAINT,
typename... OTHER_CONSTRAINTS >
83 struct _ConstraintSet_;
87 template <
typename SET1,
typename SET2 >
88 struct _ConcatConstraintSet_;
93 template <
typename FIRST_CONSTRAINT,
typename... OTHER_CONSTRAINTS >
94 class _StructuralConstraintSetStatic_;
99 template <
typename CONSTRAINT,
typename SET >
100 struct _IsInConstraintSet_;
102 template <
typename CONSTRAINT,
typename SET >
103 struct _IsInConstraintSet_< CONSTRAINT, _ConstraintSet_< SET > > {
104 constexpr static bool value = std::is_same< CONSTRAINT, SET >::value;
107 template <
typename CONSTRAINT,
typename SET1,
typename... SETS >
108 struct _IsInConstraintSet_< CONSTRAINT, _ConstraintSet_< SET1, SETS... > > {
109 constexpr static bool value
110 = std::is_same< CONSTRAINT, SET1 >::value
111 || _IsInConstraintSet_< CONSTRAINT, _ConstraintSet_< SETS... > >::value;
125 template <
typename FIRST_CONSTRAINT,
typename... OTHER_CONSTRAINTS >
126 struct _ConstraintSet_:
public _ConstraintSet_< OTHER_CONSTRAINTS... > {
127 using minset =
typename std::conditional<
128 _IsInConstraintSet_< FIRST_CONSTRAINT, _ConstraintSet_< OTHER_CONSTRAINTS... > >::value,
129 typename _ConstraintSet_< OTHER_CONSTRAINTS... >::minset,
130 typename _ConcatConstraintSet_<
132 typename _ConstraintSet_< OTHER_CONSTRAINTS... >::minset >::type >::type;
133 using set = _StructuralConstraintSetStatic_< FIRST_CONSTRAINT, OTHER_CONSTRAINTS... >;
136 template <
typename CONSTRAINT >
137 struct _ConstraintSet_< CONSTRAINT > {
138 using minset = _ConstraintSet_< CONSTRAINT >;
139 using set = _StructuralConstraintSetStatic_< CONSTRAINT >;
145 template <
typename SET1,
typename SET2 >
146 struct _ConcatConstraintSet_;
148 template <
typename CONSTRAINT1,
typename CONSTRAINT2 >
149 struct _ConcatConstraintSet_< CONSTRAINT1, _ConstraintSet_< CONSTRAINT2 > > {
150 using type = _ConstraintSet_< CONSTRAINT1, CONSTRAINT2 >;
153 template <
typename CONSTRAINT1,
typename CONSTRAINT2 >
154 struct _ConcatConstraintSet_< _ConstraintSet_< CONSTRAINT1 >, _ConstraintSet_< CONSTRAINT2 > > {
155 using type = _ConstraintSet_< CONSTRAINT1, CONSTRAINT2 >;
158 template <
typename CONSTRAINT1,
typename CONSTRAINT2,
typename... OTHER_CONSTRAINT2 >
159 struct _ConcatConstraintSet_< CONSTRAINT1,
160 _ConstraintSet_< CONSTRAINT2, OTHER_CONSTRAINT2... > > {
161 using type = _ConstraintSet_< CONSTRAINT1, CONSTRAINT2, OTHER_CONSTRAINT2... >;
164 template <
typename CONSTRAINT1,
typename CONSTRAINT2,
typename... OTHER_CONSTRAINT1 >
165 struct _ConcatConstraintSet_< _ConstraintSet_< CONSTRAINT1, OTHER_CONSTRAINT1... >,
166 _ConstraintSet_< CONSTRAINT2 > > {
167 using type = _ConstraintSet_< CONSTRAINT1, OTHER_CONSTRAINT1..., CONSTRAINT2 >;
170 template <
typename CONSTRAINT1,
171 typename CONSTRAINT2,
172 typename... OTHER_CONSTR1,
173 typename... OTHER_CONSTR2 >
174 struct _ConcatConstraintSet_< _ConstraintSet_< CONSTRAINT1, OTHER_CONSTR1... >,
175 _ConstraintSet_< CONSTRAINT2, OTHER_CONSTR2... > > {
176 using type = _ConstraintSet_< CONSTRAINT1, OTHER_CONSTR1..., CONSTRAINT2, OTHER_CONSTR2... >;
183 template <
typename CONSTRAINT1,
typename... OTHER_CONSTRAINTS >
184 class _StructuralConstraintSetStatic_:
185 public virtual CONSTRAINT1,
186 public virtual _StructuralConstraintSetStatic_< OTHER_CONSTRAINTS... > {
189 using first_constraint = CONSTRAINT1;
192 using next_constraints = _StructuralConstraintSetStatic_< OTHER_CONSTRAINTS... >;
196 using allConstraints =
typename _ConcatConstraintSet_<
197 typename std::conditional<
198 std::is_base_of< _StructuralRoot_, CONSTRAINT1 >::value,
199 typename _ConcatConstraintSet_< CONSTRAINT1,
200 typename CONSTRAINT1::allConstraints >::type,
201 _ConstraintSet_< CONSTRAINT1 > >::type,
202 typename next_constraints::allConstraints >::type;
212 using minConstraints =
typename allConstraints::minset::set;
220 _StructuralConstraintSetStatic_();
223 _StructuralConstraintSetStatic_(
224 const _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >&);
227 ~_StructuralConstraintSetStatic_();
237 _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >&
238 operator=(
const _StructuralConstraintSetStatic_< CONSTRAINT1, 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;
266 bool checkArcAddition(NodeId x, NodeId y)
const;
269 bool checkArcDeletion(NodeId x, NodeId y)
const;
272 bool checkArcReversal(NodeId x, NodeId y)
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_;
302 using allConstraints =
typename std::conditional<
303 std::is_base_of< _StructuralRoot_, CONSTRAINT >::value,
304 typename _ConcatConstraintSet_< CONSTRAINT, typename CONSTRAINT::allConstraints >::type,
305 _ConstraintSet_< CONSTRAINT > >::type;
315 using minConstraints =
typename allConstraints::minset::set;
323 _StructuralConstraintSetStatic_();
326 _StructuralConstraintSetStatic_(
const _StructuralConstraintSetStatic_< CONSTRAINT >&);
329 ~_StructuralConstraintSetStatic_();
339 _StructuralConstraintSetStatic_< CONSTRAINT >&
340 operator=(
const _StructuralConstraintSetStatic_< CONSTRAINT >&);
350 void setGraph(
const DiGraph& graph);
353 void modifyGraph(
const ArcAddition& change);
356 void modifyGraph(
const ArcDeletion& change);
359 void modifyGraph(
const ArcReversal& change);
362 void modifyGraph(
const GraphChange& change);
365 bool isAlwaysInvalid(
const GraphChange& change)
const;
368 bool checkArcAddition(NodeId x, NodeId y)
const;
371 bool checkArcDeletion(NodeId x, NodeId y)
const;
374 bool checkArcReversal(NodeId x, NodeId y)
const;
377 bool checkModification(
const ArcAddition& change)
const;
380 bool checkModification(
const ArcDeletion& change)
const;
383 bool checkModification(
const ArcReversal& change)
const;
386 bool checkModification(
const GraphChange& change)
const;
420 template <
typename CONSTRAINT1,
typename... OTHER_CONSTRAINTS >
422 public virtual _StructuralConstraintSetStatic_< CONSTRAINT1,
423 OTHER_CONSTRAINTS... >::minConstraints {
426 typename _StructuralConstraintSetStatic_< CONSTRAINT1,
427 OTHER_CONSTRAINTS... >::minConstraints;
504#ifndef DOXYGEN_SHOULD_SKIP_THIS
506 template <
typename CONSTRAINT >
508 public virtual _StructuralConstraintSetStatic_< CONSTRAINT >::minConstraints {
510 using constraints =
typename _StructuralConstraintSetStatic_< CONSTRAINT >::minConstraints;
Base class for all oriented graphs.
The class for notifying learning algorithms of new arc additions.
The class for notifying learning algorithms of arc removals.
The class for notifying learning algorithms of arc reversals.
the "meta-programming" class for storing structural constraints
bool checkModification(const GraphChange &change) const
checks whether the constraints enable to perform a graph change
bool checkArcReversal(NodeId x, NodeId y) const
checks whether the constraints enable to reverse arc (x,y)
void modifyGraph(const ArcDeletion &change)
notify the constraint of a modification of the graph
void modifyGraph(const ArcAddition &change)
notify the constraint of a modification of the graph
~StructuralConstraintSetStatic()
destructor
bool checkModification(const ArcAddition &change) const
checks whether the constraints enable to add an arc
bool checkModification(const ArcReversal &change) const
checks whether the constraints enable to reverse an arc
typename _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::minConstraints constraints
void modifyGraph(const ArcReversal &change)
notify the constraint of a modification of the graph
StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... > & operator=(const StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... > &)
copy operator
void modifyGraph(const GraphChange &change)
notify the constraint of a modification of the graph
bool isAlwaysInvalid(const GraphChange &change) const
indicates whether a change will always violate the constraint
bool checkArcDeletion(NodeId x, NodeId y) const
checks whether the constraints enable to remove arc (x,y)
StructuralConstraintSetStatic()
default constructor
bool checkArcAddition(NodeId x, NodeId y) const
checks whether the constraints enable to add arc (x,y)
void setGraph(const DiGraph &graph)
sets a new graph from which we will perform checkings
bool checkModification(const ArcDeletion &change) const
checks whether the constraints enable to remove an arc
StructuralConstraintSetStatic(const StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... > &)
copy constructor
Base classes for oriented graphs.
the classes to account for structure changes in a graph
Size NodeId
Type for node ids.
include the inlined functions if necessary
gum is the global namespace for all aGrUM entities
the "meta-programming" class for storing several structural constraints