59 for (
const auto& v:
_vars_) {
60 if (v->name() == name)
return true;
80 auto pPos =
_vars_.tryPos(&v);
82 std::string name =
"instantiation does not contain this DiscreteVariable: ";
120 Idx pos = vv.index(newVal);
153 for (
const auto var:
_vars_)
154 s *= var->domainSize();
192 for (
const auto& v:
_vars_) {
193 if (v->name() == name)
return *v;
233 for (
Idx i = 0; i < depl; i++)
241 for (
Idx i = 0; i < depl; i++)
252 for (
Idx p = 0; p < s; ++p)
263 for (
Idx p = 0; p < s; ++p)
281 for (
Size p = 0; p < s; ++p)
290 for (
Size p = 0; p < s; ++p) {
302 for (
Size p = 0; p < s; ++p)
316 for (
Size p = 0; p < s; ++p)
325 for (
Size p = 0; p < s; ++p)
338 for (
Size p = 0; p < s; ++p) {
355 for (
Size p = 0; p < s; ++p) {
457 for (
Idx i = 0; i < max; ++i) {
462 GUM_ASSERT(p >= position);
522 if (!other.
contains(k))
return false;
523 if (
val(*k) != other.
val(*k))
return false;
Base class for discrete random variable.
virtual Size domainSize() const =0
Size operator()(const Instantiation &key) const final
Computes the hashed value of a key.
static Size castToSize(const Instantiation &key)
Returns the value of a key as a Size.
This class should be useless as only its specializations should be used.
Class for assigning/browsing values to tuples of discrete variables.
const Sequence< const DiscreteVariable * > & variablesSequence() const final
Returns the sequence of DiscreteVariable of this instantiation.
void setLastOut(const Instantiation &i)
Assign the last values in the Instantiation for the variables not in i.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
bool end() const
Returns true if the Instantiation reached the end.
void inc()
Operator increment.
void clear()
Erase all variables from an Instantiation.
Instantiation & operator--()
Alias of Instantiation::dec().
Sequence< const DiscreteVariable * > _vars_
The tuple of variables to be instantiated.
void incVar(const DiscreteVariable &v)
Operator increment for variable v only.
bool isMaster(const MultiDimAdressable *m) const
Indicates whether m is the master of this instantiation.
void _masterFirstNotification_() const
void setFirstNotVar(const DiscreteVariable &v)
Assign the first values to variables different of v.
void setFirstIn(const Instantiation &i)
Assign the first values in the Instantiation for the variables in i.
void decVar(const DiscreteVariable &v)
Operator decrement for variable v only.
void dec()
Operator decrement.
Instantiation & setVals(const Instantiation &i)
Assign the values from i in the Instantiation.
Instantiation & operator-=(Size depl)
Calls depl times Instantiation::dec().
std::vector< Idx > _vals_
The current instantiation: the value of the tuple.
void setLastIn(const Instantiation &i)
Assign the last values in the Instantiation for the variables in i.
bool empty() const final
Returns true if the instantiation is empty.
bool _overflow_
Indicates whether the current value of the tuple is valid when we loop sufficiently over values of th...
void _reorder_(const Sequence< const DiscreteVariable * > &v)
Reorder vars of this instantiation giving the order in v.
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.
bool contains(const DiscreteVariable &v) const final
Indicates whether a given variable belongs to the Instantiation.
Instantiation()
Default constructor: creates an empty tuple.
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
void setFirstVar(const DiscreteVariable &v)
Assign the first value in the Instantiation for var v.
bool rend() const
Returns true if the Instantiation reached the rend.
MultiDimAdressable * _master_
The master, if any, contains precisely the set of variables to be instantiated.
void erase(const DiscreteVariable &v) final
Removes a variable from the Instantiation.
bool isSlave() const
Indicates whether the Instantiation has a master.
void addWithMaster(const MultiDimAdressable *m, const DiscreteVariable &v)
Call Instantiation:: add(const DiscreteVariable&) by master.
void setLastNotVar(const DiscreteVariable &v)
Assign the last values to variables different of v.
void _erase_(const DiscreteVariable &v)
Removes a variable from the sequence of vars.
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::inc().
void _masterLastNotification_() const
void _swap_(Idx i, Idx j)
Swap two variables in the Instantiation.
bool inOverflow() const
Indicates whether the current value of the tuple is correct or not.
void _add_(const DiscreteVariable &v)
Adds a new var to the sequence of vars.
Idx val(Idx i) const
Returns the current value of the variable at position i.
void setFirst()
Assign the first values to the tuple of the Instantiation.
void _masterChangeNotification_(Idx varPos, Idx newVal, Idx oldVal) const
void setFirstOut(const Instantiation &i)
Assign the first values in the Instantiation for the variables not in i.
void _chgVal_(Idx varPos, Idx newVal)
Modifies internally the value of a given variable of the sequence.
void unsetEnd()
Alias for unsetOverflow().
const DiscreteVariable & variable(Idx i) const final
Returns the variable at position i in the tuple.
Idx nbrDim() const final
Returns the number of variables in the Instantiation.
Instantiation & operator++()
Alias of Instantiation::inc().
bool operator==(const Instantiation &other) const
operator==
void setLastVar(const DiscreteVariable &v)
Assign the last value in the Instantiation for var v.
void unsetOverflow()
Removes the flag overflow.
void replace_(const DiscreteVariable *x, const DiscreteVariable *y) final
Replace x by y.
void setLast()
Assign the last values in the Instantiation.
Abstract base class for all multi dimensionnal addressable.
Exception : the element we looked for cannot be found.
Exception : operation not allowed.
Exception : out of bound.
const Key & atPos(Idx i) const
Returns the object at the pos i.
Size size() const noexcept
Returns the size of the sequence.
The generic class for storing (ordered) sequences of objects.
const std::string & name() const
returns the name of the variable
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Header files of gum::Instantiation.
Headers for the abstract base class for all multi dimensionnal containers.
gum is the global namespace for all aGrUM entities