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

A generic class to project efficiently a MultiDim table over a subset of its variables. More...

#include <agrum/tools/multidim/operators/multiDimProjection.h>

Public Member Functions

Constructors / Destructors
 MultiDimProjection (TABLE< GUM_SCALAR > *(*proj)(const TABLE< GUM_SCALAR > &, const Set< const DiscreteVariable * > &))
 Default constructor. More...
 
 MultiDimProjection (const MultiDimProjection< GUM_SCALAR, TABLE > &)
 Copy constructor. More...
 
virtual ~MultiDimProjection ()
 Destructor. More...
 
virtual MultiDimProjection< GUM_SCALAR, TABLE > * newFactory () const
 virtual constructor More...
 
Accessors/Modifiers
TABLE< GUM_SCALAR > * project (const TABLE< GUM_SCALAR > &table, const Set< const DiscreteVariable * > &del_vars)
 Creates and returns the projection of the table over a subset of its vars. More...
 
void project (TABLE< GUM_SCALAR > &container, const TABLE< GUM_SCALAR > &table, const Set< const TABLE< GUM_SCALAR > * > &del_vars)
 Creates and returns the projection of the table over a subset of its vars. More...
 
void setProjectFunction (TABLE< GUM_SCALAR > *(*proj)(const TABLE< GUM_SCALAR > &, const Set< const DiscreteVariable * > &))
 Changes the function used for projecting TABLES. More...
 
TABLE< GUM_SCALAR > *(*)(const TABLE< GUM_SCALAR > &, const Set< const DiscreteVariable *> &) projectFunction ()
 Returns the projection function currently used by the projector. More...
 
float nbOperations (const TABLE< GUM_SCALAR > &table, const Set< const DiscreteVariable * > &del_vars) const
 returns a rough estimate of the number of operations that will be performed to compute the projection. More...
 
float nbOperations (const Sequence< const DiscreteVariable * > &vars, const Set< const DiscreteVariable * > &del_vars) const
 returns a rough estimate of the number of operations that will be performed to compute the projection. More...
 
std::pair< long, long > memoryUsage (const TABLE< GUM_SCALAR > &table, const Set< const DiscreteVariable * > &del_vars) const
 Returns the memory consumption used during the projection. More...
 
std::pair< long, long > memoryUsage (const Sequence< const DiscreteVariable * > &vars, const Set< const DiscreteVariable * > &del_vars) const
 Returns the memory consumption used during the projection. More...
 

Protected Attributes

TABLE< GUM_SCALAR > *(* proj_ )(const TABLE< GUM_SCALAR > &, const Set< const DiscreteVariable * > &)
 The projection function actually used. More...
 

Detailed Description

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

A generic class to project efficiently a MultiDim table over a subset of its variables.

MultiDimProjection is a generic wrapper designed to project efficiently a multidimensional object over a subset of its variables.

By multidimensional objects, we mean of course MultiDimImplementations, but also more complex objects such as, for instance, pairs of MultiDimImplementations 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.

To be quite generic, the MultiDimProjection takes in argument the function that produces the result of the projection of the multidimensional object. The following code gives an example of the usage of MultiDimProjection:

// a function used to project a Potential<float>:
Potential<float>* MinPot ( const Potential<float>& table,
const Set<const DiscreteVariable*>& del_vars ) {
return new Potential<float> (...);
}
// another function used to project a Potential<float>:
Potential<float>* MaxPot ( const Potential<float>& table,
const Set<const DiscreteVariable*>& del_vars ) {
return new Potential<float> (...);
}
Potential<float> t1, t2;
Set<const DiscreteVariable*> set1, set2;
MultiDimProjectionDefault<float,Potential> Proj ( MinPot );
Potential<float>* projected_table = Proj.project ( t1, set1 );
// change the operator to apply
Proj.setProjectFunction ( MaxPot );
Potential<float>* projected_table2 = Proj.project ( t2, set2 );

Definition at line 88 of file multiDimProjection.h.

Constructor & Destructor Documentation

◆ MultiDimProjection() [1/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
gum::MultiDimProjection< GUM_SCALAR, TABLE >::MultiDimProjection ( TABLE< GUM_SCALAR > *(*)(const TABLE< GUM_SCALAR > &, const Set< const DiscreteVariable * > &)  proj)

Default constructor.

◆ MultiDimProjection() [2/2]

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

Copy constructor.

◆ ~MultiDimProjection()

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

Destructor.

Member Function Documentation

◆ memoryUsage() [1/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
std::pair< long, long > gum::MultiDimProjection< GUM_SCALAR, TABLE >::memoryUsage ( const TABLE< GUM_SCALAR > &  table,
const Set< const DiscreteVariable * > &  del_vars 
) const

Returns the memory consumption used during the projection.

Actually, this function does not return a precise account of the memory used by the multidimProjection but a rough estimate based on the size of the table involved in the projection.

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 )

◆ memoryUsage() [2/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
std::pair< long, long > gum::MultiDimProjection< GUM_SCALAR, TABLE >::memoryUsage ( const Sequence< const DiscreteVariable * > &  vars,
const Set< const DiscreteVariable * > &  del_vars 
) const

Returns the memory consumption used during the projection.

Actually, this function does not return a precise account of the memory used by the multidimProjection but a rough estimate based on the size of the table involved in the projection.

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 )

◆ nbOperations() [1/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
float gum::MultiDimProjection< GUM_SCALAR, TABLE >::nbOperations ( const TABLE< GUM_SCALAR > &  table,
const Set< const DiscreteVariable * > &  del_vars 
) const

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

◆ nbOperations() [2/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
float gum::MultiDimProjection< GUM_SCALAR, TABLE >::nbOperations ( const Sequence< const DiscreteVariable * > &  vars,
const Set< const DiscreteVariable * > &  del_vars 
) const

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

◆ newFactory()

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

virtual constructor

Returns
a new fresh MultiDimCombinator with the same projection function.

◆ operator=()

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

Forbid copy operators.

◆ project() [1/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
TABLE< GUM_SCALAR >* gum::MultiDimProjection< GUM_SCALAR, TABLE >::project ( const TABLE< GUM_SCALAR > &  table,
const Set< const DiscreteVariable * > &  del_vars 
)

Creates and returns the projection of the table over a subset of its vars.

Returns
A new freshly created TABLE which is the result of the projection of the TABLE passed in argument over the set of variables NOT IN del_vars
Warning
If del_vars is precisely equal to the variables of table, the result is an empty table.

◆ project() [2/2]

template<typename GUM_SCALAR , template< typename > class TABLE>
void gum::MultiDimProjection< GUM_SCALAR, TABLE >::project ( TABLE< GUM_SCALAR > &  container,
const TABLE< GUM_SCALAR > &  table,
const Set< const TABLE< GUM_SCALAR > * > &  del_vars 
)

Creates and returns the projection of the table over a subset of its vars.

Returns
A new freshly created TABLE which is the result of the projection of the TABLE passed in argument over the set of variables NOT IN del_vars
Warning
If del_vars is precisely equal to the variables of table, the result is an empty table.

◆ projectFunction()

template<typename GUM_SCALAR , template< typename > class TABLE>
TABLE< GUM_SCALAR >*(*)(const TABLE< GUM_SCALAR >&, const Set< const DiscreteVariable* >&) gum::MultiDimProjection< GUM_SCALAR, TABLE >::projectFunction ( )

Returns the projection function currently used by the projector.

◆ setProjectFunction()

template<typename GUM_SCALAR , template< typename > class TABLE>
void gum::MultiDimProjection< GUM_SCALAR, TABLE >::setProjectFunction ( TABLE< GUM_SCALAR > *(*)(const TABLE< GUM_SCALAR > &, const Set< const DiscreteVariable * > &)  proj)

Changes the function used for projecting TABLES.

Member Data Documentation

◆ proj_

template<typename GUM_SCALAR , template< typename > class TABLE>
TABLE< GUM_SCALAR >*(* gum::MultiDimProjection< GUM_SCALAR, TABLE >::proj_) (const TABLE< GUM_SCALAR > &, const Set< const DiscreteVariable *> &)
protected

The projection function actually used.

Definition at line 193 of file multiDimProjection.h.


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