aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
graphChange_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 A class to account for changes in a graph
24  *
25  * This class shall be used by learning algorithms to notify scores, structural
26  * constraints, etc, that the learnt graph has been modified.
27  *
28  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
29  */
30 #ifndef DOXYGEN_SHOULD_SKIP_THIS
31 
32 namespace gum {
33 
34  namespace learning {
35 
36  /// default constructor
40  }
41 
42  /// copy constructor
43  INLINE GraphChange::GraphChange(const GraphChange& from) noexcept :
46  }
47 
48  /// move constructor
52  }
53 
54  /// destructor
55  INLINE GraphChange::~GraphChange() noexcept {
57  ;
58  }
59 
60  /// copy constructor
61  INLINE GraphChange& GraphChange::operator=(const GraphChange& from) noexcept {
62  _type_ = from._type_;
65  return *this;
66  }
67 
68  /// move operator
70  _type_ = from._type_;
73  return *this;
74  }
75 
76  /// returns the type of the operation
77  INLINE GraphChangeType GraphChange::type() const noexcept { return _type_; }
78 
79  /// returns the first node involved in the modification
80  INLINE NodeId GraphChange::node1() const noexcept { return _node1_; }
81 
82  /// returns the second node involved in the modification
83  INLINE NodeId GraphChange::node2() const noexcept { return _node2_; }
84 
85  /// returns whether two graph changes are identical or not
86  INLINE bool GraphChange::operator==(const GraphChange& from) const noexcept {
87  return ((_node1_ == from._node1_) && (_node2_ == from._node2_) && (_type_ == from._type_));
88  }
89 
90  /// returns whether two graph changes are different or not
91  INLINE bool GraphChange::operator!=(const GraphChange& from) const noexcept {
92  return !operator==(from);
93  }
94 
95  // ===========================================================================
96 
97  /// default constructor
100  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
101  // destructor, we did not make the latter's destructor virtual.
102  }
103 
104  /// copy constructor
106  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
107  // destructor, we did not make the latter's destructor virtual.
108  }
109 
110  /// move constructor
112  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
113  // destructor, we did not make the latter's destructor virtual.
114  }
115 
116  /// destructor
117  INLINE ArcAddition::~ArcAddition() noexcept {
118  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
119  // destructor, we did not make the latter's destructor virtual.
120  }
121 
122  /// copy constructor
123  INLINE ArcAddition& ArcAddition::operator=(const ArcAddition& from) noexcept {
125  return *this;
126  }
127 
128  /// move operator
131  return *this;
132  }
133 
134  /// returns whether two graph changes are identical or not
135  INLINE bool ArcAddition::operator==(const ArcAddition& from) const noexcept {
136  return ((node1() == from.node1()) && (node2() == from.node2()));
137  }
138 
139  /// returns whether two graph changes are different or not
140  INLINE bool ArcAddition::operator!=(const ArcAddition& from) const noexcept {
141  return !operator==(from);
142  }
143 
144  // ===========================================================================
145 
146  /// default constructor
149  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
150  // destructor, we did not make the latter's destructor virtual.
151  }
152 
153  /// copy constructor
155  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
156  // destructor, we did not make the latter's destructor virtual.
157  }
158 
159  /// move constructor
161  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
162  // destructor, we did not make the latter's destructor virtual.
163  }
164 
165  /// destructor
166  INLINE ArcDeletion::~ArcDeletion() noexcept {
167  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
168  // destructor, we did not make the latter's destructor virtual.
169  }
170 
171  /// copy constructor
172  INLINE ArcDeletion& ArcDeletion::operator=(const ArcDeletion& from) noexcept {
174  return *this;
175  }
176 
177  /// move operator
180  return *this;
181  }
182 
183  /// returns whether two graph changes are identical or not
184  INLINE bool ArcDeletion::operator==(const ArcDeletion& from) const noexcept {
185  return ((node1() == from.node1()) && (node2() == from.node2()));
186  }
187 
188  /// returns whether two graph changes are different or not
189  INLINE bool ArcDeletion::operator!=(const ArcDeletion& from) const noexcept {
190  return !operator==(from);
191  }
192 
193  // ===========================================================================
194 
195  /// default constructor
198  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
199  // destructor, we did not make the latter's destructor virtual.
200  }
201 
202  /// copy constructor
204  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
205  // destructor, we did not make the latter's destructor virtual.
206  }
207 
208  /// move constructor
210  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
211  // destructor, we did not make the latter's destructor virtual.
212  }
213 
214  /// destructor
215  INLINE ArcReversal::~ArcReversal() noexcept {
216  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
217  // destructor, we did not make the latter's destructor virtual.
218  }
219 
220  /// copy constructor
221  INLINE ArcReversal& ArcReversal::operator=(const ArcReversal& from) noexcept {
223  return *this;
224  }
225 
226  /// move operator
229  return *this;
230  }
231 
232  /// returns whether two arc reversals are identical or not
233  INLINE bool ArcReversal::operator==(const ArcReversal& from) const noexcept {
234  return ((node1() == from.node1()) && (node2() == from.node2()));
235  }
236 
237  /// returns whether two arc reversals are different or not
238  INLINE bool ArcReversal::operator!=(const ArcReversal& from) const noexcept {
239  return !operator==(from);
240  }
241 
242  // ===========================================================================
243 
244  /// default constructor
247  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
248  // destructor, we did not make the latter's destructor virtual.
249  }
250 
251  /// copy constructor
253  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
254  // destructor, we did not make the latter's destructor virtual.
255  }
256 
257  /// move constructor
259  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
260  // destructor, we did not make the latter's destructor virtual.
261  }
262 
263  /// destructor
264  INLINE EdgeAddition::~EdgeAddition() noexcept {
265  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
266  // destructor, we did not make the latter's destructor virtual.
267  }
268 
269  /// copy constructor
272  return *this;
273  }
274 
275  /// move operator
278  return *this;
279  }
280 
281  /// returns whether two graph changes are identical or not
282  INLINE bool EdgeAddition::operator==(const EdgeAddition& from) const noexcept {
283  return (((node1() == from.node1()) && (node2() == from.node2()))
284  || ((node1() == from.node2()) && (node2() == from.node1())));
285  }
286 
287  /// returns whether two graph changes are different or not
288  INLINE bool EdgeAddition::operator!=(const EdgeAddition& from) const noexcept {
289  return !operator==(from);
290  }
291 
292  // ===========================================================================
293 
294  /// default constructor
297  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
298  // destructor, we did not make the latter's destructor virtual.
299  }
300 
301  /// copy constructor
303  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
304  // destructor, we did not make the latter's destructor virtual.
305  }
306 
307  /// move constructor
309  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
310  // destructor, we did not make the latter's destructor virtual.
311  }
312 
313  /// destructor
314  INLINE EdgeDeletion::~EdgeDeletion() noexcept {
315  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
316  // destructor, we did not make the latter's destructor virtual.
317  }
318 
319  /// copy constructor
322  return *this;
323  }
324 
325  /// move operator
328  return *this;
329  }
330 
331  /// returns whether two graph changes are identical or not
332  INLINE bool EdgeDeletion::operator==(const EdgeDeletion& from) const noexcept {
333  return (((node1() == from.node1()) && (node2() == from.node2()))
334  || ((node1() == from.node2()) && (node2() == from.node1())));
335  }
336 
337  /// returns whether two graph changes are different or not
338  INLINE bool EdgeDeletion::operator!=(const EdgeDeletion& from) const noexcept {
339  return !operator==(from);
340  }
341 
342 
343  } /* namespace learning */
344 
345 
346  // ===========================================================================
347 
348  // Returns the value of a key as a Size.
349  INLINE Size HashFunc< learning::GraphChange >::castToSize(const learning::GraphChange& key) {
350  return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi;
351  }
352 
353  /// computes the hashed value of a key
354  INLINE Size
356  return castToSize(key) >> this->right_shift_;
357  }
358 
359 
360  // Returns the value of a key as a Size.
362  return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi;
363  }
364 
365  /// computes the hashed value of a key
366  INLINE Size
368  return castToSize(key) >> this->right_shift_;
369  }
370 
371 
372  // Returns the value of a key as a Size.
374  return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi;
375  }
376 
377  /// computes the hashed value of a key
378  INLINE Size
380  return castToSize(key) >> this->right_shift_;
381  }
382 
383 
384  // Returns the value of a key as a Size.
386  return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi;
387  }
388 
389  /// computes the hashed value of a key
390  INLINE Size
392  return castToSize(key) >> this->right_shift_;
393  }
394 
395 
396  // Returns the value of a key as a Size.
398  return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi;
399  }
400 
401  /// computes the hashed value of a key
402  INLINE Size
404  return castToSize(key) >> this->right_shift_;
405  }
406 
407 
408  // Returns the value of a key as a Size.
410  return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi;
411  }
412 
413  /// computes the hashed value of a key
414  INLINE Size
416  return castToSize(key) >> this->right_shift_;
417  }
418 
419 } /* namespace gum */
420 
421 #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)