23 #ifndef DOXYGEN_SHOULD_SKIP_THIS 63 if (newVal >= v.domainSize())
GUM_ERROR(OutOfBounds,
"");
72 std::string name =
"SetInst does not contain this DiscreteVariable: ";
83 if (newVal >= v->domainSize())
GUM_ERROR(OutOfBounds,
"");
92 std::string name =
"SetInst does not contain this DiscreteVariable: ";
134 if (newVals >= (
Size)1 << v.domainSize())
GUM_ERROR(OutOfBounds,
"");
142 }
catch (NotFound&) {
143 std::string name =
"SetInst does not contain this DiscreteVariable: ";
154 if (newVals >= (
Size)1 << v->domainSize())
GUM_ERROR(OutOfBounds,
"");
162 }
catch (NotFound&) {
163 std::string name =
"SetInst does not contain this DiscreteVariable: ";
175 if (newVal >= (
Size)1 <<
__vars[varPos]->domainSize())
202 if (newVal >= v->domainSize())
GUM_ERROR(OutOfBounds,
"");
210 }
catch (NotFound&) {
211 std::string name =
"SetInst does not contain this DiscreteVariable: ";
222 if (newVal >= v.domainSize())
GUM_ERROR(OutOfBounds,
"");
230 }
catch (NotFound&) {
231 std::string name =
"SetInst does not contain this DiscreteVariable: ";
261 }
catch (NotFound&) {
262 std::string name =
"SetInst does not contain this DiscreteVariable: ";
283 }
catch (NotFound&) {
284 std::string name =
"SetInst does not contain this DiscreteVariable: ";
304 if (newVal >= v->domainSize())
GUM_ERROR(OutOfBounds,
"");
311 }
catch (NotFound&) {
312 std::string name =
"SetInst does not contain this DiscreteVariable: ";
323 if (newVal >= v.domainSize())
GUM_ERROR(OutOfBounds,
"");
331 }
catch (NotFound&) {
332 std::string name =
"SetInst does not contain this DiscreteVariable: ";
362 }
catch (NotFound&) {
363 std::string name =
"SetInst does not contain this DiscreteVariable: ";
384 }
catch (NotFound&) {
385 std::string name =
"SetInst does not contain this DiscreteVariable: ";
425 }
catch (NotFound&) {
426 std::string name =
"SetInst does not contain this DiscreteVariable: ";
448 }
catch (NotFound&) {
449 std::string name =
"SetInst does not contain this DiscreteVariable: ";
469 if (newVal >= v->domainSize())
GUM_ERROR(OutOfBounds,
"");
476 }
catch (NotFound&) {
477 std::string name =
"SetInst does not contain this DiscreteVariable: ";
488 if (newVal >= v.domainSize())
GUM_ERROR(OutOfBounds,
"");
496 }
catch (NotFound&) {
497 std::string name =
"SetInst does not contain this DiscreteVariable: ";
512 "Variable '" << v.name() <<
"' already exists in this SetInst");
526 GUM_ERROR(NotFound,
"Var does not exist in this SetInst");
547 for (
const auto var :
__vars)
548 s *= var->domainSize();
556 return __vars.pos(&k);
590 return __vals[__vars.pos(&var)];
596 return __vals[__vars.pos(var)];
603 if (
__vals[__vars.pos(var)] % 2 == 0) {
611 GUM_ERROR(NotFound,
"There is more than one value ");
638 GUM_ERROR(NotFound,
"There is more than one value ");
644 return *(__vars.atPos(i));
670 reorder(i.variablesSequence());
679 for (
Size p = 0; p < s; ++p)
689 INLINE
const Sequence< const DiscreteVariable* >&
714 Idx max = original.size();
717 for (
Idx i = 0; i < max; ++i) {
718 const DiscreteVariable* pv = original.atPos(i);
721 GUM_ASSERT(
pos(*pv) >= position);
751 const DiscreteVariable* y) {
752 __vars.setAtPos(__vars.pos(x), y);
756 #endif // DOXYGEN_SHOULD_SKIP_THIS const DiscreteVariable & variable(Idx i) const
Returns the variable at position i in the tuple.
void __chgVal(Idx varPos, Idx newVal)
Change the value of a variable.
Idx nbrDim() const
Returns the number of variables in the SetInst.
void clear()
Erase all variables from an SetInst.
void __erase(const DiscreteVariable &v)
Removes a variable from the sequence of vars.
Size domainSize() const
Returns the product of the variable's domain size in the SetInst.
virtual bool empty() const
Returns true if the SetInst is empty.
SetInst & chgVal(const DiscreteVariable &v, Idx newVal)
Assign newVal to variable v in the SetInst.
void add(const DiscreteVariable &v)
Adds a new variable in the SetInst.
SetInst & remVal(const DiscreteVariable &v, Idx newVal)
Remove newVal from the variable v in the SetInst.
bool end() const
Returns true if the SetInst reached the end.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool rend() const
Returns true if the SetInst reached the rend.
bool contains(const DiscreteVariable &v) const
Indicates whether a given variable belongs to the SetInst.
const Sequence< const DiscreteVariable *> & variablesSequence() const
Returns the sequence of DiscreteVariable of this SetInst.
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y)
void __swap(Idx i, Idx j)
Swap 2 vars in the SetInst.
void __add(const DiscreteVariable &v)
Adds a new var to the sequence of vars.
SetInst & interVal(const DiscreteVariable &v, Idx newVal)
Does an intersection (binary and) between the old value and new value.
void unsetOverflow()
Removes the flag overflow.
std::vector< Size > __vals
The current SetInst: the value of the tuple.
bool __overflow
The overflow flag.
SetInst & remVals(const DiscreteVariable &v, const Size newVal)
Remove newVal from the variable v in the SetInst.
Sequence< const DiscreteVariable *> __vars
The tuple of variables to be instantiated.
void erase(const DiscreteVariable &v)
Removes a variable from the SetInst.
Idx pos(const DiscreteVariable &v) const
Returns the position of the variable v.
SetInst & chgVals(const DiscreteVariable &v, const Size newVal)
Assign newVal to variable v in the SetInst.
Idx nbrOccurences(const DiscreteVariable &var) const
Returns the current value of the variable at position i.
Size vals(Idx i) const
Returns the current value of the variable at position i.
SetInst & chgDifVal(Idx varPos, const Size newVal)
Does the difference (binary or) between the old value and new value.
void unsetEnd()
Alias for unsetOverflow().
SetInst & addVal(const DiscreteVariable &v, Idx newVal)
Add newVal to variable v in the SetInst.
SetInst()
Default constructor: creates an empty tuple.
Size Idx
Type for indexes.
bool inOverflow() const
Indicates whether the current value of the tuple is correct or not.
Idx val(Idx i) const
Returns the current value of a variable at a given position.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
SetInst & interVals(const DiscreteVariable &v, const Size newVal)
Does an intersection (binary and) between the old value and new value.
SetInst & chgValIn(const SetInst &i)
Change all the values to match does in i.
SetInst & addVals(const DiscreteVariable &v, const Size newVal)
Add newVal to variable v in the SetInst.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __chgVals(Idx varPos, const Size newVal)
Change the value of a variable.
#define GUM_ERROR(type, msg)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
~SetInst()
Class destructor.
void reorder(const Sequence< const DiscreteVariable * > &v)
Reorder the variables given v.