57 for (
const auto& v:
_vars_) {
58 if (v->name() == name)
return true;
91 std::string name =
"instantiation does not contain this DiscreteVariable: ";
118 Idx pos = vv.index(newVal);
133 for (
const auto& vv:
_vars_) {
134 if (vv->name() == v.
name()) {
136 "Var with name <" << v.
name() <<
"> already exists in this instantiation");
171 for (
const auto var:
_vars_)
172 s *= var->domainSize();
210 for (
const auto& v:
_vars_) {
211 if (v->name() == name)
return *v;
311 for (
Idx i = 0; i < depl; i++)
319 for (
Idx i = 0; i < depl; i++)
330 for (
Idx p = 0; p < s; ++p)
341 for (
Idx p = 0; p < s; ++p)
434 for (
Size p = 0; p < s; ++p)
443 for (
Size p = 0; p < s; ++p)
454 for (
Size p = 0; p < s; ++p)
528 for (
Size p = 0; p < s; ++p)
537 for (
Size p = 0; p < s; ++p)
610 for (
Size p = 0; p < s; ++p) {
627 for (
Size p = 0; p < s; ++p) {
729 for (
Idx i = 0; i < max; ++i) {
734 GUM_ASSERT(p >= position);
793 if (!other.
contains(k))
return false;
794 if (
val(*k) != other.
val(*k))
return false;
Base class for discrete random variable.
virtual Size domainSize() const =0
Exception : a similar element already exists.
static Size castToSize(const Instantiation &key)
Returns the value of a key as a Size.
virtual Size operator()(const Instantiation &key) const override final
Computes the hashed value of a key.
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.
void incIn(const Instantiation &i)
Operator increment for the variables in i.
void decNotVar(const DiscreteVariable &v)
Operator decrement for vars which are not v.
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 incOut(const Instantiation &i)
Operator increment for the variables not in i.
void decOut(const Instantiation &i)
Operator decrement for the variables not in i.
void clear()
Erase all variables from an Instantiation.
void _masterIncNotification_() const
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 add(const DiscreteVariable &v) final
Adds a new variable in the Instantiation.
void decVar(const DiscreteVariable &v)
Operator decrement for variable v only.
void decIn(const Instantiation &i)
Operator decrement for the variables in i.
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.
void incNotVar(const DiscreteVariable &v)
Operator increment for vars which are not v.
virtual 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.
void inc()
Operator increment.
MultiDimAdressable * _master_
The master, if any, contains precisely the set of variables to be instantiated.
void dec()
Operator decrement.
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.
void _masterDecNotification_() const
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.
virtual void replace_(const DiscreteVariable *x, const DiscreteVariable *y) final
Replace x by y.
void setLast()
Assign the last values in the Instantiation.
Exception: at least one argument passed to a function is not what was expected.
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.
Size size() const noexcept
Returns the size of the sequence.
const Key & atPos(Idx i) const
Returns the object at the pos i.
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.
Headers for the abstract base class for all multi dimensionnal containers.
gum is the global namespace for all aGrUM entities