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

a Projection operator class used for scheduling inferences More...

#include <agrum/graphicalModels/inference/scheduleProjection.h>

Inheritance diagram for gum::ScheduleProjection< TABLE >:
Collaboration diagram for gum::ScheduleProjection< TABLE >:

Public Member Functions

Constructors / Destructors
 ScheduleProjection (const ScheduleMultiDim< TABLE > &table, const gum::VariableSet &del_vars, TABLE(*project)(const TABLE &, const gum::VariableSet &), const bool is_result_persistent=false)
 default constructor
 ScheduleProjection (const ScheduleProjection< TABLE > &from)
 copy constructor
 ScheduleProjection (ScheduleProjection< TABLE > &&from)
 move constructor
ScheduleProjection< TABLE > * clone () const final
 virtual copy constructor
virtual ~ScheduleProjection ()
 destructor
Operators
ScheduleProjection< TABLE > & operator= (const ScheduleProjection< TABLE > &)
 copy operator
ScheduleProjection< TABLE > & operator= (ScheduleProjection< TABLE > &&)
 move operator
bool operator== (const ScheduleOperator &) const final
 operator ==
bool operator!= (const ScheduleOperator &) const final
 operator !=
virtual bool operator== (const ScheduleProjection< TABLE > &) const
 operator ==
virtual bool operator!= (const ScheduleProjection< TABLE > &) const
 operator !=
Accessors/Modifiers
bool hasSameArguments (const ScheduleOperator &) const final
 checks whether two ScheduleProjection have the same parameters (same variables, including the set of variables to delete, and same content)
bool hasSameArguments (const ScheduleProjection< TABLE > &) const
 checks whether two ScheduleProjection have the same parameters (same variables, including the set of variables to delete, and same content)
bool hasSimilarArguments (const ScheduleOperator &) const final
 checks whether two ScheduleProjection have similar parameters (same variables, including the set of variables to delete)
bool hasSimilarArguments (const ScheduleProjection< TABLE > &) const
 checks whether two ScheduleProjection have similar parameters (same variables, including the set of variables to delete)
bool isSameOperator (const ScheduleOperator &) const final
 checks whether two ScheduleOperator perform the same projection
bool isSameOperator (const ScheduleProjection< TABLE > &) const
 checks whether two ScheduleOperator perform the same projection
const ScheduleMultiDim< TABLE > & arg () const
 returns the argument of the projection
const Sequence< const IScheduleMultiDim * > & args () const final
 returns the sequence of arguments passed to the operator
const ScheduleMultiDim< TABLE > & result () const
 returns the result of the projection
const Sequence< const IScheduleMultiDim * > & results () const final
 returns the sequence of ScheduleMultidim output by the operator
void updateArgs (const Sequence< const IScheduleMultiDim * > &new_args) final
 modifies the arguments of the operator
bool isExecuted () const final
 indicates whether the operator has been executed
void execute () final
 executes the operator
void undo () final
 undo a previous execution, if any
double nbOperations () const final
 returns an estimation of the number of elementary operations needed to perform the ScheduleOperator
std::pair< double, doublememoryUsage () const final
 returns the memory consumption used during the execution of the operator
std::string toString () const final
 displays the content of the operator
void setProjectionFunction (TABLE(*project)(const TABLE &, const gum::VariableSet &))
 use a new projection function
Accessors/Modifiers
ScheduleOperatorType type () const
 returns the type of the operator
bool implyDeletion () const
 indicates whether the operator deletes some of its arguments
void makeResultsPersistent (const bool is_persistent)
 makes the results of the operator persistent or not
bool hasPersistentResults () const
 shows whether the operator has persistent results

Private Attributes

const ScheduleMultiDim< TABLE > * _arg_ {nullptr}
 the argument to be projected
Sequence< const IScheduleMultiDim * > _args_
 the sequence of arguments passed to the operator
ScheduleMultiDim< TABLE > * _result_ {nullptr}
 the result of the projection
Sequence< const IScheduleMultiDim * > _results_
 the sequence of ScheduleMultidim output by the operator
gum::VariableSet _del_vars_
 the set of variables that should be removed from the arg table
TABLE(* _project_ )(const TABLE &, const gum::VariableSet &)
 the projection operator
ScheduleOperatorType _op_type_
 the name of the operator to perform
bool _imply_deletion_
 indicates whether the operator will delete some of the ScheduleMultiDim passed as its arguments
bool _result_persistent_
 is the result persistent

Detailed Description

template<typename TABLE>
class gum::ScheduleProjection< TABLE >

a Projection operator class used for scheduling inferences

ScheduleProjection is a generic wrapper designed to project efficiently a ScheduleMultiDim objects over a subset of its variables.

To be quite generic, the ScheduleProjection takes in argument the function that produces the result of the projection of the object contained inside the ScheduleMultiDim. Note that executing a ScheduleProjection will always produce a freshly allocated table. The following code gives an example of the usage of ScheduleProjection:

// two functions used to project a Tensor<float>:
Tensor<float> MinPot ( const Tensor<float>& table,
const VariableSet& del_vars ) {
return Tensor<float> (...);
}
Tensor<float> MaxPot ( const Tensor<float>& table,
const VariableSet& del_vars ) {
return Tensor<float> (...);
}
ScheduleMultiDim< Tensor< float > > t1(...), t2(...);
VariableSet set1, set2;
ScheduleProjection< Tensor<float> > proj1 ( t1, set1, MinPot );
proj1.execute();
ScheduleProjection< Tensor<float> > proj2 ( proj1.result(), set1, MaxPot );
// change the operator to apply
proj1.setProjectionFunction ( MaxPot );
ScheduleTensor< Tensor<float> > proj_table2 = proj1.result();
ScheduleProjection(const ScheduleMultiDim< TABLE > &table, const gum::VariableSet &del_vars, TABLE(*project)(const TABLE &, const gum::VariableSet &), const bool is_result_persistent=false)
default constructor
aGrUM's Tensor is a multi-dimensional array with tensor operators.
Definition tensor.h:85
Set< const DiscreteVariable * > VariableSet

Definition at line 103 of file scheduleProjection.h.

Constructor & Destructor Documentation

◆ ScheduleProjection() [1/3]

template<typename TABLE>
gum::ScheduleProjection< TABLE >::ScheduleProjection ( const ScheduleMultiDim< TABLE > & table,
const gum::VariableSet & del_vars,
TABLE(* project )(const TABLE &, const gum::VariableSet &),
const bool is_result_persistent = false )
explicit

default constructor

Parameters
tablethe ScheduleMultiDim containing the table that will be projected
del_varsthe set of variables that will be removed from table. Note that variables in del_vars that do not belong to table are simply not taken into account. They do not raise any exception.
projectthe function that will actually perform the projection
is_result_persistentthis boolean indicates whether the result of the projection is persistent, i.e., whether it should be kept in memory when the operator itself is deleted from memory.
Warning
table is stored only by reference within the ScheduleProjection. But the set of variables to remove (del_vars) is stored by copy within the ScheduleProjection

Referenced by ScheduleProjection(), ScheduleProjection(), ~ScheduleProjection(), clone(), hasSameArguments(), hasSimilarArguments(), isSameOperator(), operator!=(), operator=(), operator=(), and operator==().

Here is the caller graph for this function:

◆ ScheduleProjection() [2/3]

template<typename TABLE>
gum::ScheduleProjection< TABLE >::ScheduleProjection ( const ScheduleProjection< TABLE > & from)

copy constructor

References ScheduleProjection().

Here is the call graph for this function:

◆ ScheduleProjection() [3/3]

template<typename TABLE>
gum::ScheduleProjection< TABLE >::ScheduleProjection ( ScheduleProjection< TABLE > && from)

move constructor

References ScheduleProjection().

Here is the call graph for this function:

◆ ~ScheduleProjection()

template<typename TABLE>
virtual gum::ScheduleProjection< TABLE >::~ScheduleProjection ( )
virtual

destructor

Warning
If the ScheduleProjection has created some output ScheduleTensor, upon destruction, it is removed from memory

References ScheduleProjection().

Here is the call graph for this function:

Member Function Documentation

◆ arg()

template<typename TABLE>
const ScheduleMultiDim< TABLE > & gum::ScheduleProjection< TABLE >::arg ( ) const

returns the argument of the projection

References arg().

Referenced by arg().

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

◆ args()

template<typename TABLE>
const Sequence< const IScheduleMultiDim * > & gum::ScheduleProjection< TABLE >::args ( ) const
finalvirtual

returns the sequence of arguments passed to the operator

Implements gum::ScheduleOperator.

References args().

Referenced by args().

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

◆ clone()

template<typename TABLE>
ScheduleProjection< TABLE > * gum::ScheduleProjection< TABLE >::clone ( ) const
finalvirtual

virtual copy constructor

Implements gum::ScheduleOperator.

References ScheduleProjection().

Here is the call graph for this function:

◆ execute()

template<typename TABLE>
void gum::ScheduleProjection< TABLE >::execute ( )
finalvirtual

executes the operator

This method guarantees that the result of the combination is a stored into a newly allocated table

Implements gum::ScheduleOperator.

References execute().

Referenced by execute().

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

◆ hasPersistentResults()

bool gum::ScheduleOperator::hasPersistentResults ( ) const
inherited

shows whether the operator has persistent results

◆ hasSameArguments() [1/2]

template<typename TABLE>
bool gum::ScheduleProjection< TABLE >::hasSameArguments ( const ScheduleOperator & ) const
finalvirtual

checks whether two ScheduleProjection have the same parameters (same variables, including the set of variables to delete, and same content)

ScheduleMultiDim Parameters having the same variables and the same content are essentially identical but they may have different Ids (so that they may not be ==).

Implements gum::ScheduleOperator.

References gum::ScheduleOperator::ScheduleOperator(), and hasSameArguments().

Referenced by hasSameArguments(), and hasSameArguments().

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

◆ hasSameArguments() [2/2]

template<typename TABLE>
bool gum::ScheduleProjection< TABLE >::hasSameArguments ( const ScheduleProjection< TABLE > & ) const

checks whether two ScheduleProjection have the same parameters (same variables, including the set of variables to delete, and same content)

ScheduleMultiDim Parameters having the same variables and the same content are essentially identical but they may have different Ids (so that they may not be ==).

References ScheduleProjection(), and hasSameArguments().

Here is the call graph for this function:

◆ hasSimilarArguments() [1/2]

template<typename TABLE>
bool gum::ScheduleProjection< TABLE >::hasSimilarArguments ( const ScheduleOperator & ) const
finalvirtual

checks whether two ScheduleProjection have similar parameters (same variables, including the set of variables to delete)

ScheduleMultiDim Parameters having the same variables and the same content are essentially identical but they may have different Ids (so that they may not be ==).

Implements gum::ScheduleOperator.

References gum::ScheduleOperator::ScheduleOperator(), and hasSimilarArguments().

Referenced by hasSimilarArguments(), and hasSimilarArguments().

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

◆ hasSimilarArguments() [2/2]

template<typename TABLE>
bool gum::ScheduleProjection< TABLE >::hasSimilarArguments ( const ScheduleProjection< TABLE > & ) const

checks whether two ScheduleProjection have similar parameters (same variables, including the set of variables to delete)

ScheduleMultiDim Parameters having the same variables and the same content are essentially identical but they may have different Ids (so that they may not be ==).

References ScheduleProjection(), and hasSimilarArguments().

Here is the call graph for this function:

◆ implyDeletion()

bool gum::ScheduleOperator::implyDeletion ( ) const
inherited

indicates whether the operator deletes some of its arguments

◆ isExecuted()

template<typename TABLE>
bool gum::ScheduleProjection< TABLE >::isExecuted ( ) const
finalvirtual

indicates whether the operator has been executed

Implements gum::ScheduleOperator.

References isExecuted().

Referenced by isExecuted().

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

◆ isSameOperator() [1/2]

template<typename TABLE>
bool gum::ScheduleProjection< TABLE >::isSameOperator ( const ScheduleOperator & ) const
finalvirtual

checks whether two ScheduleOperator perform the same projection

Reimplemented from gum::ScheduleOperator.

References gum::ScheduleOperator::ScheduleOperator(), and isSameOperator().

Referenced by isSameOperator(), and isSameOperator().

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

◆ isSameOperator() [2/2]

template<typename TABLE>
bool gum::ScheduleProjection< TABLE >::isSameOperator ( const ScheduleProjection< TABLE > & ) const

checks whether two ScheduleOperator perform the same projection

References ScheduleProjection(), and isSameOperator().

Here is the call graph for this function:

◆ makeResultsPersistent()

void gum::ScheduleOperator::makeResultsPersistent ( const bool is_persistent)
inherited

makes the results of the operator persistent or not

Unlike non-persistent results, a persistent one is not destroyed when the operator itself is destroyed

◆ memoryUsage()

template<typename TABLE>
std::pair< double, double > gum::ScheduleProjection< TABLE >::memoryUsage ( ) const
finalvirtual

returns the memory consumption used during the execution of the operator

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

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

Implements gum::ScheduleOperator.

References memoryUsage().

Referenced by memoryUsage().

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

◆ nbOperations()

template<typename TABLE>
double gum::ScheduleProjection< TABLE >::nbOperations ( ) const
finalvirtual

returns an estimation of the number of elementary operations needed to perform the ScheduleOperator

Implements gum::ScheduleOperator.

References nbOperations().

Referenced by nbOperations().

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

◆ operator!=() [1/2]

template<typename TABLE>
bool gum::ScheduleProjection< TABLE >::operator!= ( const ScheduleOperator & ) const
finalvirtual

operator !=

Two operators are different if and only if they either have different (!=) ScheduleMultiDim arguments or they have different sets of variables to project on, or they perform different operations (e.g., one performs a max projection and the other a min projection). Different ScheduleMultiDim arguments means that the latter differ by their Ids.

Reimplemented from gum::ScheduleOperator.

References gum::ScheduleOperator::ScheduleOperator().

Here is the call graph for this function:

◆ operator!=() [2/2]

template<typename TABLE>
virtual bool gum::ScheduleProjection< TABLE >::operator!= ( const ScheduleProjection< TABLE > & ) const
virtual

operator !=

Two operators are different if and only if they either have different (!=) ScheduleMultiDim arguments or they have different sets of variables to project on, or they perform different operations (e.g., one performs a max projection and the other a min projection). Different ScheduleMultiDim arguments means that the latter differ by their Ids.

References ScheduleProjection().

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename TABLE>
ScheduleProjection< TABLE > & gum::ScheduleProjection< TABLE >::operator= ( const ScheduleProjection< TABLE > & )

copy operator

References ScheduleProjection().

Here is the call graph for this function:

◆ operator=() [2/2]

template<typename TABLE>
ScheduleProjection< TABLE > & gum::ScheduleProjection< TABLE >::operator= ( ScheduleProjection< TABLE > && )

move operator

References ScheduleProjection().

Here is the call graph for this function:

◆ operator==() [1/2]

template<typename TABLE>
bool gum::ScheduleProjection< TABLE >::operator== ( const ScheduleOperator & ) const
finalvirtual

operator ==

Two operators are identical if and only if they have equal (==) ScheduleMultiDim arguments, the same set of variables to project on, and they perform exactly the same set of operations (e.g., both perform a max projection). By Equal arguments, we stress that we mean that these ScheduleMultiDims have the same IDs

Reimplemented from gum::ScheduleOperator.

References gum::ScheduleOperator::ScheduleOperator().

Here is the call graph for this function:

◆ operator==() [2/2]

template<typename TABLE>
virtual bool gum::ScheduleProjection< TABLE >::operator== ( const ScheduleProjection< TABLE > & ) const
virtual

operator ==

Two operators are identical if and only if they have equal (==) ScheduleMultiDim arguments, the same set of variables to project on, and they perform exactly the same set of operations (e.g., both perform a max projection). By Equal arguments, we mean that these ScheduleMultiDims have the same IDs

References ScheduleProjection().

Here is the call graph for this function:

◆ result()

template<typename TABLE>
const ScheduleMultiDim< TABLE > & gum::ScheduleProjection< TABLE >::result ( ) const

returns the result of the projection

References result().

Referenced by result().

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

◆ results()

template<typename TABLE>
const Sequence< const IScheduleMultiDim * > & gum::ScheduleProjection< TABLE >::results ( ) const
finalvirtual

returns the sequence of ScheduleMultidim output by the operator

Implements gum::ScheduleOperator.

References results().

Referenced by results().

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

◆ setProjectionFunction()

template<typename TABLE>
void gum::ScheduleProjection< TABLE >::setProjectionFunction ( TABLE(* project )(const TABLE &, const gum::VariableSet &))

use a new projection function

References setProjectionFunction().

Referenced by setProjectionFunction().

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

◆ toString()

template<typename TABLE>
std::string gum::ScheduleProjection< TABLE >::toString ( ) const
finalvirtual

displays the content of the operator

Implements gum::ScheduleOperator.

References toString().

Referenced by toString().

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

◆ type()

ScheduleOperatorType gum::ScheduleOperator::type ( ) const
inherited

returns the type of the operator

Referenced by ScheduleOperator().

Here is the caller graph for this function:

◆ undo()

template<typename TABLE>
void gum::ScheduleProjection< TABLE >::undo ( )
finalvirtual

undo a previous execution, if any

Implements gum::ScheduleOperator.

References undo().

Referenced by undo().

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

◆ updateArgs()

template<typename TABLE>
void gum::ScheduleProjection< TABLE >::updateArgs ( const Sequence< const IScheduleMultiDim * > & new_args)
finalvirtual

modifies the arguments of the operator

Exceptions
SizeErroris raised if the number of elements in new_args does not correspond to the number of arguments expected by the ScheduleOperator.
TypeErroris raised if at least one element of new_args does not have a type compatible with what the ScheduleOperator expects.

Implements gum::ScheduleOperator.

References updateArgs().

Referenced by updateArgs().

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

Member Data Documentation

◆ _arg_

template<typename TABLE>
const ScheduleMultiDim< TABLE >* gum::ScheduleProjection< TABLE >::_arg_ {nullptr}
private

the argument to be projected

Definition at line 294 of file scheduleProjection.h.

294{nullptr};

◆ _args_

template<typename TABLE>
Sequence< const IScheduleMultiDim* > gum::ScheduleProjection< TABLE >::_args_
private

the sequence of arguments passed to the operator

This method is convenient when using ScheduleOperator rather than directly using ScheduleBinaryCombination

Definition at line 299 of file scheduleProjection.h.

◆ _del_vars_

template<typename TABLE>
gum::VariableSet gum::ScheduleProjection< TABLE >::_del_vars_
private

the set of variables that should be removed from the arg table

Definition at line 312 of file scheduleProjection.h.

◆ _imply_deletion_

bool gum::ScheduleOperator::_imply_deletion_
privateinherited

indicates whether the operator will delete some of the ScheduleMultiDim passed as its arguments

Definition at line 246 of file scheduleOperator.h.

◆ _op_type_

ScheduleOperatorType gum::ScheduleOperator::_op_type_
privateinherited

the name of the operator to perform

Definition at line 242 of file scheduleOperator.h.

◆ _project_

template<typename TABLE>
TABLE(* gum::ScheduleProjection< TABLE >::_project_) (const TABLE &, const gum::VariableSet &)
private

the projection operator

Definition at line 315 of file scheduleProjection.h.

◆ _result_

template<typename TABLE>
ScheduleMultiDim< TABLE >* gum::ScheduleProjection< TABLE >::_result_ {nullptr}
private

the result of the projection

Definition at line 302 of file scheduleProjection.h.

302{nullptr};

◆ _result_persistent_

bool gum::ScheduleOperator::_result_persistent_
privateinherited

is the result persistent

Definition at line 249 of file scheduleOperator.h.

◆ _results_

template<typename TABLE>
Sequence< const IScheduleMultiDim* > gum::ScheduleProjection< TABLE >::_results_
private

the sequence of ScheduleMultidim output by the operator

Warning
Note that the Operator has always some output, even if it has not been executed. In this case, the outputs are abstract ScheduleMultiDim.

Definition at line 309 of file scheduleProjection.h.


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