aGrUM  0.16.0
structuralConstraintSliceOrder_inl.h
Go to the documentation of this file.
1 
40 #ifndef DOXYGEN_SHOULD_SKIP_THIS
41 
42 namespace gum {
43 
44  namespace learning {
45 
47  INLINE void
48  StructuralConstraintSliceOrder::setGraphAlone(const DiGraph& graph) {}
49 
51  INLINE bool
53  NodeId y) const {
54  try {
55  return _SliceOrder__order[x] <= _SliceOrder__order[y];
56  } catch (const Exception&) { return true; }
57  }
58 
60  INLINE bool
62  NodeId y) const {
63  return true;
64  }
65 
67  INLINE bool
69  NodeId y) const {
70  try {
71  return _SliceOrder__order[x] == _SliceOrder__order[y];
72  } catch (const Exception&) { return true; }
73  }
74 
77  const ArcAddition& change) {}
78 
81  const ArcDeletion& change) {}
82 
85  const ArcReversal& change) {}
86 
89  const GraphChange& change) {}
90 
93  const GraphChange& change) const {
94  switch (change.type()) {
96  try {
97  return (_SliceOrder__order[change.node1()]
98  > _SliceOrder__order[change.node2()]);
99  } catch (const Exception&) { return false; }
100 
101  case GraphChangeType::ARC_DELETION: return false;
102 
104  try {
105  return (_SliceOrder__order[change.node1()]
106  != _SliceOrder__order[change.node2()]);
107  } catch (const Exception&) { return false; }
108 
109  default:
110  GUM_ERROR(OperationNotAllowed,
111  "edge modifications are not "
112  "supported by SliceOrder constraints");
113  }
114  }
115 
118  const ArcAddition& change) const {
119  return checkArcAdditionAlone(change.node1(), change.node2());
120  }
121 
124  const ArcDeletion& change) const {
125  return checkArcDeletionAlone(change.node1(), change.node2());
126  }
127 
130  const ArcReversal& change) const {
131  return checkArcReversalAlone(change.node1(), change.node2());
132  }
133 
136  const GraphChange& change) const {
137  switch (change.type()) {
139  return checkArcAdditionAlone(change.node1(), change.node2());
140 
142  return checkArcDeletionAlone(change.node1(), change.node2());
143 
145  return checkArcReversalAlone(change.node1(), change.node2());
146 
147  default:
148  GUM_ERROR(OperationNotAllowed,
149  "edge modifications are not "
150  "supported by StructuralConstraintSliceOrder");
151  }
152  }
153 
156  const NodeProperty< NodeId >& order) {
157  _SliceOrder__order = order;
158  }
159 
162  for (auto& node : _SliceOrder__order) {
163  node.second = slice;
164  }
165  }
166 
169  NodeId slice) {
170  _SliceOrder__order.set(node, slice);
171  }
172 
174  INLINE const NodeProperty< NodeId >&
176  return _SliceOrder__order;
177  }
178 
179 // include all the methods applicable to the whole class hierarchy
180 # define GUM_CONSTRAINT_CLASS_NAME StructuralConstraintSliceOrder
182 # undef GUM_CONSTRAINT_CLASS_NAME
183 
184  } /* namespace learning */
185 
186 } /* namespace gum */
187 
188 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
bool checkArcAdditionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to add arc (x,y)
bool checkArcReversalAlone(NodeId x, NodeId y) const
checks whether the constraints enable to reverse arc (x,y)
bool checkArcDeletionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to remove arc (x,y)
void setGraphAlone(const DiGraph &graph)
sets a new graph from which we will perform checkings
void setDefaultSlice(NodeId slice)
assign a given slice to all the nodes specified in the partial order
NodeProperty< NodeId > _SliceOrder__order
slices to which belong the nodes
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
bool checkModificationAlone(const ArcAddition &change) const
checks whether the constraints enable to add an arc
void setSliceOrder(const NodeProperty< NodeId > &slice)
sets the time slices of all the nodes in the property
const NodeProperty< NodeId > & sliceOrder() const
returns the current slice order
bool isAlwaysInvalidAlone(const GraphChange &change) const
indicates whether a change will always violate the constraint
void modifyGraphAlone(const ArcAddition &change)
notify the constraint of a modification of the graph
Size NodeId
Type for node ids.
Definition: graphElements.h:98
void addNode(NodeId node, NodeId slice)
adds a new node in the slice order
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55