32 template <
typename GUM_SCALAR >
35 __changed(false), __name(
"MultiDimBucket") {
39 template <
typename GUM_SCALAR >
50 template <
typename GUM_SCALAR >
71 template <
typename GUM_SCALAR >
77 template <
typename GUM_SCALAR >
91 template <
typename GUM_SCALAR >
97 template <
typename GUM_SCALAR >
116 template <
typename GUM_SCALAR >
122 template <
typename GUM_SCALAR >
128 template <
typename GUM_SCALAR >
133 template <
typename GUM_SCALAR >
138 template <
typename GUM_SCALAR >
143 template <
typename GUM_SCALAR >
148 template <
typename GUM_SCALAR >
159 template <
typename GUM_SCALAR >
175 template <
typename GUM_SCALAR >
180 template <
typename GUM_SCALAR >
196 template <
typename GUM_SCALAR >
210 template <
typename GUM_SCALAR >
215 template <
typename GUM_SCALAR >
221 template <
typename GUM_SCALAR >
242 template <
typename GUM_SCALAR >
263 template <
typename GUM_SCALAR >
278 template <
typename GUM_SCALAR >
293 template <
typename GUM_SCALAR >
308 template <
typename GUM_SCALAR >
323 template <
typename GUM_SCALAR >
338 template <
typename GUM_SCALAR >
349 template <
typename GUM_SCALAR >
358 }
catch (
NotFound&) {
return false; }
369 template <
typename GUM_SCALAR >
378 template <
typename GUM_SCALAR >
388 template <
typename GUM_SCALAR >
389 INLINE
const std::string
391 std::stringstream sBuff;
392 sBuff << (*i) <<
" = " <<
get(*i);
396 template <
typename GUM_SCALAR >
416 for (
auto var : iter.key()->variablesSequence()) {
424 template <
typename GUM_SCALAR >
430 template <
typename GUM_SCALAR >
441 template <
typename GUM_SCALAR >
449 if (iter.key()->contains(*var)) {
462 template <
typename GUM_SCALAR >
488 iter != this->
_slaves().cendSafe();
497 template <
typename GUM_SCALAR >
514 template <
typename GUM_SCALAR >
518 GUM_SCALAR sum = (GUM_SCALAR)0;
524 current = (GUM_SCALAR)1;
532 current *= iter.key()->get(*(iter.val()));
540 std::cerr << std::endl << e.
errorContent() << std::endl;
546 template <
typename GUM_SCALAR >
552 template <
typename GUM_SCALAR >
562 template <
typename GUM_SCALAR >
571 iter.
first()->replace(*x, *y);
572 iter.second()->replace(*x, *y);
582 template <
typename GUM_SCALAR >
virtual bool unregisterSlave(Instantiation &i) override
Unregister i as a slave of this MultiDimAdressable.
virtual void setDecNotification(const Instantiation &i) override
Listen to increment in each recorded Instantiation.
Size __bufferSize
The number of element allowed in __bucket.
Instantiation __allVarsInst
Instantiation over all variable in this.
MultiDimArray< GUM_SCALAR > * __bucket
The result table of this bucket.
HashTable< const MultiDimContainer< GUM_SCALAR > *, Instantiation *> __multiDims
The set of MultiDimContainer in this bucket.
virtual void setChangeNotification(const Instantiation &i) override
Listen to an assignment of a value in a Instantiation.
std::string __name
The class name.
virtual Size realSize() const override
Returns the real number of parameters used for this table.
virtual void erase(const DiscreteVariable &v) override
Removes a var from the variables of the multidimensional matrix.
Safe iterators for bijectionIterator.
bool isBucketEmpty() const
Returns true if this bucket is empty.
const List< Instantiation *> & _slaves() const
Returns a constant reference over the list of slaved instantiations.
virtual const std::string toString() const
Returns a representation of this MultiDimContainer.
A multidim implementation for buckets.
HashTable< const Instantiation *, GUM_SCALAR > __slavesValue
This table is used to keep the last value computed for an instantiation when the value are computed o...
GUM_SCALAR __computeValue(const Instantiation &value) const
Compute the value of the final table of this bucket given i.
Base class for discrete random variable.
bool contains(const MultiDimContainer< GUM_SCALAR > &impl) const
Returns true if the MultiDimContainer is in this bucket.
Safe Iterators for hashtables.
virtual bool unregisterSlave(Instantiation &slave) override
Unregister i as a slave of this MultiDimAdressable.
gum is the global namespace for all aGrUM entities
Abstract base class for all multi dimensionnal containers.
virtual bool empty() const override
Returns true if no var is in *this.
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const override
Default constructor.
virtual GUM_SCALAR get(const Instantiation &i) const override
Returns the value pointed by i.
Abstract base class for all multi dimensionnal read only structure.
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.
The class for generic Hash Tables.
virtual ~MultiDimBucket()
Destructor.
void __addVariable(const DiscreteVariable *var)
Add a variable to __allVariables, and do nothing if var is already in the set.
Representation of a setA Set is a structure that contains arbitrary elements.
void __initializeBuffer()
Initialize the internal buffer.
void __eraseBuffer()
Clean the buffer and switch it's instantiation to this bucket.
void erase(const MultiDimContainer< GUM_SCALAR > &impl)
Remove a MultiDimContainer from this bucket.
void incOut(const Instantiation &i)
Operator increment for the variables not in i.
virtual void changeNotification(const Instantiation &i, const DiscreteVariable *const var, Idx oldval, Idx newval) override
Listen to changes in a given Instantiation.
virtual void setLastNotification(const Instantiation &i) override
Listen to setLast in a given Instantiation.
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y) override
Replace variable x by y.
void inc()
Operator increment.
const MultiDimArray< GUM_SCALAR > & bucket() const
Returns the MultiDimArray used by this MultiDimBucket.
void __eraseVariable(const DiscreteVariable *var)
Erase a variable from __allVariables if no other multidimensional table uses it in this bucket...
Size bucketSize() const
Returns the number of MultiDimContainer in in this bukcet.
MultiDimBucket(Size bufferSize=INT_MAX)
Default constructor.
virtual GUM_SCALAR & _get(const Instantiation &i) const override
void compute(bool force=false) const
This method computes the final table of this bucket.
virtual void setIncNotification(const Instantiation &i) override
Listen to increment in a given Instantiation.
Multidimensional matrix stored as an array in memory.
Bijection< Instantiation *, Instantiation *> __instantiations
Bijection between instantiations registered on this and their equivalent on __bucket.
bool bucketChanged() const
Returns true if the bucket need re-computation since the last computation.
virtual bool empty() const final
Returns true if the instantiation is empty.
virtual void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
bool __changed
Flag used to know if changes has occurred in the bucket since last computation.
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
virtual void setFirstNotification(const Instantiation &i) override
Listen to setFirst in a given Instantiation.
Abstract base class for all multi dimensionnal addressable.
Class for assigning/browsing values to tuples of discrete variables.
virtual void _commitMultipleChanges() override
Synchronize content after MultipleChanges.
virtual Size domainSize() const override
Returns the product of the variables domain size.
Set< const DiscreteVariable *> __allVariables
The set of all variables of the multidims in this bucket.
Size bufferSize() const
Returns the amount of memory allowed for this bucket.
bool isMaster(const MultiDimAdressable *m) const
Indicates whether m is the master of this instantiation.
void setFirst()
Assign the first values to the tuple of the Instantiation.
Headers of the MultiDimBucket class.
const T2 & second() const
Returns the second element of the current association.
void replace(const DiscreteVariable &x, const DiscreteVariable &y)
Replace variables in this multidim.
virtual void _commitMultipleChanges()
Synchronize content after MultipleChanges.
Safe const iterators for Lists.
virtual bool registerSlave(Instantiation &i) override
Register i as a slave of this MultiDimAdressable.
<agrum/multidim/multiDimImplementation.h>
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const =0
Returns a const ref to the sequence of DiscreteVariable*.
Size Idx
Type for indexes.
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.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
void setBufferSize(Size amount)
Changes the amount of memory allowed for this bucket.
const Set< const DiscreteVariable *> & allVariables() const
Returns the sequence of all the variables contained in the bucket.
virtual bool contains(const DiscreteVariable &v) const override
Returns true if var is in *this.
const HashTable< const MultiDimContainer< GUM_SCALAR > *, Instantiation *> & multidims() const
Returns the MultiDimContainer and their respective Instantiation.
const std::string & name() const override
Returns the real name of the multiDim implementation.
const std::string errorContent() const
Returns the message content.
virtual MultiDimAdressable & getMasterRef() override
In order to insure the dereference for decorators, we need to virtualize the access to master pointer...
void add(const MultiDimContainer< GUM_SCALAR > &impl)
Add a MultiDimContainer in the bucket.
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y) override
Replace variable x by y.
const T1 & first() const
Returns the first element of the current association.
virtual bool registerSlave(Instantiation &slave) override
Register i as a slave of this MultiDimAdressable.
#define GUM_ERROR(type, msg)
bool end() const
Returns true if the Instantiation reached the end.
void setFirstOut(const Instantiation &i)
Assign the first values in the Instantiation for the variables not in i.