aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::MultiDimCombination< GUM_SCALAR, TABLE > Class Template Referenceabstract

A generic interface to combine efficiently several MultiDim tables. More...

#include <agrum/tools/multidim/multiDimCombination.h>

+ Inheritance diagram for gum::MultiDimCombination< GUM_SCALAR, TABLE >:

Public Member Functions

Constructors / Destructors
 MultiDimCombination ()
 default constructor More...
 
 MultiDimCombination (const MultiDimCombination< GUM_SCALAR, TABLE > &)
 copy constructor More...
 
virtual ~MultiDimCombination ()
 destructor More...
 
virtual MultiDimCombination< GUM_SCALAR, TABLE > * newFactory () const =0
 virtual constructor More...
 

Accessors/Modifiers

virtual TABLE< GUM_SCALAR > * combine (const Set< const TABLE< GUM_SCALAR > * > &set)=0
 creates and returns the result of the combination of the tables within set More...
 
virtual void combine (TABLE< GUM_SCALAR > &container, const Set< const TABLE< GUM_SCALAR > * > &set)=0
 creates and returns the result of the combination of the tables within set More...
 
virtual void setCombineFunction (TABLE< GUM_SCALAR > *(*combine)(const TABLE< GUM_SCALAR > &, const TABLE< GUM_SCALAR > &))=0
 changes the function used for combining two TABLES More...
 
virtual TABLE< GUM_SCALAR > *(*)(const TABLE< GUM_SCALAR > &, const TABLE< GUM_SCALAR > &) combineFunction ()
 returns the combination function currently used by the combinator More...
 
virtual float nbOperations (const Set< const TABLE< GUM_SCALAR > * > &set) const =0
 returns a rough estimate of the number of operations that will be performed to compute the combination. More...
 
virtual float nbOperations (const Set< const Sequence< const DiscreteVariable * > * > &set) const =0
 creates and returns the result of the combination of the tables within set More...
 
virtual std::pair< long, long > memoryUsage (const Set< const TABLE< GUM_SCALAR > * > &set) const =0
 Returns the memory consumption used during the combination. More...
 
virtual std::pair< long, long > memoryUsage (const Set< const Sequence< const DiscreteVariable * > * > &set) const =0
 creates and returns the result of the combination of the tables within set More...
 
MultiDimCombination< GUM_SCALAR, TABLE > & operator= (const MultiDimCombination< GUM_SCALAR, TABLE > &)
 forbid copy operators More...
 

Detailed Description

template<typename GUM_SCALAR, template< typename > class TABLE>
class gum::MultiDimCombination< GUM_SCALAR, TABLE >

A generic interface to combine efficiently several MultiDim tables.

MultiDimCombination is a generic interface designed to combine efficiently several multidimensional objects, that is, to compute expressions like T1 op T2 op T3 op .... op Tn, where the Ti's are the multidimensional objects and op is an operator or a function taking in argument two such objects and producing a new (combined) Ti object. By default, the combination operation "op" is assumed to be COMMUTATIVE and ASSOCIATIVE.

By multidimensional objects, we mean of course MultiDimImplementations, but also more complex objects such as, for instance, pairs of MultiDimImplementation the first one of which being a utility function and the second one being a table of instantiations (useful, e.g., for computing MPE's) but this can also be a pair (Utility,Potential) for the inference in an Influence Diagram. Actually, the important point for a multidimensional object to be eligible to be combined by the MultiDimCombination is:

that there exists a function taking in arguments two such

multidimensional objects and producing a new object of the same type, which is the so-called combined result of these two objects.

To be quite generic, the MultiDimCombination takes in argument the function that produces the result of the combination of two multidimensional objects. The following code gives an example of the usage of MultiDimCombinations:

// a function used to combine two Potential<float>'s:
Potential<float>* addPotential ( const Potential<float>& t1,
const Potential<float>& t2 ) {
return new Potential<float> (t1 + t2);
}
// another function used to combine two Potential<float>'s:
Potential<float>* multPotential ( const Potential<float>& t1,
const Potential<float>& t2 ) {
return new Potential<float> (t1 * t2);
}
Potential<float> t1, t2, t3;
Set<const Potential<float>*> set;
set << &table1 << &table2 << &table3;
MultiDimCombinationDefault<float,Potential> Comb ( addPotential );
Potential<float>* combined_table = Comb.combine ( set );
// change the operator to apply
Comb.setCombineFunction ( multPotential );
Potential<float>* combined_table2 = Comb.combine ( set );

Definition at line 96 of file multiDimCombination.h.

Constructor & Destructor Documentation

◆ MultiDimCombination() [1/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
gum::MultiDimCombination< GUM_SCALAR, TABLE >::MultiDimCombination ( )

default constructor

◆ MultiDimCombination() [2/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
gum::MultiDimCombination< GUM_SCALAR, TABLE >::MultiDimCombination ( const MultiDimCombination< GUM_SCALAR, TABLE > &  )

copy constructor

◆ ~MultiDimCombination()

template<typename GUM_SCALAR , template< typename > class TABLE>
virtual gum::MultiDimCombination< GUM_SCALAR, TABLE >::~MultiDimCombination ( )
virtual

destructor

Member Function Documentation

◆ combine() [1/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
virtual TABLE< GUM_SCALAR >* gum::MultiDimCombination< GUM_SCALAR, TABLE >::combine ( const Set< const TABLE< GUM_SCALAR > * > &  set)
pure virtual

creates and returns the result of the combination of the tables within set

Returns
a new freshly created TABLE which is the result of the combination of all the TABLES passed in argument
Exceptions
InvalidArgumentsNumberexception is thrown if the set passed in argument contains less than two elements.

Implemented in gum::MultiDimCombinationDefault< GUM_SCALAR, TABLE >.

◆ combine() [2/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
virtual void gum::MultiDimCombination< GUM_SCALAR, TABLE >::combine ( TABLE< GUM_SCALAR > &  container,
const Set< const TABLE< GUM_SCALAR > * > &  set 
)
pure virtual

creates and returns the result of the combination of the tables within set

Returns
a new freshly created TABLE which is the result of the combination of all the TABLES passed in argument
Exceptions
InvalidArgumentsNumberexception is thrown if the set passed in argument contains less than two elements.

Implemented in gum::MultiDimCombinationDefault< GUM_SCALAR, TABLE >.

◆ combineFunction()

template<typename GUM_SCALAR , template< typename > class TABLE>
virtual TABLE< GUM_SCALAR >*(*)(const TABLE< GUM_SCALAR >&, const TABLE< GUM_SCALAR >&) gum::MultiDimCombination< GUM_SCALAR, TABLE >::combineFunction ( )
virtual

returns the combination function currently used by the combinator

Reimplemented in gum::MultiDimCombinationDefault< GUM_SCALAR, TABLE >.

◆ memoryUsage() [1/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
virtual std::pair< long, long > gum::MultiDimCombination< GUM_SCALAR, TABLE >::memoryUsage ( const Set< const TABLE< GUM_SCALAR > * > &  set) const
pure virtual

Returns the memory consumption used during the combination.

Actually, this function does not return a precise account of the memory used by the multidimCombination but a rough estimate based on the sizes of the tables involved in the combination.

Returns
a pair of memory consumption: the first one is the maximum amount of memory used during the combination and the second one is the amount of memory still used at the end of the function ( the memory used by the resulting table ).

Implemented in gum::MultiDimCombinationDefault< GUM_SCALAR, TABLE >.

◆ memoryUsage() [2/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
virtual std::pair< long, long > gum::MultiDimCombination< GUM_SCALAR, TABLE >::memoryUsage ( const Set< const Sequence< const DiscreteVariable * > * > &  set) const
pure virtual

creates and returns the result of the combination of the tables within set

Returns
a new freshly created TABLE which is the result of the combination of all the TABLES passed in argument
Exceptions
InvalidArgumentsNumberexception is thrown if the set passed in argument contains less than two elements.

Implemented in gum::MultiDimCombinationDefault< GUM_SCALAR, TABLE >.

◆ nbOperations() [1/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
virtual float gum::MultiDimCombination< GUM_SCALAR, TABLE >::nbOperations ( const Set< const TABLE< GUM_SCALAR > * > &  set) const
pure virtual

returns a rough estimate of the number of operations that will be performed to compute the combination.

Implemented in gum::MultiDimCombinationDefault< GUM_SCALAR, TABLE >.

◆ nbOperations() [2/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
virtual float gum::MultiDimCombination< GUM_SCALAR, TABLE >::nbOperations ( const Set< const Sequence< const DiscreteVariable * > * > &  set) const
pure virtual

creates and returns the result of the combination of the tables within set

Returns
a new freshly created TABLE which is the result of the combination of all the TABLES passed in argument
Exceptions
InvalidArgumentsNumberexception is thrown if the set passed in argument contains less than two elements.

Implemented in gum::MultiDimCombinationDefault< GUM_SCALAR, TABLE >.

◆ newFactory()

template<typename GUM_SCALAR , template< typename > class TABLE>
virtual MultiDimCombination< GUM_SCALAR, TABLE >* gum::MultiDimCombination< GUM_SCALAR, TABLE >::newFactory ( ) const
pure virtual

virtual constructor

Returns
a new fresh MultiDimCombinator with the same combination function.

Implemented in gum::MultiDimCombinationDefault< GUM_SCALAR, TABLE >.

◆ operator=()

template<typename GUM_SCALAR , template< typename > class TABLE>
MultiDimCombination< GUM_SCALAR, TABLE >& gum::MultiDimCombination< GUM_SCALAR, TABLE >::operator= ( const MultiDimCombination< GUM_SCALAR, TABLE > &  )
private

forbid copy operators

◆ setCombineFunction()

template<typename GUM_SCALAR , template< typename > class TABLE>
virtual void gum::MultiDimCombination< GUM_SCALAR, TABLE >::setCombineFunction ( TABLE< GUM_SCALAR > *(*)(const TABLE< GUM_SCALAR > &, const TABLE< GUM_SCALAR > &)  combine)
pure virtual

changes the function used for combining two TABLES

Implemented in gum::MultiDimCombinationDefault< GUM_SCALAR, TABLE >.


The documentation for this class was generated from the following file: