73 GUM_ASSERT(master !=
nullptr);
80 for (
const auto var: v)
167 for (
const auto var:
_vars_) {
168 if (!first) sstr +=
"|";
173 sstr += var->label(
val(*var));
185 for (
const auto var:
_vars_)
194 for (
const auto& elt: map) {
197 if (!external.
contains(*elt.first)) {
288 for (
const auto& vv:
_vars_) {
289 if (vv->name() == v.
name()) {
291 "Var with name <" << v.
name() <<
"> already exists in this instantiation");
Base class for discrete random variable.
Exception : a similar element already exists.
The class for generic Hash Tables.
Class for assigning/browsing values to tuples of discrete variables.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
void inc()
Operator increment.
void incOut(const Instantiation &i)
Operator increment for the variables not in i.
void decIn(const Instantiation &i)
Operator decrement for the variables in i.
void synchronizeWithMaster(const MultiDimAdressable *m)
Force the variables sequence to be the same as the master one.
void _masterIncNotification_() const
Sequence< const DiscreteVariable * > _vars_
The tuple of variables to be instantiated.
bool actAsSlave(MultiDimAdressable &aMD)
Tries to register the Instantiation to a MultiDimAdressable.
bool isMaster(const MultiDimAdressable *m) const
Indicates whether m is the master of this instantiation.
void _masterFirstNotification_() const
~Instantiation() override
Destructor.
void dec()
Operator decrement.
Instantiation & setVals(const Instantiation &i)
Assign the values from i in the Instantiation.
void add(const DiscreteVariable &v) final
Adds a new variable in the Instantiation.
std::vector< Idx > _vals_
The current instantiation: the value of the tuple.
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.
void incNotVar(const DiscreteVariable &v)
Operator increment for vars which are not v.
MultiDimAdressable * _master_
The master, if any, contains precisely the set of variables to be instantiated.
void _init_(MultiDimAdressable *master)
Initialize this Instantiation.
Idx hamming() const
Returns the hamming distance of this instantiation.
void _erase_(const DiscreteVariable &v)
Removes a variable from the sequence of vars.
void _masterLastNotification_() const
void _add_(const DiscreteVariable &v)
Adds a new var to the sequence of vars.
void _masterDecNotification_() const
void incIn(const Instantiation &i)
Operator increment for the variables in i.
Idx val(Idx i) const
Returns the current value of the variable at position i.
void setValsFrom(const HashTable< const DiscreteVariable *, const DiscreteVariable * > &map, const Instantiation &external)
Assign the values of external in *this, using map as a bijection between external and this variables.
void _masterChangeNotification_(Idx varPos, Idx newVal, Idx oldVal) const
void _chgVal_(Idx varPos, Idx newVal)
Modifies internally the value of a given variable of the sequence.
void decOut(const Instantiation &i)
Operator decrement for the variables not in i.
std::string toString() const
Give a string version of instantiation.
const DiscreteVariable & variable(Idx i) const final
Returns the variable at position i in the tuple.
void decNotVar(const DiscreteVariable &v)
Operator decrement for vars which are not v.
Idx nbrDim() const final
Returns the number of variables in the Instantiation.
bool forgetMaster()
Deassociate the master MultiDimAdressable, if any.
void eraseWithMaster(const MultiDimAdressable *m, const DiscreteVariable &v)
Call Instantiation:: erase(const DiscreteVariable&) by master.
Instantiation & operator=(const Instantiation &aI)
Copy operator.
Exception: at least one argument passed to a function is not what was expected.
Abstract base class for all multi dimensionnal addressable.
virtual bool registerSlave(Instantiation &i)=0
Register i as a slave of this MultiDimAdressable.
virtual MultiDimAdressable & getMasterRef()=0
In order to insure the dereference for decorators, we need to virtualize the access to master pointer...
Interface for all classes addressing in a multiDim fashion.
virtual const Sequence< const DiscreteVariable * > & variablesSequence() const =0
Returns a const ref to the sequence of DiscreteVariable*.
Exception : the element we looked for cannot be found.
Exception : operation not allowed.
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.
Inline implemenation of gum::Instantiation.
Headers for the abstract base class for all multi dimensionnal containers.
gum is the global namespace for all aGrUM entities
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree