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

a MultiDimImplementation Wrapper used for scheduling inferences More...

#include <scheduleMultiDim.h>

Public Member Functions

Constructors / Destructors
 ScheduleMultiDim (const MultiDimImplementation< GUM_SCALAR > &)
 constructs a ScheduleMultiDim containing an already built implementation More...
 
 ScheduleMultiDim (const MultiDimDecorator< GUM_SCALAR > &)
 constructs a ScheduleMultiDim containing an already built implementation More...
 
 ScheduleMultiDim (const Sequence< const DiscreteVariable * > &vars)
 construct a ScheduleMultiDim for an implementation yet to be built More...
 
 ScheduleMultiDim (const ScheduleMultiDim< GUM_SCALAR > &)
 copy constructor More...
 
 ~ScheduleMultiDim ()
 destructor More...
 
Operators
ScheduleMultiDim< GUM_SCALAR > & operator= (const ScheduleMultiDim< GUM_SCALAR > &)
 copy operator More...
 
bool operator== (const ScheduleMultiDim< GUM_SCALAR > &) const
 checks whether two ScheduleMultiDim are related to the same table More...
 
bool operator!= (const ScheduleMultiDim< GUM_SCALAR > &) const
 checks whether two ScheduleMultiDim are related to different tables More...
 
Accessors/Modifiers
bool isAbstract () const
 returns whether the ScheduleMultiDim contains a real multiDimImplementation More...
 
const MultiDimImplementation< GUM_SCALAR > & multiDim () const
 returns the multiDimImplementation actually contained in the ScheduleMultiDim More...
 
Idx id () const
 returns the id of the ScheduleMultiDim More...
 
const Sequence< const DiscreteVariable *> & variablesSequence () const
 returns the set of variables involved in the multidim More...
 
Size domainSize () const
 returns the domain size of the multidim More...
 
void setMultiDim (const MultiDimImplementation< GUM_SCALAR > &)
 sets a new multiDimImplementation inside the wrapper More...
 
void setMultiDim (const MultiDimDecorator< GUM_SCALAR > &)
 sets a new multiDimDecorator inside the wrapper More...
 
std::string toString () const
 displays the content of the multidim More...
 

Friends

class ScheduleDeleteMultiDim< GUM_SCALAR >
 grant accesses to ScheduleDeleteMultiDim More...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::ScheduleMultiDim< GUM_SCALAR >

a MultiDimImplementation Wrapper used for scheduling inferences

A ScheduleMultiDim is a wrapper that contains either a "real" multidim table or an Id that indicates that the multidim table that should be contained has not been computed yet (by the scheduler). This Id enables the scheduler to know which is the operation the result of which will be the multidim table that will eventually be contained in the ScheduleMultiDim. Here is a brief piece of code that should highlight the concept:

// some arbitrary potentials (to be initialized before going on)
gum::Potential<float> pot1, pot2, pot3;
// we wish to schedule ( pot1 + pot2 ) + pot3
// so, first, create ScheduleMultiDims for wrapping these potentials
gum::ScheduleMultiDim<float> f1 ( pot1 ), f2 ( pot2 ), f3 ( pot3 );
// now schedule a combination (+) between f1 and f2
gum::ScheduleCombine<float> comb1 ( &f1, &f2, add );
// get the result and schedule it with f3
const ScheduleMultiDim<float>& result1 = comb1.result ();
gum::ScheduleCombine<float> comb2 ( &result2, &f3,add );
// get the resulting ScheduleMultiDim
const ScheduleMultiDim<float>& result2 = comb2.result ();
// here, no addition has been performed yet. We just have a structure
// that indicates which operations we wish to do. So, for the moment,
// result1 and result2 do not contain real multidim tables but just ids.
// As such, they are called abstract and trying to get their "real"
// multiDim table (using method multiDim()) would throw a NotFound
*exception.
std::cout << result1.isAbstract ();
std::cout << result2.isAbstract ();
std::cout << ! f1.isAbstract ();
// now, we can actually perform the operations
comb1.execute ();
std::cout << ! result1.isAbstract ();
comb2.execute ();
// here, we can display the content of the real multidim table stored
// into result2
std::cout << result2.multiDim ();

So, to summarize the key idea underlying Schedule* classes: these classes encapsulate operations to perform and multidim tables that should be passed as argument to these operations. But nothing is actually computed until the execute() methods of the scheduled operations are executed.

Definition at line 106 of file scheduleMultiDim.h.

Constructor & Destructor Documentation

◆ ScheduleMultiDim() [1/4]

template<typename GUM_SCALAR>
gum::ScheduleMultiDim< GUM_SCALAR >::ScheduleMultiDim ( const MultiDimImplementation< GUM_SCALAR > &  )
explicit

constructs a ScheduleMultiDim containing an already built implementation

◆ ScheduleMultiDim() [2/4]

template<typename GUM_SCALAR>
gum::ScheduleMultiDim< GUM_SCALAR >::ScheduleMultiDim ( const MultiDimDecorator< GUM_SCALAR > &  )
explicit

constructs a ScheduleMultiDim containing an already built implementation

◆ ScheduleMultiDim() [3/4]

template<typename GUM_SCALAR>
gum::ScheduleMultiDim< GUM_SCALAR >::ScheduleMultiDim ( const Sequence< const DiscreteVariable * > &  vars)
explicit

construct a ScheduleMultiDim for an implementation yet to be built

The ScheduleMultiDim created is abstract, i.e., it does not contain a proper MultiDimImplementation yet. However, the variables of the latter need be known to optimize inference processes

Warning
the sequence of variables is copied into the wrapper.

◆ ScheduleMultiDim() [4/4]

template<typename GUM_SCALAR>
gum::ScheduleMultiDim< GUM_SCALAR >::ScheduleMultiDim ( const ScheduleMultiDim< GUM_SCALAR > &  )

copy constructor

◆ ~ScheduleMultiDim()

template<typename GUM_SCALAR>
gum::ScheduleMultiDim< GUM_SCALAR >::~ScheduleMultiDim ( )

destructor

Member Function Documentation

◆ _id2multidim_()

template<typename GUM_SCALAR>
static HashTable< Idx, const MultiDimImplementation< GUM_SCALAR >* >& gum::ScheduleMultiDim< GUM_SCALAR >::_id2multidim_ ( )
staticprivate

returns a mapping from id to multidimImplementations

◆ _id2refs_()

template<typename GUM_SCALAR>
static HashTable< Idx, Idx >& gum::ScheduleMultiDim< GUM_SCALAR >::_id2refs_ ( )
staticprivate

returns a table indicating how many ScheduleMultiDim have the same id

◆ _id2size_()

template<typename GUM_SCALAR>
static HashTable< Idx, Size >& gum::ScheduleMultiDim< GUM_SCALAR >::_id2size_ ( )
staticprivate

returns a table with the domain size of the table corresponding to id

◆ _id2vars_()

template<typename GUM_SCALAR>
static HashTable< Idx, const Sequence< const DiscreteVariable* >* >& gum::ScheduleMultiDim< GUM_SCALAR >::_id2vars_ ( )
staticprivate

returns a table with the variables of the table corresponding to id

◆ _multidim2id_()

template<typename GUM_SCALAR>
static HashTable< const MultiDimImplementation< GUM_SCALAR >*, Idx >& gum::ScheduleMultiDim< GUM_SCALAR >::_multidim2id_ ( )
staticprivate

returns the id corresponding to a given multidim

useful to assign the same id every time a given MultiDimImplementation is wrapped into a ScheduleMultiDim

◆ _newId_()

template<typename GUM_SCALAR>
static Idx gum::ScheduleMultiDim< GUM_SCALAR >::_newId_ ( )
staticprivate

returns a new distinct ID for each abtract scheduleMultiDim

◆ domainSize()

template<typename GUM_SCALAR>
Size gum::ScheduleMultiDim< GUM_SCALAR >::domainSize ( ) const

returns the domain size of the multidim

◆ id()

template<typename GUM_SCALAR>
Idx gum::ScheduleMultiDim< GUM_SCALAR >::id ( ) const

returns the id of the ScheduleMultiDim

◆ isAbstract()

template<typename GUM_SCALAR>
bool gum::ScheduleMultiDim< GUM_SCALAR >::isAbstract ( ) const

returns whether the ScheduleMultiDim contains a real multiDimImplementation

Returns
true if the ScheduleMultiDim is abstract, i.e., it is does not actually contains a real MultiDimImplementation but rather a ID indicating that the real multiDimImplementation is yet to be created as a result of an operation on other multiDimImplementations.

◆ multiDim()

template<typename GUM_SCALAR>
const MultiDimImplementation< GUM_SCALAR >& gum::ScheduleMultiDim< GUM_SCALAR >::multiDim ( ) const

returns the multiDimImplementation actually contained in the ScheduleMultiDim

Exceptions
NotFoundexception is thrown if the multidimImplementation does not exist yet (because it has not been computed yet)

◆ operator!=()

template<typename GUM_SCALAR>
bool gum::ScheduleMultiDim< GUM_SCALAR >::operator!= ( const ScheduleMultiDim< GUM_SCALAR > &  ) const

checks whether two ScheduleMultiDim are related to different tables

◆ operator=()

template<typename GUM_SCALAR>
ScheduleMultiDim< GUM_SCALAR >& gum::ScheduleMultiDim< GUM_SCALAR >::operator= ( const ScheduleMultiDim< GUM_SCALAR > &  )

copy operator

◆ operator==()

template<typename GUM_SCALAR>
bool gum::ScheduleMultiDim< GUM_SCALAR >::operator== ( const ScheduleMultiDim< GUM_SCALAR > &  ) const

checks whether two ScheduleMultiDim are related to the same table

◆ setMultiDim() [1/2]

template<typename GUM_SCALAR>
void gum::ScheduleMultiDim< GUM_SCALAR >::setMultiDim ( const MultiDimImplementation< GUM_SCALAR > &  )

sets a new multiDimImplementation inside the wrapper

Exceptions
DuplicateElementexception is thrown if the MultiDimImplementation has already been wrapped in a ScheduleMultiDim with another id

◆ setMultiDim() [2/2]

template<typename GUM_SCALAR>
void gum::ScheduleMultiDim< GUM_SCALAR >::setMultiDim ( const MultiDimDecorator< GUM_SCALAR > &  )

sets a new multiDimDecorator inside the wrapper

Exceptions
DuplicateElementexception is thrown if the MultiDimDecorator has already been wrapped in a ScheduleMultiDim with another id

◆ toString()

template<typename GUM_SCALAR>
std::string gum::ScheduleMultiDim< GUM_SCALAR >::toString ( ) const

displays the content of the multidim

◆ variablesSequence()

template<typename GUM_SCALAR>
const Sequence< const DiscreteVariable* >& gum::ScheduleMultiDim< GUM_SCALAR >::variablesSequence ( ) const

returns the set of variables involved in the multidim

Friends And Related Function Documentation

◆ ScheduleDeleteMultiDim< GUM_SCALAR >

template<typename GUM_SCALAR>
friend class ScheduleDeleteMultiDim< GUM_SCALAR >
friend

grant accesses to ScheduleDeleteMultiDim

Definition at line 201 of file scheduleMultiDim.h.

Member Data Documentation

◆ _id_

template<typename GUM_SCALAR>
Idx gum::ScheduleMultiDim< GUM_SCALAR >::_id_
private

the unique Id of the ScheduleMultiDim

Definition at line 204 of file scheduleMultiDim.h.


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