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

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

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

Collaboration diagram for gum::MultiDimProjection< TABLE >:

Public Types

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

Public Member Functions

Constructors / Destructors
 MultiDimProjection (TABLE(*proj)(const TABLE &, const gum::VariableSet &))
 Default constructor.
 MultiDimProjection (const MultiDimProjection< TABLE > &)
 Copy constructor.
virtual ~MultiDimProjection ()
 Destructor.
virtual MultiDimProjection< TABLE > * clone () const
 virtual constructor

Protected Attributes

TABLE(* proj_ )(const TABLE &, const gum::VariableSet &)
 The projection function actually used.

Private Member Functions

MultiDimProjection< TABLE > & operator= (const MultiDimProjection< TABLE > &)
 Forbid copy operators.

Accessors/Modifiers

TABLE(*)(const TABLE &, const gum::VariableSet &) projectionFunction ()
 Returns the projection function currently used by the projector.
TABLE * execute (const TABLE &table, const gum::VariableSet &del_vars) const
 Creates and returns the projection of the table over a subset of its vars.
void execute (TABLE &container, const TABLE &table, const gum::VariableSet &del_vars) const
 Returns the projection function currently used by the projector.
std::pair< ScheduleOperator *, const IScheduleMultiDim * > operations (const IScheduleMultiDim *table, const gum::VariableSet &del_vars, const bool is_result_persistent=false) const
 returns operation to perform as well as the result of the projection
const IScheduleMultiDimschedule (Schedule &schedule, const IScheduleMultiDim *table, const gum::VariableSet &del_vars, const bool is_result_persistent=false) const
 add to a given schedule the set of operations needed to perform the projection
void setProjectionFunction (TABLE(*proj)(const TABLE &, const gum::VariableSet &))
 Changes the function used for projecting TABLES.
double nbOperations (const TABLE &table, const gum::VariableSet &del_vars) const
 returns a rough estimate of the number of operations that will be performed to compute the projection.
double nbOperations (const Sequence< const DiscreteVariable * > &vars, const gum::VariableSet &del_vars) const
 returns a rough estimate of the number of operations that will be performed to compute the projection.
std::pair< double, doublememoryUsage (const TABLE &table, const gum::VariableSet &del_vars) const
 Returns the memory consumption used during the projection.
std::pair< double, doublememoryUsage (const Sequence< const DiscreteVariable * > &vars, const gum::VariableSet &del_vars) const
 Returns the memory consumption used during the projection.

Detailed Description

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

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,Tensor) 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 Tensor<float>:
Tensor<float> MinPot ( const Tensor<float>& table,
const VariableSet& del_vars ) {
return Tensor<float> (...);
}
// another function used to project a Tensor<float>:
Tensor<float> MaxPot ( const Tensor<float>& table,
const VariableSet& del_vars ) {
return Tensor<float> (...);
}
Tensor<float> t1, t2;
VariableSet set1, set2;
MultiDimProjectionDefault< Tensor< float > > Proj ( MinPot );
Tensor<float>* projected_table = Proj.project ( t1, set1 );
// change the operator to apply
Proj.setProjectionFunction ( MaxPot );
Tensor<float>* projected_table2 = Proj.project ( t2, set2 );
aGrUM's Tensor is a multi-dimensional array with tensor operators.
Definition tensor.h:85
Set< const DiscreteVariable * > VariableSet

Definition at line 109 of file multiDimProjection.h.

Member Typedef Documentation

◆ value_type

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

the type of the values contained into TABLE

Definition at line 125 of file multiDimProjection.h.

Constructor & Destructor Documentation

◆ MultiDimProjection() [1/2]

template<class TABLE>
gum::MultiDimProjection< TABLE >::MultiDimProjection ( TABLE(* proj )(const TABLE &, const gum::VariableSet &))

Default constructor.

Referenced by MultiDimProjection(), clone(), and operator=().

Here is the caller graph for this function:

◆ MultiDimProjection() [2/2]

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

Copy constructor.

References MultiDimProjection().

Here is the call graph for this function:

◆ ~MultiDimProjection()

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

Destructor.

Member Function Documentation

◆ clone()

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

virtual constructor

Returns
a new fresh MultiDimCombinator with the same projection function.

References MultiDimProjection().

Here is the call graph for this function:

◆ execute() [1/2]

template<class TABLE>
TABLE * gum::MultiDimProjection< TABLE >::execute ( const TABLE & table,
const gum::VariableSet & del_vars ) const

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.

◆ execute() [2/2]

template<class TABLE>
void gum::MultiDimProjection< TABLE >::execute ( TABLE & container,
const TABLE & table,
const gum::VariableSet & del_vars ) const

Returns the projection function currently used by the projector.

◆ memoryUsage() [1/2]

template<class TABLE>
std::pair< double, double > gum::MultiDimProjection< TABLE >::memoryUsage ( const Sequence< const DiscreteVariable * > & vars,
const gum::VariableSet & 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<class TABLE>
std::pair< double, double > gum::MultiDimProjection< TABLE >::memoryUsage ( const TABLE & table,
const gum::VariableSet & 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<class TABLE>
double gum::MultiDimProjection< TABLE >::nbOperations ( const Sequence< const DiscreteVariable * > & vars,
const gum::VariableSet & del_vars ) const

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

◆ nbOperations() [2/2]

template<class TABLE>
double gum::MultiDimProjection< TABLE >::nbOperations ( const TABLE & table,
const gum::VariableSet & del_vars ) const

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

◆ operations()

template<class TABLE>
std::pair< ScheduleOperator *, const IScheduleMultiDim * > gum::MultiDimProjection< TABLE >::operations ( const IScheduleMultiDim * table,
const gum::VariableSet & del_vars,
const bool is_result_persistent = false ) const

returns operation to perform as well as the result of the projection

Warning
MultiDimProjections always produce a new freshly allocated resulting table

◆ operator=()

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

Forbid copy operators.

References MultiDimProjection().

Here is the call graph for this function:

◆ schedule()

template<class TABLE>
const IScheduleMultiDim * gum::MultiDimProjection< TABLE >::schedule ( Schedule & schedule,
const IScheduleMultiDim * table,
const gum::VariableSet & del_vars,
const bool is_result_persistent = false ) const

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

Parameters
schedulethe schedule to which we add the new projection
tablethe table which is projected
del_varsthe set of variables to remove from the table
is_result_persistentthis boolean indicates whether the result of the projection is persistent, i.e., whether it should be kept in memory when the operation itself is deleted from memory.
Returns
the IScheduleMultiDim resulting from the projection
Warning
MultiDimProjections always produce a new freshly allocated resulting table

References schedule().

Referenced by schedule().

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

◆ setProjectionFunction()

template<class TABLE>
void gum::MultiDimProjection< TABLE >::setProjectionFunction ( TABLE(* proj )(const TABLE &, const gum::VariableSet &))

Changes the function used for projecting TABLES.

Member Data Documentation

◆ proj_

template<class TABLE>
TABLE(* gum::MultiDimProjection< TABLE >::proj_) (const TABLE &, const gum::VariableSet &)
protected

The projection function actually used.

Definition at line 248 of file multiDimProjection.h.

◆ projectionFunction

template<class TABLE>
TABLE(*)(const TABLE &, const gum::VariableSet &) gum::MultiDimProjection< TABLE >::projectionFunction()

Returns the projection function currently used by the projector.

Definition at line 199 of file multiDimProjection.h.


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