35 template <
typename GUM_SCALAR >
38 __changed(false), __name(
"MultiDimBucket") {
42 template <
typename GUM_SCALAR >
53 template <
typename GUM_SCALAR >
74 template <
typename GUM_SCALAR >
80 template <
typename GUM_SCALAR >
94 template <
typename GUM_SCALAR >
100 template <
typename GUM_SCALAR >
119 template <
typename GUM_SCALAR >
125 template <
typename GUM_SCALAR >
131 template <
typename GUM_SCALAR >
136 template <
typename GUM_SCALAR >
141 template <
typename GUM_SCALAR >
146 template <
typename GUM_SCALAR >
151 template <
typename GUM_SCALAR >
162 template <
typename GUM_SCALAR >
178 template <
typename GUM_SCALAR >
183 template <
typename GUM_SCALAR >
199 template <
typename GUM_SCALAR >
213 template <
typename GUM_SCALAR >
218 template <
typename GUM_SCALAR >
224 template <
typename GUM_SCALAR >
245 template <
typename GUM_SCALAR >
266 template <
typename GUM_SCALAR >
281 template <
typename GUM_SCALAR >
296 template <
typename GUM_SCALAR >
311 template <
typename GUM_SCALAR >
326 template <
typename GUM_SCALAR >
341 template <
typename GUM_SCALAR >
352 template <
typename GUM_SCALAR >
361 }
catch (
NotFound&) {
return false; }
372 template <
typename GUM_SCALAR >
381 template <
typename GUM_SCALAR >
391 template <
typename GUM_SCALAR >
392 INLINE
const std::string
394 std::stringstream sBuff;
395 sBuff << (*i) <<
" = " <<
get(*i);
399 template <
typename GUM_SCALAR >
419 for (
auto var : iter.key()->variablesSequence()) {
427 template <
typename GUM_SCALAR >
433 template <
typename GUM_SCALAR >
444 template <
typename GUM_SCALAR >
452 if (iter.key()->contains(*var)) {
465 template <
typename GUM_SCALAR >
491 iter != this->
_slaves().cendSafe();
500 template <
typename GUM_SCALAR >
517 template <
typename GUM_SCALAR >
521 GUM_SCALAR sum = (GUM_SCALAR)0;
527 current = (GUM_SCALAR)1;
535 current *= iter.key()->get(*(iter.val()));
543 std::cerr << std::endl << e.
errorContent() << std::endl;
549 template <
typename GUM_SCALAR >
555 template <
typename GUM_SCALAR >
565 template <
typename GUM_SCALAR >
574 iter.
first()->replace(*x, *y);
575 iter.second()->replace(*x, *y);
585 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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.