aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
structuralConstraintSetStatic_tpl.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2026 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2026 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41#pragma once
42
43
51#ifndef DOXYGEN_SHOULD_SKIP_THIS
52
53# include <iostream>
54
55namespace gum {
56
57 namespace learning {
58
60 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
61 _StructuralConstraintSetStatic_< CONSTRAINT1,
62 OTHER_CONSTRAINTS... >::_StructuralConstraintSetStatic_()
63 = default;
64
66 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
67 _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::
68 _StructuralConstraintSetStatic_(
69 const _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >& from) :
70 CONSTRAINT1(from), _StructuralConstraintSetStatic_< OTHER_CONSTRAINTS... >(from) {}
71
73 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
74 _StructuralConstraintSetStatic_< CONSTRAINT1,
75 OTHER_CONSTRAINTS... >::~_StructuralConstraintSetStatic_()
76 = default;
77
79 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
80 _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >&
81 _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::operator=(
82 const _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >& from) {
83 if (this != &from) {
84 next_constraints::operator=(from);
85 first_constraint::operator=(from);
86 }
87
88 return *this;
89 }
90
92 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
93 void _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::setGraph(
94 const DiGraph& graph) {
95 next_constraints::setGraph(graph);
96 first_constraint::setGraphAlone(graph);
97 }
98
100 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
101 void _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
102 const ArcAddition& change) {
103 next_constraints::modifyGraph(change);
104 first_constraint::modifyGraphAlone(change);
105 }
106
108 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
109 void _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
110 const ArcDeletion& change) {
111 next_constraints::modifyGraph(change);
112 first_constraint::modifyGraphAlone(change);
113 }
114
116 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
117 void _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
118 const ArcReversal& change) {
119 next_constraints::modifyGraph(change);
120 first_constraint::modifyGraphAlone(change);
121 }
122
124 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
125 void _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
126 const ArcTriangleDeletion1& change) {
127 next_constraints::modifyGraph(change);
128 first_constraint::modifyGraphAlone(change);
129 }
130
132 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
133 void _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
134 const ArcTriangleDeletion2& change) {
135 next_constraints::modifyGraph(change);
136 first_constraint::modifyGraphAlone(change);
137 }
138
140 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
141 void _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
142 const GraphChange& change) {
143 next_constraints::modifyGraph(change);
144 first_constraint::modifyGraphAlone(change);
145 }
146
148 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
149 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::isAlwaysInvalid(
150 const GraphChange& change) const {
151 return next_constraints::isAlwaysInvalid(change)
152 || first_constraint::isAlwaysInvalidAlone(change);
153 }
154
156 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
157 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkArcAddition(
158 NodeId x,
159 NodeId y) const {
160 return next_constraints::checkArcAddition(x, y)
161 && first_constraint::checkArcAdditionAlone(x, y);
162 }
163
165 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
166 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkArcDeletion(
167 NodeId x,
168 NodeId y) const {
169 return next_constraints::checkArcDeletion(x, y)
170 && first_constraint::checkArcDeletionAlone(x, y);
171 }
172
174 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
175 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkArcReversal(
176 NodeId x,
177 NodeId y) const {
178 return next_constraints::checkArcReversal(x, y)
179 && first_constraint::checkArcReversalAlone(x, y);
180 }
181
183 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
184 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::
185 checkArcTriangleDeletion1(NodeId node1, NodeId node2, NodeId node3) const {
186 return next_constraints::checkArcTriangleDeletion1(node1, node2, node3)
187 && first_constraint::checkArcTriangleDeletion1Alone(node1, node2, node3);
188 }
189
191 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
192 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::
193 checkArcTriangleDeletion2(NodeId node1, NodeId node2, NodeId node3) const {
194 return next_constraints::checkArcTriangleDeletion2(node1, node2, node3)
195 && first_constraint::checkArcTriangleDeletion2Alone(node1, node2, node3);
196 }
197
199 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
200 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
201 const ArcAddition& change) const {
202 return next_constraints::checkModification(change)
203 && first_constraint::checkModificationAlone(change);
204 }
205
207 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
208 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
209 const ArcDeletion& change) const {
210 return next_constraints::checkModification(change)
211 && first_constraint::checkModificationAlone(change);
212 }
213
215 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
216 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
217 const ArcReversal& change) const {
218 return next_constraints::checkModification(change)
219 && first_constraint::checkModificationAlone(change);
220 }
221
223 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
224 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
225 const ArcTriangleDeletion1& change) const {
226 return next_constraints::checkModification(change)
227 && first_constraint::checkModificationAlone(change);
228 }
229
231 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
232 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
233 const ArcTriangleDeletion2& change) const {
234 return next_constraints::checkModification(change)
235 && first_constraint::checkModificationAlone(change);
236 }
237
239 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
240 bool _StructuralConstraintSetStatic_< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
241 const GraphChange& change) const {
242 return next_constraints::checkModification(change)
243 && first_constraint::checkModificationAlone(change);
244 }
245
246 // ===========================================================================
247
249 template < typename CONSTRAINT >
250 _StructuralConstraintSetStatic_< CONSTRAINT >::_StructuralConstraintSetStatic_() = default;
251
253 template < typename CONSTRAINT >
254 _StructuralConstraintSetStatic_< CONSTRAINT >::_StructuralConstraintSetStatic_(
255 const _StructuralConstraintSetStatic_< CONSTRAINT >& from) : CONSTRAINT(from) {}
256
258 template < typename CONSTRAINT >
259 _StructuralConstraintSetStatic_< CONSTRAINT >::~_StructuralConstraintSetStatic_() = default;
260
262 template < typename CONSTRAINT >
263 _StructuralConstraintSetStatic_< CONSTRAINT >&
264 _StructuralConstraintSetStatic_< CONSTRAINT >::operator=(
265 const _StructuralConstraintSetStatic_< CONSTRAINT >& from) {
266 if (this != &from) { CONSTRAINT::operator=(from); }
267
268 return *this;
269 }
270
272 template < typename CONSTRAINT >
273 void _StructuralConstraintSetStatic_< CONSTRAINT >::setGraph(const DiGraph& graph) {
274 first_constraint::setGraphAlone(graph);
275 }
276
278 template < typename CONSTRAINT >
279 void _StructuralConstraintSetStatic_< CONSTRAINT >::modifyGraph(const ArcAddition& change) {
280 first_constraint::modifyGraphAlone(change);
281 }
282
284 template < typename CONSTRAINT >
285 void _StructuralConstraintSetStatic_< CONSTRAINT >::modifyGraph(const ArcDeletion& change) {
286 first_constraint::modifyGraphAlone(change);
287 }
288
290 template < typename CONSTRAINT >
291 void _StructuralConstraintSetStatic_< CONSTRAINT >::modifyGraph(const ArcReversal& change) {
292 first_constraint::modifyGraphAlone(change);
293 }
294
296 template < typename CONSTRAINT >
297 void _StructuralConstraintSetStatic_< CONSTRAINT >::modifyGraph(
298 const ArcTriangleDeletion1& change) {
299 first_constraint::modifyGraphAlone(change);
300 }
301
303 template < typename CONSTRAINT >
304 void _StructuralConstraintSetStatic_< CONSTRAINT >::modifyGraph(
305 const ArcTriangleDeletion2& change) {
306 first_constraint::modifyGraphAlone(change);
307 }
308
310 template < typename CONSTRAINT >
311 void _StructuralConstraintSetStatic_< CONSTRAINT >::modifyGraph(const GraphChange& change) {
312 first_constraint::modifyGraphAlone(change);
313 }
314
316 template < typename CONSTRAINT >
317 bool _StructuralConstraintSetStatic_< CONSTRAINT >::isAlwaysInvalid(
318 const GraphChange& change) const {
319 return first_constraint::isAlwaysInvalidAlone(change);
320 }
321
323 template < typename CONSTRAINT >
324 bool _StructuralConstraintSetStatic_< CONSTRAINT >::checkArcAddition(NodeId x, NodeId y) const {
325 return first_constraint::checkArcAdditionAlone(x, y);
326 }
327
329 template < typename CONSTRAINT >
330 bool _StructuralConstraintSetStatic_< CONSTRAINT >::checkArcDeletion(NodeId x, NodeId y) const {
331 return first_constraint::checkArcDeletionAlone(x, y);
332 }
333
335 template < typename CONSTRAINT >
336 bool _StructuralConstraintSetStatic_< CONSTRAINT >::checkArcReversal(NodeId x, NodeId y) const {
337 return first_constraint::checkArcReversalAlone(x, y);
338 }
339
341 template < typename CONSTRAINT >
342 bool _StructuralConstraintSetStatic_< CONSTRAINT >::checkArcTriangleDeletion1(
343 NodeId node1,
344 NodeId node2,
345 NodeId node3) const {
346 return first_constraint::checkArcTriangleDeletion1Alone(node1, node2, node3);
347 }
348
350 template < typename CONSTRAINT >
351 bool _StructuralConstraintSetStatic_< CONSTRAINT >::checkArcTriangleDeletion2(
352 NodeId node1,
353 NodeId node2,
354 NodeId node3) const {
355 return first_constraint::checkArcTriangleDeletion2Alone(node1, node2, node3);
356 }
357
359 template < typename CONSTRAINT >
360 bool _StructuralConstraintSetStatic_< CONSTRAINT >::checkModification(
361 const ArcAddition& change) const {
362 return first_constraint::checkModificationAlone(change);
363 }
364
366 template < typename CONSTRAINT >
367 bool _StructuralConstraintSetStatic_< CONSTRAINT >::checkModification(
368 const ArcDeletion& change) const {
369 return first_constraint::checkModificationAlone(change);
370 }
371
373 template < typename CONSTRAINT >
374 bool _StructuralConstraintSetStatic_< CONSTRAINT >::checkModification(
375 const ArcReversal& change) const {
376 return first_constraint::checkModificationAlone(change);
377 }
378
380 template < typename CONSTRAINT >
381 bool _StructuralConstraintSetStatic_< CONSTRAINT >::checkModification(
382 const ArcTriangleDeletion1& change) const {
383 return first_constraint::checkModificationAlone(change);
384 }
385
387 template < typename CONSTRAINT >
388 bool _StructuralConstraintSetStatic_< CONSTRAINT >::checkModification(
389 const ArcTriangleDeletion2& change) const {
390 return first_constraint::checkModificationAlone(change);
391 }
392
394 template < typename CONSTRAINT >
395 bool _StructuralConstraintSetStatic_< CONSTRAINT >::checkModification(
396 const GraphChange& change) const {
397 return first_constraint::checkModificationAlone(change);
398 }
399
400 // ===========================================================================
401
403 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
404 StructuralConstraintSetStatic< CONSTRAINT1,
405 OTHER_CONSTRAINTS... >::StructuralConstraintSetStatic() {
406 GUM_CONSTRUCTOR(StructuralConstraintSetStatic);
407 }
408
410 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
411 StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
412 StructuralConstraintSetStatic(
413 const StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >& from) :
414 constraints(from) {
415 GUM_CONS_CPY(StructuralConstraintSetStatic);
416 }
417
419 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
420 StructuralConstraintSetStatic< CONSTRAINT1,
421 OTHER_CONSTRAINTS... >::~StructuralConstraintSetStatic() {
422 GUM_DESTRUCTOR(StructuralConstraintSetStatic);
423 }
424
426 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
427 StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >&
428 StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::operator=(
429 const StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >& from) {
430 if (this != &from) { constraints::operator=(from); }
431
432 return *this;
433 }
434
436 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
437 void StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::setGraph(
438 const DiGraph& graph) {
439 constraints::setGraph(graph);
440 }
441
443 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
444 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkArcAddition(
445 NodeId x,
446 NodeId y) const {
447 return constraints::checkArcAddition(x, y);
448 }
449
451 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
452 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkArcDeletion(
453 NodeId x,
454 NodeId y) const {
455 return constraints::checkArcDeletion(x, y);
456 }
457
459 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
460 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkArcReversal(
461 NodeId x,
462 NodeId y) const {
463 return constraints::checkArcReversal(x, y);
464 }
465
467 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
468 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
469 checkArcTriangleDeletion1(NodeId node1, NodeId node2, NodeId node3) const {
470 return constraints::checkArcTriangleDeletion1(node1, node2, node3);
471 }
472
474 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
475 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::
476 checkArcTriangleDeletion2(NodeId node1, NodeId node2, NodeId node3) const {
477 return constraints::checkArcTriangleDeletion2(node1, node2, node3);
478 }
479
481 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
482 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
483 const ArcAddition& change) const {
484 return constraints::checkModification(change);
485 }
486
488 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
489 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
490 const ArcDeletion& change) const {
491 return constraints::checkModification(change);
492 }
493
495 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
496 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
497 const ArcReversal& change) const {
498 return constraints::checkModification(change);
499 }
500
502 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
503 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
504 const ArcTriangleDeletion1& change) const {
505 return constraints::checkModification(change);
506 }
507
509 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
510 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
511 const ArcTriangleDeletion2& change) const {
512 return constraints::checkModification(change);
513 }
514
516 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
517 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::checkModification(
518 const GraphChange& change) const {
519 return constraints::checkModification(change);
520 }
521
523 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
524 void StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
525 const ArcAddition& change) {
526 if (checkModification(change)) {
527 constraints::modifyGraph(change);
528 } else {
530 "the constraint set does not allow an arc addition between "
531 << change.node1() << " and " << change.node2());
532 }
533 }
534
536 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
537 void StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
538 const ArcDeletion& change) {
539 if (checkModification(change)) {
540 constraints::modifyGraph(change);
541 } else {
543 "the constraint set does not allow an arc deletion between "
544 << change.node1() << " and " << change.node2());
545 }
546 }
547
549 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
550 void StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
551 const ArcReversal& change) {
552 if (checkModification(change)) {
553 constraints::modifyGraph(change);
554 } else {
556 "the constraint set does not allow an arc reversal between "
557 << change.node1() << " and " << change.node2());
558 }
559 }
560
562 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
563 void StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
564 const ArcTriangleDeletion1& change) {
565 if (checkModification(change)) {
566 constraints::modifyGraph(change);
567 } else {
569 "the constraint set does not allow the deletion of arc triangle1 "
570 << change.node1() << " -> " << change.node2() << " -> " << change.node3());
571 }
572 }
573
575 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
576 void StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
577 const ArcTriangleDeletion2& change) {
578 if (checkModification(change)) {
579 constraints::modifyGraph(change);
580 } else {
582 "the constraint set does not allow the deletion of arc triangle2 "
583 << change.node1() << " -> " << change.node2() << " -> " << change.node3());
584 }
585 }
586
588 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
589 void StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::modifyGraph(
590 const GraphChange& change) {
591 switch (change.type()) {
592 case GraphChangeType::ARC_ADDITION :
593 modifyGraph(reinterpret_cast< const ArcAddition& >(change));
594 break;
595
596 case GraphChangeType::ARC_DELETION :
597 modifyGraph(reinterpret_cast< const ArcDeletion& >(change));
598 break;
599
600 case GraphChangeType::ARC_REVERSAL :
601 modifyGraph(reinterpret_cast< const ArcReversal& >(change));
602 break;
603
604 case GraphChangeType::ARC_TRIANGLE_DELETION1 :
605 modifyGraph(reinterpret_cast< const ArcTriangleDeletion1& >(change));
606 break;
607
608 case GraphChangeType::ARC_TRIANGLE_DELETION2 :
609 modifyGraph(reinterpret_cast< const ArcTriangleDeletion2& >(change));
610 break;
611
612 default :
614 "Graph change operation " << change.typeAsString()
615 << " is not currently supported by constraint sets");
616 }
617 }
618
620 template < typename CONSTRAINT1, typename... OTHER_CONSTRAINTS >
621 bool StructuralConstraintSetStatic< CONSTRAINT1, OTHER_CONSTRAINTS... >::isAlwaysInvalid(
622 const GraphChange& change) const {
623 return constraints::isAlwaysInvalid(change);
624 }
625
626 // ===========================================================================
627
629 template < typename CONSTRAINT >
630 StructuralConstraintSetStatic< CONSTRAINT >::StructuralConstraintSetStatic() {
631 GUM_CONSTRUCTOR(StructuralConstraintSetStatic);
632 }
633
635 template < typename CONSTRAINT >
636 StructuralConstraintSetStatic< CONSTRAINT >::StructuralConstraintSetStatic(
637 const StructuralConstraintSetStatic< CONSTRAINT >& from) : constraints(from) {
638 GUM_CONS_CPY(StructuralConstraintSetStatic);
639 }
640
642 template < typename CONSTRAINT >
643 StructuralConstraintSetStatic< CONSTRAINT >::~StructuralConstraintSetStatic() {
644 GUM_DESTRUCTOR(StructuralConstraintSetStatic);
645 }
646
648 template < typename CONSTRAINT >
649 StructuralConstraintSetStatic< CONSTRAINT >&
650 StructuralConstraintSetStatic< CONSTRAINT >::operator=(
651 const StructuralConstraintSetStatic< CONSTRAINT >& from) {
652 if (this != &from) { constraints::operator=(from); }
653
654 return *this;
655 }
656
658 template < typename CONSTRAINT >
659 void StructuralConstraintSetStatic< CONSTRAINT >::setGraph(const DiGraph& graph) {
660 constraints::setGraph(graph);
661 }
662
664 template < typename CONSTRAINT >
665 bool StructuralConstraintSetStatic< CONSTRAINT >::checkArcAddition(NodeId x, NodeId y) const {
666 return constraints::checkArcAddition(x, y);
667 }
668
670 template < typename CONSTRAINT >
671 bool StructuralConstraintSetStatic< CONSTRAINT >::checkArcDeletion(NodeId x, NodeId y) const {
672 return constraints::checkArcDeletion(x, y);
673 }
674
676 template < typename CONSTRAINT >
677 bool StructuralConstraintSetStatic< CONSTRAINT >::checkArcReversal(NodeId x, NodeId y) const {
678 return constraints::checkArcReversal(x, y);
679 }
680
682 template < typename CONSTRAINT >
683 bool
684 StructuralConstraintSetStatic< CONSTRAINT >::checkArcTriangleDeletion1(NodeId node1,
685 NodeId node2,
686 NodeId node3) const {
687 return constraints::checkArcTriangleDeletion1(node1, node2, node3);
688 }
689
691 template < typename CONSTRAINT >
692 bool
693 StructuralConstraintSetStatic< CONSTRAINT >::checkArcTriangleDeletion2(NodeId node1,
694 NodeId node2,
695 NodeId node3) const {
696 return constraints::checkArcTriangleDeletion2(node1, node2, node3);
697 }
698
700 template < typename CONSTRAINT >
701 bool StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
702 const ArcAddition& change) const {
703 return constraints::checkModification(change);
704 }
705
707 template < typename CONSTRAINT >
708 bool StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
709 const ArcDeletion& change) const {
710 return constraints::checkModification(change);
711 }
712
714 template < typename CONSTRAINT >
715 bool StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
716 const ArcReversal& change) const {
717 return constraints::checkModification(change);
718 }
719
721 template < typename CONSTRAINT >
722 bool StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
723 const ArcTriangleDeletion1& change) const {
724 return constraints::checkModification(change);
725 }
726
728 template < typename CONSTRAINT >
729 bool StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
730 const ArcTriangleDeletion2& change) const {
731 return constraints::checkModification(change);
732 }
733
735 template < typename CONSTRAINT >
736 bool StructuralConstraintSetStatic< CONSTRAINT >::checkModification(
737 const GraphChange& change) const {
738 return constraints::checkModification(change);
739 }
740
742 template < typename CONSTRAINT >
743 void StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(const ArcAddition& change) {
744 if (checkModification(change)) {
745 constraints::modifyGraph(change);
746 } else {
748 "the constraint set does not allow this arc addition between "
749 << change.node1() << " and " << change.node2());
750 }
751 }
752
754 template < typename CONSTRAINT >
755 void StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(const ArcDeletion& change) {
756 if (checkModification(change)) {
757 constraints::modifyGraph(change);
758 } else {
760 "the constraint set does not allow this arc deletion between "
761 << change.node1() << " and " << change.node2());
762 }
763 }
764
766 template < typename CONSTRAINT >
767 void StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(const ArcReversal& change) {
768 if (checkModification(change)) {
769 constraints::modifyGraph(change);
770 } else {
772 "the constraint set does not allow this arc reversal between "
773 << change.node1() << " and " << change.node2());
774 }
775 }
776
778 template < typename CONSTRAINT >
779 void StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(
780 const ArcTriangleDeletion1& change) {
781 if (checkModification(change)) {
782 constraints::modifyGraph(change);
783 } else {
785 "the constraint set does not allow the deletion of arc triangle1 "
786 << change.node1() << " -> " << change.node2() << " -> " << change.node3());
787 }
788 }
789
791 template < typename CONSTRAINT >
792 void StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(
793 const ArcTriangleDeletion2& change) {
794 if (checkModification(change)) {
795 constraints::modifyGraph(change);
796 } else {
798 "the constraint set does not allow the deletion of arc triangle2 "
799 << change.node1() << " -> " << change.node2() << " -> " << change.node3());
800 }
801 }
802
804 template < typename CONSTRAINT >
805 void StructuralConstraintSetStatic< CONSTRAINT >::modifyGraph(const GraphChange& change) {
806 switch (change.type()) {
807 case GraphChangeType::ARC_ADDITION :
808 modifyGraph(reinterpret_cast< const ArcAddition& >(change));
809 break;
810
811 case GraphChangeType::ARC_DELETION :
812 modifyGraph(reinterpret_cast< const ArcDeletion& >(change));
813 break;
814
815 case GraphChangeType::ARC_REVERSAL :
816 modifyGraph(reinterpret_cast< const ArcReversal& >(change));
817 break;
818
819 case GraphChangeType::ARC_TRIANGLE_DELETION1 :
820 modifyGraph(reinterpret_cast< const ArcTriangleDeletion1& >(change));
821 break;
822
823 case GraphChangeType::ARC_TRIANGLE_DELETION2 :
824 modifyGraph(reinterpret_cast< const ArcTriangleDeletion2& >(change));
825 break;
826
827 default :
829 "Graph change operation " << change.typeAsString()
830 << " is not currently supported by constraint sets");
831 }
832 }
833
835 template < typename CONSTRAINT >
836 bool StructuralConstraintSetStatic< CONSTRAINT >::isAlwaysInvalid(
837 const GraphChange& change) const {
838 return constraints::isAlwaysInvalid(change);
839 }
840
841 } /* namespace learning */
842
843} /* namespace gum */
844
845#endif /* DOXYGEN_SHOULD_SKIP_THIS */
Exception : operation not allowed.
#define GUM_ERROR(type, msg)
Definition exceptions.h:76
include the inlined functions if necessary
Definition CSVParser.h:55
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
the "meta-programming" class for storing several structural constraints