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

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

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

Inheritance diagram for gum::MultiDimCombination< TABLE >:

Public Types

using value_type = typename TableType< TABLE >::value_type
 the type of the values contained into TABLE

Public Member Functions

Constructors / Destructors
 MultiDimCombination ()
 default constructor
 MultiDimCombination (const MultiDimCombination< TABLE > &)
 copy constructor
virtual ~MultiDimCombination ()
 destructor
virtual MultiDimCombination< TABLE > * clone () const =0
 virtual constructor

Accessors/Modifiers

virtual TABLE(*)(const TABLE &, const TABLE &) combinationFunction ()
 returns the combination function currently used by the combinator
virtual TABLE * execute (const Set< const TABLE * > &set) const =0
 creates and returns the result of the combination of the tables within set
virtual void execute (TABLE &container, const Set< const TABLE * > &set) const =0
 returns the combination function currently used by the combinator
virtual std::pair< std::vector< ScheduleOperator * >, const IScheduleMultiDim * > operations (const std::vector< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const =0
 returns the set of operations to perform as well as the result of the combination
virtual std::pair< std::vector< ScheduleOperator * >, const IScheduleMultiDim * > operations (const Set< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const =0
 returns the combination function currently used by the combinator
const IScheduleMultiDimschedule (Schedule &schedule, const Set< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const
 add to a given schedule the set of operations needed to perform the combination
const IScheduleMultiDimschedule (Schedule &schedule, const std::vector< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const
 returns the combination function currently used by the combinator
virtual void setCombinationFunction (TABLE(*combine)(const TABLE &, const TABLE &))=0
 changes the function used for combining two TABLES
virtual double nbOperations (const Set< const TABLE * > &set) const =0
 returns a rough estimate of the number of operations that will be performed to compute the combination.
virtual double nbOperations (const Set< const Sequence< const DiscreteVariable * > * > &set) const =0
 returns the combination function currently used by the combinator
virtual std::pair< double, doublememoryUsage (const Set< const TABLE * > &set) const =0
 Returns the memory consumption used during the combination.
virtual std::pair< double, doublememoryUsage (const Set< const Sequence< const DiscreteVariable * > * > &set) const =0
 returns the combination function currently used by the combinator
MultiDimCombination< TABLE > & operator= (const MultiDimCombination< TABLE > &)
 forbid copy operators

Detailed Description

template<class TABLE>
class gum::MultiDimCombination< 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. Note that MultiDimCombinations always produce a new freshly allocated table as the result of the combinations.

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,Tensor) 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 Tensor<float>'s:
Tensor<float> addTensor ( const Tensor<float>& t1,
const Tensor<float>& t2 ) {
return t1 + t2;
}
// another function used to combine two Tensor<float>'s:
Tensor<float> multTensor ( const Tensor<float>& t1,
const Tensor<float>& t2 ) {
return t1 * t2;
}
Tensor<float> t1, t2, t3;
Set<const Tensor<float>*> set;
set << &table1 << &table2 << &table3;
MultiDimCombinationDefault< Tensor< float > > Comb ( addTensor );
Tensor<float>* combined_table = Comb.execute ( set );
// change the operator to apply
Comb.setCombinationFunction ( multTensor );
Tensor<float>* combined_table2 = Comb.execute ( set );
aGrUM's Tensor is a multi-dimensional array with tensor operators.
Definition tensor.h:85

Definition at line 120 of file multiDimCombination.h.

Member Typedef Documentation

◆ value_type

template<class TABLE>
using gum::MultiDimCombination< TABLE >::value_type = typename TableType< TABLE >::value_type

the type of the values contained into TABLE

Definition at line 136 of file multiDimCombination.h.

Constructor & Destructor Documentation

◆ MultiDimCombination() [1/2]

template<class TABLE>
gum::MultiDimCombination< TABLE >::MultiDimCombination ( )

default constructor

Referenced by MultiDimCombination(), clone(), gum::MultiDimCombinationDefault< TABLE >::operations(), and operator=().

Here is the caller graph for this function:

◆ MultiDimCombination() [2/2]

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

copy constructor

References MultiDimCombination().

Here is the call graph for this function:

◆ ~MultiDimCombination()

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

destructor

Member Function Documentation

◆ clone()

template<class TABLE>
virtual MultiDimCombination< TABLE > * gum::MultiDimCombination< TABLE >::clone ( ) const
pure virtual

virtual constructor

Returns
a new fresh MultiDimCombinator with the same combination function.

Implemented in gum::MultiDimCombinationDefault< TABLE >.

References MultiDimCombination().

Here is the call graph for this function:

◆ execute() [1/2]

template<class TABLE>
virtual TABLE * gum::MultiDimCombination< TABLE >::execute ( const Set< const TABLE * > & 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< TABLE >.

◆ execute() [2/2]

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

returns the combination function currently used by the combinator

Implemented in gum::MultiDimCombinationDefault< TABLE >.

◆ memoryUsage() [1/2]

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

returns the combination function currently used by the combinator

Implemented in gum::MultiDimCombinationDefault< TABLE >.

◆ memoryUsage() [2/2]

template<class TABLE>
virtual std::pair< double, double > gum::MultiDimCombination< TABLE >::memoryUsage ( const Set< const TABLE * > & 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< TABLE >.

◆ nbOperations() [1/2]

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

returns the combination function currently used by the combinator

Implemented in gum::MultiDimCombinationDefault< TABLE >.

◆ nbOperations() [2/2]

template<class TABLE>
virtual double gum::MultiDimCombination< TABLE >::nbOperations ( const Set< const TABLE * > & 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< TABLE >.

◆ operations() [1/2]

template<class TABLE>
virtual std::pair< std::vector< ScheduleOperator * >, const IScheduleMultiDim * > gum::MultiDimCombination< TABLE >::operations ( const Set< const IScheduleMultiDim * > & set,
const bool is_result_persistent = false ) const
pure virtual

returns the combination function currently used by the combinator

Implemented in gum::MultiDimCombinationDefault< TABLE >.

◆ operations() [2/2]

template<class TABLE>
virtual std::pair< std::vector< ScheduleOperator * >, const IScheduleMultiDim * > gum::MultiDimCombination< TABLE >::operations ( const std::vector< const IScheduleMultiDim * > & set,
const bool is_result_persistent = false ) const
pure virtual

returns the set of operations to perform as well as the result of the combination

Executing sequentially the set of operations returned is guaranteed to produce the right result. The latter is contained within the IScheduleMultiDim.

Warning
MultiDimCombinations always produce a new freshly allocated resulting table

Implemented in gum::MultiDimCombinationDefault< TABLE >.

◆ operator=()

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

forbid copy operators

References MultiDimCombination().

Here is the call graph for this function:

◆ schedule() [1/2]

template<class TABLE>
const IScheduleMultiDim * gum::MultiDimCombination< TABLE >::schedule ( Schedule & schedule,
const Set< const IScheduleMultiDim * > & set,
const bool is_result_persistent = false ) const

add to a given schedule the set of operations needed to perform the combination

Warning
whenever this method is executed, it is assumed that the ScheduleMultiDim already belong to the schedule.
MultiDimCombinations always produce a new freshly allocated resulting table

References schedule().

Referenced by gum::MultiDimCombinationDefault< TABLE >::operations(), schedule(), and schedule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ schedule() [2/2]

template<class TABLE>
const IScheduleMultiDim * gum::MultiDimCombination< TABLE >::schedule ( Schedule & schedule,
const std::vector< const IScheduleMultiDim * > & set,
const bool is_result_persistent = false ) const

returns the combination function currently used by the combinator

References schedule().

Here is the call graph for this function:

◆ setCombinationFunction()

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

changes the function used for combining two TABLES

Implemented in gum::MultiDimCombinationDefault< TABLE >.

Member Data Documentation

◆ combinationFunction

template<class TABLE>
virtual TABLE(*)(const TABLE &, const TABLE &) gum::MultiDimCombination< TABLE >::combinationFunction()
inline

returns the combination function currently used by the combinator

Definition at line 209 of file multiDimCombination.h.


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