aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
structuralConstraintIndegree_inl.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /** @file
23  * @brief the class for structural constraints limiting the number of parents
24  * of nodes in a directed graph
25  *
26  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
27  */
28 
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 
31 namespace gum {
32 
33  namespace learning {
34 
35  /// sets a new graph from which we will perform checkings
37  // check that the max_indegree corresponds to the graph
38  for (const auto id: graph) {
41  }
42  }
43  }
44 
45  /// checks whether the constraints enable to add arc (x,y)
46  INLINE bool
48  NodeId y) const {
50  }
51 
52  /// checks whether the constraints enable to remove arc (x,y)
53  INLINE bool
55  NodeId y) const {
56  return true;
57  }
58 
59  /// checks whether the constraints enable to reverse arc (x,y)
60  INLINE bool
62  NodeId y) const {
64  }
65 
66  /// checks whether the constraints enable to add an arc
68  const ArcAddition& change) const {
70  }
71 
72  /// checks whether the constraints enable to remove an arc
74  const ArcDeletion& change) const {
76  }
77 
78  /// checks whether the constraints enable to reverse an arc
80  const ArcReversal& change) const {
82  }
83 
84  /// checks whether the constraints enable to perform a graph change
86  const GraphChange& change) const {
87  switch (change.type()) {
90 
93 
96 
97  default:
99  "edge modifications are not "
100  "supported by StructuralConstraintIndegree");
101  }
102  }
103 
104  /// notify the constraint of a modification of the graph
105  INLINE void
107 
108  /// notify the constraint of a modification of the graph
109  INLINE void
111 
112  /// notify the constraint of a modification of the graph
113  INLINE void
115 
116  /// notify the constraint of a modification of the graph
117  INLINE void
119 
120  /// indicates whether a change will always violate the constraint
122  const GraphChange& change) const {
124  && (Indegree__max_parents_[change.node2()] == 0)) {
125  return true;
126  } else if ((change.type() == GraphChangeType::ARC_REVERSAL)
127  && (Indegree__max_parents_[change.node1()] == 0)) {
128  return true;
129  } else {
130  return false;
131  }
132  }
133 
134  /// sets the indegree for a given set of nodes
136  const NodeProperty< Size >& max_indegree) {
137  for (const auto& degree: max_indegree) {
139  }
140  }
141 
142  /// resets the max indegree
144  bool update_all) {
145  if (update_all) {
146  for (auto& degree: Indegree__max_parents_) {
148  }
149  }
150 
152  }
153 
154 // include all the methods applicable to the whole class hierarchy
155 # define GUM_CONSTRAINT_CLASS_NAME StructuralConstraintIndegree
156 # include <agrum/BN/learning/constraints/structuralConstraintPatternInline.h>
157 # undef GUM_CONSTRAINT_CLASS_NAME
158 
159  } /* namespace learning */
160 
161 } /* namespace gum */
162 
163 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)