67 std::string name =
"instantiation does not contain this DiscreteVariable: ";
89 std::string name =
"instantiation does not contain this DiscreteVariable: ";
115 const std::string& newVal) {
117 Idx pos = vv.index(newVal);
130 "Var <" << v.
name() <<
"> already exists in this instantiation");
133 for (
const auto& vv :
__vars) {
134 if (vv->name() == v.
name()) {
136 "Var with name <" << v.
name()
137 <<
"> already exists in this instantiation");
173 for (
const auto var :
__vars)
174 s *= var->domainSize();
208 return *(
__vars.atPos(i));
213 for (
const auto& v :
__vars) {
214 if (v->name() == name)
return *v;
317 for (
Idx i = 0; i < depl; i++)
326 for (
Idx i = 0; i < depl; i++)
337 for (
Idx p = 0; p < s; ++p)
348 for (
Idx p = 0; p < s; ++p)
447 for (
Size p = 0; p < s; ++p)
456 for (
Size p = 0; p < s; ++p)
467 for (
Size p = 0; p < s; ++p)
545 for (
Size p = 0; p < s; ++p)
554 for (
Size p = 0; p < s; ++p)
631 for (
Size p = 0; p < s; ++p) {
648 for (
Size p = 0; p < s; ++p) {
746 "Reordering impossible in slave instantiation");
757 for (
Idx i = 0; i < max; ++i) {
762 GUM_ASSERT(p >= position);
821 return castToSize(key) & this->_hash_mask;
828 if (!other.
contains(k))
return false;
829 if (
val(*k) != other.
val(*k))
return false;
void __erase(const DiscreteVariable &v)
Removes a variable from the sequence of vars.
bool __overflow
Indicates whether the current value of the tuple is valid when we loop sufficiently over values of th...
void decIn(const Instantiation &i)
Operator decrement for the variables in i.
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
void addWithMaster(const MultiDimAdressable *m, const DiscreteVariable &v)
Call Instantiation::__add(const DiscreteVariable&) by master.
Idx pos(const DiscreteVariable &v) const final
Returns the position of the variable v.
Size domainSize() const final
Returns the product of the variable's domain size in the Instantiation.
void __masterDecNotification() const
Idx nbrDim() const final
Returns the number of variables in the Instantiation.
Size size() const noexcept
Returns the size of the sequence.
void setLast()
Assign the last values in the Instantiation.
The generic class for storing (ordered) sequences of objects.
void setLastIn(const Instantiation &i)
Assign the last values in the Instantiation for the variables in i.
Sequence< const DiscreteVariable *> __vars
The tuple of variables to be instantiated.
void unsetOverflow()
Removes the flag overflow.
void __masterIncNotification() const
void dec()
Operator decrement.
bool operator==(const Instantiation &other) const
operator==
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
void reorder(const Sequence< const DiscreteVariable * > &v)
Reorder vars of this instantiation giving the order in v.
Class template representing hashing function of LpCol.
Base class for discrete random variable.
void setLastOut(const Instantiation &i)
Assign the last values in the Instantiation for the variables not in i.
void incNotVar(const DiscreteVariable &v)
Operator increment for vars which are not v.
gum is the global namespace for all aGrUM entities
void incVar(const DiscreteVariable &v)
Operator increment for variable v only.
Instantiation & setVals(const Instantiation &i)
Assign the values from i in the Instantiation.
const Sequence< const DiscreteVariable *> & variablesSequence() const final
Returns the sequence of DiscreteVariable of this instantiation.
void setFirstNotVar(const DiscreteVariable &v)
Assign the first values to variables different of v.
void unsetEnd()
Alias for unsetOverflow().
void decOut(const Instantiation &i)
Operator decrement for the variables not in i.
Idx val(Idx i) const
Returns the current value of the variable at position i.
Instantiation & operator--()
Alias of Instantiation::dec().
virtual Size domainSize() const =0
Instantiation & operator++()
Alias of Instantiation::inc().
bool rend() const
Returns true if the Instantiation reached the rend.
void incOut(const Instantiation &i)
Operator increment for the variables not in i.
void setFirstIn(const Instantiation &i)
Assign the first values in the Instantiation for the variables in i.
void clear()
Erase all variables from an Instantiation.
void inc()
Operator increment.
void __chgVal(Idx varPos, Idx newVal)
Modifies internally the value of a given variable of the sequence.
void setFirstVar(const DiscreteVariable &v)
Assign the first value in the Instantiation for var v.
void __reorder(const Sequence< const DiscreteVariable * > &v)
Reorder vars of this instantiation giving the order in v.
Instantiation & operator-=(Size depl)
Calls depl times Instantiation::dec().
virtual bool empty() const final
Returns true if the instantiation is empty.
void __masterFirstNotification() const
void incIn(const Instantiation &i)
Operator increment for the variables in i.
void setLastNotVar(const DiscreteVariable &v)
Assign the last values to variables different of v.
void __masterLastNotification() const
MultiDimAdressable * __master
The master, if any, contains precisely the set of variables to be instantiated.
Abstract base class for all multi dimensionnal addressable.
Class for assigning/browsing values to tuples of discrete variables.
bool contains(const DiscreteVariable &v) const final
Indicates whether a given variable belongs to the Instantiation.
bool isMaster(const MultiDimAdressable *m) const
Indicates whether m is the master of this instantiation.
Instantiation & operator+=(Size depl)
Calls depl times Instantiation::inc().
void setLastVar(const DiscreteVariable &v)
Assign the last value in the Instantiation for var v.
void setFirst()
Assign the first values to the tuple of the Instantiation.
void __swap(Idx i, Idx j)
Swap two variables in the Instantiation.
Size Idx
Type for indexes.
bool inOverflow() const
Indicates whether the current value of the tuple is correct or not.
void decNotVar(const DiscreteVariable &v)
Operator decrement for vars which are not v.
void add(const DiscreteVariable &v) final
Adds a new variable in the Instantiation.
void erase(const DiscreteVariable &v) final
Removes a variable from the Instantiation.
bool isSlave() const
Indicates whether the Instantiation has a master.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y) final
Replace x by y.
const std::string & name() const
returns the name of the variable
const DiscreteVariable & variable(Idx i) const final
Returns the variable at position i in the tuple.
void __add(const DiscreteVariable &v)
Adds a new var to the sequence of vars.
void decVar(const DiscreteVariable &v)
Operator decrement for variable v only.
Headers for the abstract base class for all multi dimensionnal containers.
void __masterChangeNotification(Idx varPos, Idx newVal, Idx oldVal) const
#define GUM_ERROR(type, msg)
const Key & atPos(Idx i) const
Returns the object at the pos i.
bool end() const
Returns true if the Instantiation reached the end.
std::vector< Idx > __vals
The current instantiation: the value of the tuple.
void setFirstOut(const Instantiation &i)
Assign the first values in the Instantiation for the variables not in i.