aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
setInst_inl.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
44#include <agrum/base/multidim/setInst.h> // to ease IDE parser
45#ifndef DOXYGEN_SHOULD_SKIP_THIS
46
48
49// to ease IDE PARSER
51
52namespace gum {
53
54 // indicates whether a given variable belongs to the SetInst
55
56 INLINE bool SetInst::contains(const DiscreteVariable& v) const { return _vars_.exists(&v); }
57
58 // indicates whether a given variable belongs to the SetInst
59
60 INLINE bool SetInst::contains(const DiscreteVariable* v) const { return _vars_.exists(v); }
61
62 // modifies internally the value of a given variable of the sequence
63
64 INLINE void SetInst::_chgVal_(Idx varPos, Idx newVal) {
65 // Size oldVal = _vals_[varPos];
66 _vals_[varPos] = Idx(1) << newVal;
67
68 // if ( _master_ )
69 // _master_->changeNotification( *this, _vars_[varPos], oldVal, newVal
70 // );
71 }
72
73 // modifies the value of a given variable of the sequence (external function)
74
75 INLINE SetInst& SetInst::chgVal(const DiscreteVariable& v, Idx newVal) {
76 auto pPos = _vars_.tryPos(&v);
77 if (!pPos) {
78 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v.name())
79 }
80 Idx varPos = *pPos;
81
82 if (newVal >= v.domainSize()) GUM_ERROR(OutOfBounds, "")
83
84 // if we were in overflow, indicate that we are not anymore
85 _overflow_ = false;
86
87 _chgVal_(varPos, newVal);
88
89 return *this;
90 }
91
92 INLINE SetInst& SetInst::chgVal(const DiscreteVariable* v, Idx newVal) {
93 auto pPos = _vars_.tryPos(v);
94 if (!pPos) {
95 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v->name())
96 }
97 Idx varPos = *pPos;
98
99 if (newVal >= v->domainSize()) GUM_ERROR(OutOfBounds, "")
100
101 // if we were in overflow, indicate that we are not anymore
102 _overflow_ = false;
103
104 _chgVal_(varPos, newVal);
105
106 return *this;
107 }
108
109 // modifies the value of a given variable of the sequence (external function)
110
111 INLINE SetInst& SetInst::chgVal(Idx varPos, Idx newVal) {
112 // check that the variable does belong to the SetInst and that the new
113 // value is possible.
114 if (_vals_.size() <= varPos) GUM_ERROR(NotFound, "")
115
116 if (newVal >= _vars_[varPos]->domainSize()) GUM_ERROR(OutOfBounds, "")
117
118 // if we were in overflow, indicate that we are not anymore
119 _overflow_ = false;
120
121 _chgVal_(varPos, newVal);
122
123 return *this;
124 }
125
126 // modifies internally the value of a given variable of the sequence
127
128 INLINE void SetInst::_chgVals_(Idx varPos, const Size newVals) {
129 // Size oldVal = _vals_[varPos];
130 _vals_[varPos] = 0;
131 _vals_[varPos] = newVals;
132
133 // if ( _master_ )
134 // _master_->changeNotification( *this, _vars_[varPos], oldVal, newVals
135 // );
136 }
137
138 // modifies the value of a given variable of the sequence (external function)
139
140 INLINE SetInst& SetInst::chgVals(const DiscreteVariable& v, const Size newVals) {
141 auto pPos = _vars_.tryPos(&v);
142 if (!pPos) {
143 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v.name())
144 }
145 Idx varPos = *pPos;
146
147 if (newVals >= (Size)1 << v.domainSize()) GUM_ERROR(OutOfBounds, "")
148
149 // if we were in overflow, indicate that we are not anymore
150 _overflow_ = false;
151
152 _chgVals_(varPos, newVals);
153
154 return *this;
155 }
156
157 INLINE SetInst& SetInst::chgVals(const DiscreteVariable* v, const Size newVals) {
158 auto pPos = _vars_.tryPos(v);
159 if (!pPos) {
160 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v->name())
161 }
162 Idx varPos = *pPos;
163
164 if (newVals >= (Size)1 << v->domainSize()) GUM_ERROR(OutOfBounds, "")
165
166 // if we were in overflow, indicate that we are not anymore
167 _overflow_ = false;
168
169 _chgVals_(varPos, newVals);
170
171 return *this;
172 }
173
174 // modifies the value of a given variable of the sequence (external function)
175
176 INLINE SetInst& SetInst::chgVals(Idx varPos, const Size newVal) {
177 // check that the variable does belong to the SetInst and that the new
178 // value is possible.
179 if (_vals_.size() <= varPos) GUM_ERROR(NotFound, "")
180
181 if (newVal >= (Size)1 << _vars_[varPos]->domainSize()) GUM_ERROR(OutOfBounds, "")
182
183 // if we were in overflow, indicate that we are not anymore
184 _overflow_ = false;
185
186 _chgVals_(varPos, newVal);
187
188 return *this;
189 }
190
191 INLINE SetInst& SetInst::addVal(Idx varPos, Idx newVal) {
192 if (_vals_.size() <= varPos) GUM_ERROR(NotFound, "")
193
194 if (newVal >= _vars_[varPos]->domainSize()) GUM_ERROR(OutOfBounds, "")
195
196 _chgVals_(varPos, (Idx(1) << newVal) | _vals_[varPos]);
197 return *this;
198 }
199
200 INLINE SetInst& SetInst::addVal(const DiscreteVariable* v, Idx newVal) {
201 auto pPos = _vars_.tryPos(v);
202 if (!pPos) {
203 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v->name())
204 }
205 Idx varPos = *pPos;
206
207 if (newVal >= v->domainSize()) GUM_ERROR(OutOfBounds, "")
208
209 // if we were in overflow, indicate that we are not anymore
210 _overflow_ = false;
211
212 addVal(varPos, newVal);
213
214 return *this;
215 }
216
217 INLINE SetInst& SetInst::addVal(const DiscreteVariable& v, Idx newVal) {
218 auto pPos = _vars_.tryPos(&v);
219 if (!pPos) {
220 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v.name())
221 }
222 Idx varPos = *pPos;
223
224 if (newVal >= v.domainSize()) GUM_ERROR(OutOfBounds, "")
225
226 // if we were in overflow, indicate that we are not anymore
227 _overflow_ = false;
228
229 addVal(varPos, newVal);
230
231 return *this;
232 }
233
234 INLINE SetInst& SetInst::addVals(Idx varPos, const Size newVal) {
235 if (_vals_.size() <= varPos) GUM_ERROR(NotFound, "")
236
237 if (newVal >= (Size(1) << _vars_[varPos]->domainSize())) GUM_ERROR(OutOfBounds, "")
238
239 _chgVals_(varPos, newVal | _vals_[varPos]);
240 return *this;
241 }
242
243 INLINE SetInst& SetInst::addVals(const DiscreteVariable* v, const Size newVal) {
244 auto pPos = _vars_.tryPos(v);
245 if (!pPos) {
246 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v->name())
247 }
248 Idx varPos = *pPos;
249
250 if (newVal >= (Size(1) << _vars_[varPos]->domainSize())) GUM_ERROR(OutOfBounds, "")
251
252 addVals(varPos, newVal);
253
254 return *this;
255 }
256
257 INLINE SetInst& SetInst::addVals(const DiscreteVariable& v, const Size newVal) {
258 auto pPos = _vars_.tryPos(&v);
259 if (!pPos) {
260 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v.name())
261 }
262 Idx varPos = *pPos;
263
264 if (newVal >= (Size(1) << _vars_[varPos]->domainSize())) GUM_ERROR(OutOfBounds, "")
265
266 // if we were in overflow, indicate that we are not anymore
267 _overflow_ = false;
268
269 addVals(varPos, newVal);
270
271 return *this;
272 }
273
274 INLINE SetInst& SetInst::remVal(Idx varPos, Idx newVal) {
275 if (_vals_.size() <= varPos) GUM_ERROR(NotFound, "")
276
277 if (newVal >= _vars_[varPos]->domainSize()) GUM_ERROR(OutOfBounds, "")
278
279 _chgVals_(varPos, ~(1 << newVal) & _vals_[varPos]);
280 return *this;
281 }
282
283 INLINE SetInst& SetInst::remVal(const DiscreteVariable* v, Idx newVal) {
284 auto pPos = _vars_.tryPos(v);
285 if (!pPos) {
286 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v->name())
287 }
288 Idx varPos = *pPos;
289
290 if (newVal >= v->domainSize()) GUM_ERROR(OutOfBounds, "")
291
292 remVal(varPos, newVal);
293
294 return *this;
295 }
296
297 INLINE SetInst& SetInst::remVal(const DiscreteVariable& v, Idx newVal) {
298 auto pPos = _vars_.tryPos(&v);
299 if (!pPos) {
300 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v.name())
301 }
302 Idx varPos = *pPos;
303
304 if (newVal >= v.domainSize()) GUM_ERROR(OutOfBounds, "")
305
306 // if we were in overflow, indicate that we are not anymore
307 _overflow_ = false;
308
309 remVal(varPos, newVal);
310
311 return *this;
312 }
313
314 INLINE SetInst& SetInst::remVals(Idx varPos, const Size newVal) {
315 if (_vals_.size() <= varPos) GUM_ERROR(NotFound, "")
316
317 if (newVal >= (Size(1) << _vars_[varPos]->domainSize())) GUM_ERROR(OutOfBounds, "")
318
319 _chgVals_(varPos, ~newVal & _vals_[varPos]);
320 return *this;
321 }
322
323 INLINE SetInst& SetInst::remVals(const DiscreteVariable* v, const Size newVal) {
324 auto pPos = _vars_.tryPos(v);
325 if (!pPos) {
326 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v->name())
327 }
328 Idx varPos = *pPos;
329
330 if (newVal >= (Size(1) << _vars_[varPos]->domainSize())) GUM_ERROR(OutOfBounds, "")
331
332 remVals(varPos, newVal);
333
334 return *this;
335 }
336
337 INLINE SetInst& SetInst::remVals(const DiscreteVariable& v, const Size newVal) {
338 auto pPos = _vars_.tryPos(&v);
339 if (!pPos) {
340 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v.name())
341 }
342 Idx varPos = *pPos;
343
344 if (newVal >= (Size(1) << _vars_[varPos]->domainSize())) GUM_ERROR(OutOfBounds, "")
345
346 // if we were in overflow, indicate that we are not anymore
347 _overflow_ = false;
348
349 remVals(varPos, newVal);
350
351 return *this;
352 }
353
354 INLINE SetInst& SetInst::chgDifVal(Idx varPos, const Size newVal) {
355 if (_vals_.size() <= varPos) GUM_ERROR(NotFound, "")
356
357 if (newVal >= _vars_[varPos]->domainSize()) GUM_ERROR(OutOfBounds, "")
358
359 _chgVals_(varPos, newVal ^ _vals_[varPos]);
360 return *this;
361 }
362
363 INLINE SetInst& SetInst::interVals(Idx varPos, const Size newVal) {
364 if (_vals_.size() <= varPos) GUM_ERROR(NotFound, "")
365
366 if (newVal >= (Size(1) << _vars_[varPos]->domainSize())) GUM_ERROR(OutOfBounds, "")
367
368 _chgVals_(varPos, newVal & _vals_[varPos]);
369 return *this;
370 }
371
372 INLINE SetInst& SetInst::interVals(const DiscreteVariable* v, const Size newVal) {
373 auto pPos = _vars_.tryPos(v);
374 if (!pPos) {
375 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v->name())
376 }
377 Idx varPos = *pPos;
378
379 if (newVal >= (Size(1) << _vars_[varPos]->domainSize())) GUM_ERROR(OutOfBounds, "")
380
381 interVals(varPos, newVal);
382
383 return *this;
384 }
385
386 INLINE SetInst& SetInst::interVals(const DiscreteVariable& v, const Size newVal) {
387 auto pPos = _vars_.tryPos(&v);
388 if (!pPos) {
389 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v.name())
390 }
391 Idx varPos = *pPos;
392
393 if (newVal >= (Size(1) << _vars_[varPos]->domainSize())) GUM_ERROR(OutOfBounds, "")
394
395 // if we were in overflow, indicate that we are not anymore
396 _overflow_ = false;
397
398 interVals(varPos, newVal);
399
400 return *this;
401 }
402
403 INLINE SetInst& SetInst::interVal(Idx varPos, Idx newVal) {
404 if (_vals_.size() <= varPos) GUM_ERROR(NotFound, "")
405
406 if (newVal >= _vars_[varPos]->domainSize()) GUM_ERROR(OutOfBounds, "")
407
408 _chgVals_(varPos, (Size(1) << newVal) & _vals_[varPos]);
409 return *this;
410 }
411
412 INLINE SetInst& SetInst::interVal(const DiscreteVariable* v, Idx newVal) {
413 auto pPos = _vars_.tryPos(v);
414 if (!pPos) {
415 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v->name())
416 }
417 Idx varPos = *pPos;
418
419 if (newVal >= v->domainSize()) GUM_ERROR(OutOfBounds, "")
420
421 interVal(varPos, newVal);
422
423 return *this;
424 }
425
426 INLINE SetInst& SetInst::interVal(const DiscreteVariable& v, Idx newVal) {
427 auto pPos = _vars_.tryPos(&v);
428 if (!pPos) {
429 GUM_ERROR(NotFound, "SetInst does not contain this DiscreteVariable: " + v.name())
430 }
431 Idx varPos = *pPos;
432
433 if (newVal >= v.domainSize()) GUM_ERROR(OutOfBounds, "")
434
435 // if we were in overflow, indicate that we are not anymore
436 _overflow_ = false;
437
438 interVal(varPos, newVal);
439
440 return *this;
441 }
442
443 // adds a new var to the sequence of vars
444
445 INLINE void SetInst::add(const DiscreteVariable& v) {
446 // if _master_ : not allowed
447 // if ( _master_ ) GUM_ERROR( OperationNotAllowed, "in slave SetInst" )
448
449 // check if the variable already belongs to the tuple of variables
450 // of the SetInst
451 if (_vars_.exists(&v))
452 GUM_ERROR(DuplicateElement, "Variable '" << v.name() << "' already exists in this SetInst")
453
454 // actually add the new dimension
455 _add_(v);
456 }
457
458 // removes a variable from the sequence of vars
459
460 INLINE void SetInst::erase(const DiscreteVariable& v) {
461 // if _master_ : not allowed
462 // if ( _master_ ) GUM_ERROR( OperationNotAllowed, "in slave SetInst" )
463
464 // check that the variable does actually belong to the SetInst
465 if (!_vars_.exists(&v)) GUM_ERROR(NotFound, "Var does not exist in this SetInst")
466
467 // actually delete the dimension
468 _erase_(v);
469 }
470
471 // removes everything
472 INLINE void SetInst::clear() {
473 // if ( _master_ ) GUM_ERROR( OperationNotAllowed, "in slave SetInst" )
474
475 _vars_.clear();
476 _vals_.clear();
477 }
478
481
482 INLINE Size SetInst::domainSize() const {
483 Size s = 1;
484
485 for (const auto var: _vars_)
486 s *= var->domainSize();
487
488 return s;
489 }
490
491 // returns the index of a var
492
493 INLINE Idx SetInst::pos(const DiscreteVariable& k) const { return _vars_.pos(&k); }
494
495 // Default constructor
496
497 INLINE SetInst::SetInst() : /* _master_( 0 ),*/ _overflow_(false) { GUM_CONSTRUCTOR(SetInst); }
498
499 // destructor
500
501 INLINE SetInst::~SetInst() {
502 GUM_DESTRUCTOR(SetInst);
503 // unregister the SetInst from its _master_
504
505 // if ( _master_ ) _master_->unregisterSlave( *this );
506 }
507
508 // returns the number of vars in the sequence
509
510 INLINE Idx SetInst::nbrDim() const { return _vars_.size(); }
511
512 // returns the current value of a given variable
513
514 INLINE Size SetInst::vals(Idx i) const {
515 if (i >= _vals_.size()) GUM_ERROR(NotFound, "")
516
517 return _vals_[i];
518 }
519
520 INLINE Size SetInst::vals(const DiscreteVariable& var) const { return _vals_[_vars_.pos(&var)]; }
521
522 INLINE Size SetInst::vals(const DiscreteVariable* var) const { return _vals_[_vars_.pos(var)]; }
523
524 INLINE Idx SetInst::nbrOccurences(const DiscreteVariable& var) const {
525 Idx n = 0;
526 Size val = _vals_[_vars_.pos(&var)];
527
528 while (val) {
529 n += (val & 1);
530 val >>= 1;
531 }
532
533 return n;
534 }
535
536 INLINE Idx SetInst::val(const DiscreteVariable& var) const {
537 Idx n = 0;
538 Size value = _vals_[_vars_.pos(&var)];
539
540 if (nbrOccurences(var) == 1) {
541 while (value > 1) {
542 n++;
543 value >>= 1;
544 }
545
546 return n;
547 } else GUM_ERROR(NotFound, "There is more than one value ")
548 }
549
550 INLINE Idx SetInst::val(const DiscreteVariable* var) const {
551 if (var != nullptr) { return val(*var); }
552 GUM_ERROR(ArgumentError, "Call 'val' on nullptr")
553 }
554
555 // returns the variable at position i in the tuple
556
557 INLINE const DiscreteVariable& SetInst::variable(Idx i) const { return *(_vars_.atPos(i)); }
558
559 // indicates whether the current value of the tuple is correct or not
560
561 INLINE bool SetInst::inOverflow() const { return _overflow_; }
562
563 // end() just is a synonym for inOverflow()
564
565 INLINE bool SetInst::end() const { return inOverflow(); }
566
567 // rend() just is a synonym for inOverflow()
568
569 INLINE bool SetInst::rend() const { return inOverflow(); }
570
571 // indicates that the current value is correct even if it should be in
572 // overflow
573
574 INLINE void SetInst::unsetOverflow() { _overflow_ = false; }
575
576 // alias for unsetOverflow
577
578 INLINE void SetInst::unsetEnd() { _overflow_ = false; }
579
580 // reorder vars in *this
581 INLINE void SetInst::reorder(const SetInst& i) { reorder(i.variablesSequence()); }
582
583 // change values with those in i
584
585 INLINE SetInst& SetInst::chgValIn(const SetInst& i) {
586 _overflow_ = false;
587 Idx s = i.nbrDim();
588
589 for (Size p = 0; p < s; ++p)
590 if (contains(i.variable(p)))
591 // __vals[pos( i.variable( p ) )] = i.val( p );
592 _chgVals_(pos(i.variable(p)), i.vals(i.variable(p)));
593
594 return *this;
595 }
596
597 // returns the sequence of DiscreteVariable
598
599 INLINE const Sequence< const DiscreteVariable* >& SetInst::variablesSequence() const {
600 return _vars_;
601 }
602
603 // replace 2 vars in the SetInst
604
605 INLINE void SetInst::_swap_(Idx i, Idx j) {
606 if (i == j) return;
607
608 _vars_.swap(i, j);
609
610 Size v;
611
612 v = _vals_[i];
613
614 _vals_[i] = _vals_[j];
615
616 _vals_[j] = v;
617 }
618
619 // reordering
620
621 INLINE void SetInst::reorder(const Sequence< const DiscreteVariable* >& original) {
622 Idx max = original.size();
623 Idx position = 0;
624
625 for (Idx i = 0; i < max; ++i) {
626 const DiscreteVariable* pv = original.atPos(i);
627
628 if (contains(pv)) {
629 GUM_ASSERT(pos(*pv) >= position); // this var should not be
630 // already placed.
631 _swap_(position, pos(*pv));
632 position++;
633 }
634 }
635 }
636
637 // adds a new var to the sequence of vars
638
639 INLINE void SetInst::_add_(const DiscreteVariable& v) {
640 _vars_.insert(&v);
641 _vals_.push_back(1);
642 _overflow_ = false;
643 }
644
645 // removes a variable from the sequence of vars
646
647 INLINE void SetInst::_erase_(const DiscreteVariable& v) {
648 // get the position of the variable
649 Idx pos = _vars_.pos(&v);
650 _vars_.erase(&v);
651 _vals_.erase(_vals_.begin() + pos);
652 }
653
654 // is this empty ?
655 INLINE bool SetInst::empty() const { return _vals_.empty(); }
656
657 // Replace x by y.
658 INLINE void SetInst::replace_(const DiscreteVariable* x, const DiscreteVariable* y) {
659 _vars_.setAtPos(_vars_.pos(x), y);
660 }
661} /* namespace gum */
662
663#endif // DOXYGEN_SHOULD_SKIP_THIS
Exception base for argument error.
Base class for discrete random variable.
Exception : the element we looked for cannot be found.
Class for assigning/browsing values to tuples of discrete variables.
Definition setInst.h:101
SetInst()
Default constructor: creates an empty tuple.
void _chgVal_(Idx varPos, Idx newVal)
Change the value of a variable.
Idx pos(const DiscreteVariable &v) const
Returns the position of the variable v.
void erase(const DiscreteVariable &v)
Removes a variable from the SetInst.
Sequence< const DiscreteVariable * > _vars_
The tuple of variables to be instantiated.
Definition setInst.h:873
void _chgVals_(Idx varPos, const Size newVal)
Change the value of a variable.
SetInst & interVals(const DiscreteVariable &v, const Size newVal)
Does an intersection (binary and) between the old value and new value.
bool contains(const DiscreteVariable &v) const
Indicates whether a given variable belongs to the SetInst.
void _erase_(const DiscreteVariable &v)
Removes a variable from the sequence of vars.
SetInst & chgDifVal(Idx varPos, const Size newVal)
Does the difference (binary or) between the old value and new value.
SetInst & addVal(const DiscreteVariable &v, Idx newVal)
Add newVal to variable v in the SetInst.
void _add_(const DiscreteVariable &v)
Adds a new var to the sequence of vars.
bool _overflow_
The overflow flag.
Definition setInst.h:879
SetInst & remVals(const DiscreteVariable &v, const Size newVal)
Remove newVal from the variable v in the SetInst.
Size domainSize() const
Returns the product of the variable's domain size in the SetInst.
SetInst & interVal(const DiscreteVariable &v, Idx newVal)
Does an intersection (binary and) between the old value and new value.
SetInst & remVal(const DiscreteVariable &v, Idx newVal)
Remove newVal from the variable v in the SetInst.
void add(const DiscreteVariable &v)
Adds a new variable in the SetInst.
std::vector< Size > _vals_
The current SetInst: the value of the tuple.
Definition setInst.h:876
SetInst & chgVal(const DiscreteVariable &v, Idx newVal)
Assign newVal to variable v in the SetInst.
void clear()
Erase all variables from an SetInst.
SetInst & chgVals(const DiscreteVariable &v, const Size newVal)
Assign newVal to variable v in the SetInst.
SetInst & addVals(const DiscreteVariable &v, const Size newVal)
Add newVal to variable v in the SetInst.
#define GUM_ERROR(type, msg)
Definition exceptions.h:76
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size Idx
Type for indexes.
Definition types.h:79
bool contains(std::string_view s, std::string_view needle)
true if needle in s
Headers for the abstract base class for all multi dimensionnal containers.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Headers of SetInst.