aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
structuralConstraintIndegree_inl.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by 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)
48  }
49 
50  /// checks whether the constraints enable to remove arc (x,y)
52  return true;
53  }
54 
55  /// checks whether the constraints enable to reverse arc (x,y)
58  }
59 
60  /// checks whether the constraints enable to add an arc
61  INLINE bool
64  }
65 
66  /// checks whether the constraints enable to remove an arc
67  INLINE bool
70  }
71 
72  /// checks whether the constraints enable to reverse an arc
73  INLINE bool
76  }
77 
78  /// checks whether the constraints enable to perform a graph change
79  INLINE bool
81  switch (change.type()) {
84 
87 
90 
91  default:
93  "edge modifications are not "
94  "supported by StructuralConstraintIndegree");
95  }
96  }
97 
98  /// notify the constraint of a modification of the graph
100 
101  /// notify the constraint of a modification of the graph
103 
104  /// notify the constraint of a modification of the graph
106 
107  /// notify the constraint of a modification of the graph
109 
110  /// indicates whether a change will always violate the constraint
111  INLINE bool
114  && (_Indegree_max_parents_[change.node2()] == 0)) {
115  return true;
116  } else if ((change.type() == GraphChangeType::ARC_REVERSAL)
117  && (_Indegree_max_parents_[change.node1()] == 0)) {
118  return true;
119  } else {
120  return false;
121  }
122  }
123 
124  /// sets the indegree for a given set of nodes
125  INLINE void
127  for (const auto& degree: max_indegree) {
129  }
130  }
131 
132  /// resets the max indegree
134  if (update_all) {
135  for (auto& degree: _Indegree_max_parents_) {
137  }
138  }
139 
141  }
142 
143 // include all the methods applicable to the whole class hierarchy
144 # define GUM_CONSTRAINT_CLASS_NAME StructuralConstraintIndegree
145 # include <agrum/BN/learning/constraints/structuralConstraintPatternInline.h>
146 # undef GUM_CONSTRAINT_CLASS_NAME
147 
148  } /* namespace learning */
149 
150 } /* namespace gum */
151 
152 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)