aGrUM  0.16.0
gum::DiscretizedVariable< T_TICKS > Class Template Reference

Class for discretized random variable. More...

#include <discretizedVariable.h>

+ Inheritance diagram for gum::DiscretizedVariable< T_TICKS >:
+ Collaboration diagram for gum::DiscretizedVariable< T_TICKS >:

Public Member Functions

virtual DiscretizedVariable< T_TICKS > * clone () const
 a virtual clone More...
 
virtual VarType varType () const
 returns the type of variable More...
 
DiscretizedVariable< T_TICKS > & operator= (const DiscretizedVariable< T_TICKS > &aDRV)
 operator = More...
 
bool isTick (const T_TICKS &aTick) const
 
DiscretizedVariableaddTick (const T_TICKS &aTick)
 add a tick. More...
 
void eraseTicks ()
 erase all the Ticks More...
 
virtual std::string label (Idx i) const
 
virtual double numerical (Idx indice) const
 get a numerical representation of he indice-the value. More...
 
virtual Idx index (const std::string &label) const
 from the label to its index in var. More...
 
virtual Size domainSize () const
 
virtual const std::string domain () const
 string represent the domain of the variable More...
 
const T_TICKS & tick (Idx i) const
 from the index to the tick. More...
 
const std::vector< T_TICKS > & ticks () const
 Return the list of ticks. More...
 
virtual std::vector< doubleticksAsDoubles () const
 return the list of ticks as a vector of doubles More...
 
Idx operator[] (const std::string &label) const
 from the label to its index in var. More...
 
const std::string toString () const
 string version of *this More...
 
const std::string toStringWithDescription () const
 string version of *this using description attribute instead of name. More...
 
constructors & destructors
 DiscretizedVariable (const std::string &aName, const std::string &aDesc)
 Constructor. More...
 
 DiscretizedVariable (const std::string &aName, const std::string &aDesc, const std::vector< T_TICKS > &ticks)
 Constructor. More...
 
 DiscretizedVariable (const DiscretizedVariable< T_TICKS > &aDRV)
 Copy constructor. More...
 
virtual ~DiscretizedVariable ()
 Destructor. More...
 
Accessors / Modifiers
bool empty () const
 
std::vector< std::string > labels () const
 vector of labels More...
 
Operators
virtual bool operator== (const DiscreteVariable &aRV) const
 equality operator More...
 
virtual bool operator!= (const DiscreteVariable &aRV) const
 inequality operator More...
 
Operators
virtual bool operator== (const Variable &aRV) const
 equality operator More...
 
virtual bool operator!= (const Variable &aRV) const
 inequality operator More...
 
Accessors / Modifiers
void setName (const std::string &theValue)
 sets the name of the variable More...
 
const std::string & name () const
 returns the name of the variable More...
 
void setDescription (const std::string &theValue) const
 sets the description of the variable More...
 
const std::string & description () const
 returns the description of the variable More...
 

Protected Member Functions

void _copy (const DiscretizedVariable< T_TICKS > &aDRV)
 make a copy TODO since we removed T_OtherData maybe some changes are needed in this method? More...
 
Idx _dichotomy (const T_TICKS &target, Idx min, Idx max) const
 perform a dichotomy on ticks More...
 
Idx _pos (const T_TICKS &target) const
 seach the class of target (internally use _dichotomy) More...
 
void _copy (const Variable &aRV)
 protected copy More...
 

Detailed Description

template<typename T_TICKS>
class gum::DiscretizedVariable< T_TICKS >

Class for discretized random variable.

a DiscretizedVariable contains a vector of T_TICKS, assuming that the modalities of the variable arc [T1,T2[,[T2,T3[,...,[Tn-1,Tn]. T can be plus_infinity or minus_infinity.

operator [] has a T_TICKS argument.

Warning
DiscretizedVariable is a template but it is assumed that there is a complete order on T_TICKS.
Note that, if T_TICKS allows it, you may use std::numeric_limits<T_TICKS>::infinity() and std::numeric_limits<T_TICKS>::infinity() as tick value.
If a variable contains less than 3 ticks, it is considered as empty(). A variable with 3 ticks is binary and contains 2 ranges : [T1,T2[ (modality 0) and [T2,T3] (modality 1).
Author
Pierre-Henri WUILLEMIN et Christophe GONZALES

Definition at line 57 of file discretizedVariable.h.

Constructor & Destructor Documentation

◆ DiscretizedVariable() [1/3]

template<typename T_TICKS>
gum::DiscretizedVariable< T_TICKS >::DiscretizedVariable ( const std::string &  aName,
const std::string &  aDesc 
)

Constructor.

Parameters
aNamethe name
aDescthe description

◆ DiscretizedVariable() [2/3]

template<typename T_TICKS>
gum::DiscretizedVariable< T_TICKS >::DiscretizedVariable ( const std::string &  aName,
const std::string &  aDesc,
const std::vector< T_TICKS > &  ticks 
)

Constructor.

Parameters
aNamethe name
aDescthe description

◆ DiscretizedVariable() [3/3]

template<typename T_TICKS>
gum::DiscretizedVariable< T_TICKS >::DiscretizedVariable ( const DiscretizedVariable< T_TICKS > &  aDRV)

Copy constructor.

Parameters
aDRV

◆ ~DiscretizedVariable()

template<typename T_TICKS>
virtual gum::DiscretizedVariable< T_TICKS >::~DiscretizedVariable ( )
virtual

Destructor.

Member Function Documentation

◆ _copy() [1/2]

template<typename T_TICKS>
void gum::DiscretizedVariable< T_TICKS >::_copy ( const DiscretizedVariable< T_TICKS > &  aDRV)
protected

make a copy TODO since we removed T_OtherData maybe some changes are needed in this method?

Parameters
aDRVthe copied object

◆ _copy() [2/2]

void gum::Variable::_copy ( const Variable aRV)
protectedinherited

protected copy

Parameters
aRVto be copied

◆ _dichotomy()

template<typename T_TICKS>
Idx gum::DiscretizedVariable< T_TICKS >::_dichotomy ( const T_TICKS &  target,
Idx  min,
Idx  max 
) const
protected

perform a dichotomy on ticks

Parameters
targetT_TICKS value
minfirst index
maxlast index
Returns
either the index of target, either the index of the predecessor of target in ticks

◆ _pos()

template<typename T_TICKS>
Idx gum::DiscretizedVariable< T_TICKS >::_pos ( const T_TICKS &  target) const
protected

seach the class of target (internally use _dichotomy)

Parameters
target
Returns
the class of target

◆ addTick()

template<typename T_TICKS>
DiscretizedVariable& gum::DiscretizedVariable< T_TICKS >::addTick ( const T_TICKS &  aTick)

add a tick.

Parameters
aTick
Exceptions
DefaultInLabel

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::addTick().

+ Here is the caller graph for this function:

◆ clone()

template<typename T_TICKS>
virtual DiscretizedVariable< T_TICKS >* gum::DiscretizedVariable< T_TICKS >::clone ( ) const
virtual

a virtual clone

Implements gum::IDiscretizedVariable.

◆ description()

const std::string& gum::Variable::description ( ) const
inherited

returns the description of the variable

◆ domain()

template<typename T_TICKS>
virtual const std::string gum::DiscretizedVariable< T_TICKS >::domain ( ) const
virtual

string represent the domain of the variable

Implements gum::DiscreteVariable.

◆ domainSize()

template<typename T_TICKS>
virtual Size gum::DiscretizedVariable< T_TICKS >::domainSize ( ) const
virtual
Returns
the size of the random discrete variable domain

Implements gum::DiscreteVariable.

◆ empty()

bool gum::DiscreteVariable::empty ( ) const
inherited
Returns
true if the domainSize() < 2;

◆ eraseTicks()

template<typename T_TICKS>
void gum::DiscretizedVariable< T_TICKS >::eraseTicks ( )

erase all the Ticks

◆ index()

template<typename T_TICKS>
virtual Idx gum::DiscretizedVariable< T_TICKS >::index ( const std::string &  label) const
virtual

from the label to its index in var.

Exceptions
NotFound

Implements gum::DiscreteVariable.

◆ isTick()

template<typename T_TICKS>
bool gum::DiscretizedVariable< T_TICKS >::isTick ( const T_TICKS &  aTick) const
Parameters
aTick
Returns
true if the tick already exists

◆ label()

template<typename T_TICKS>
virtual std::string gum::DiscretizedVariable< T_TICKS >::label ( Idx  i) const
virtual
Parameters
i
Returns
the ith label
Exceptions
OutOfBound

Implements gum::DiscreteVariable.

◆ labels()

std::vector< std::string > gum::DiscreteVariable::labels ( ) const
inherited

vector of labels

◆ name()

const std::string& gum::Variable::name ( ) const
inherited

returns the name of the variable

Referenced by gum::BNdistance< GUM_SCALAR >::__checkCompatibility(), gum::prm::PRMFactory< GUM_SCALAR >::__retrieveCommonType(), gum::prm::PRMFactory< GUM_SCALAR >::__retrieveInputs(), gum::BayesNetFactory< GUM_SCALAR >::__setCPTAndParents(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::MultiDimImplementation< std::string >::add(), gum::Instantiation::add(), gum::FMDP< double >::addTransitionForAction(), gum::FMDP< double >::addVariable(), gum::MultiDimICIModel< GUM_SCALAR >::causalWeight(), gum::Instantiation::chgVal(), gum::learning::genericBNLearner::Database::Database(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscreteType(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscretizedType(), gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration(), gum::BayesNetFactory< GUM_SCALAR >::endVariableDeclaration(), gum::MarkovBlanket::hasSameStructure(), gum::BayesNetFragment< GUM_SCALAR >::nodeId(), gum::StructuredPlaner< double >::optimalPolicy2String(), gum::Estimator< GUM_SCALAR >::posterior(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), gum::Instantiation::setValsFrom(), gum::BayesNetFactory< GUM_SCALAR >::setVariable(), gum::BayesNetFactory< GUM_SCALAR >::setVariableValues(), gum::BayesNetFactory< GUM_SCALAR >::setVariableValuesUnchecked(), gum::MarkovBlanket::toDot(), gum::EssentialGraph::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), gum::prm::ClassBayesNet< GUM_SCALAR >::toDot(), gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >::toDot(), gum::Estimator< GUM_SCALAR >::update(), and gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >::varNodeListe().

◆ numerical()

template<typename T_TICKS>
virtual double gum::DiscretizedVariable< T_TICKS >::numerical ( Idx  indice) const
virtual

get a numerical representation of he indice-the value.

Implements gum::DiscreteVariable.

◆ operator!=() [1/2]

virtual bool gum::Variable::operator!= ( const Variable aRV) const
virtualinherited

inequality operator

◆ operator!=() [2/2]

virtual bool gum::DiscreteVariable::operator!= ( const DiscreteVariable aRV) const
virtualinherited

inequality operator

◆ operator=()

template<typename T_TICKS>
DiscretizedVariable< T_TICKS >& gum::DiscretizedVariable< T_TICKS >::operator= ( const DiscretizedVariable< T_TICKS > &  aDRV)

operator =

Parameters
aDRVa labelized discrete random variable
Returns
a reference to *this

◆ operator==() [1/2]

virtual bool gum::Variable::operator== ( const Variable aRV) const
virtualinherited

equality operator

◆ operator==() [2/2]

virtual bool gum::DiscreteVariable::operator== ( const DiscreteVariable aRV) const
virtualinherited

equality operator

◆ operator[]()

Idx gum::DiscreteVariable::operator[] ( const std::string &  label) const
inlineinherited

from the label to its index in var.

Warning
This operation may have different complexity in different subclasses.
Exceptions
NotFound

Definition at line 140 of file discreteVariable.h.

References gum::DiscreteVariable::domain(), gum::DiscreteVariable::index(), gum::DiscreteVariable::label(), gum::DiscreteVariable::toString(), and gum::DiscreteVariable::toStringWithDescription().

140 { return index(label); };
virtual std::string label(Idx i) const =0
get the indice-th label. This method is pure virtual.
virtual Idx index(const std::string &label) const =0
+ Here is the call graph for this function:

◆ setDescription()

void gum::Variable::setDescription ( const std::string &  theValue) const
inherited

sets the description of the variable

Warning
since __description is mutable, setDescription() is const
Parameters
theValue

◆ setName()

void gum::Variable::setName ( const std::string &  theValue)
inherited

sets the name of the variable

Parameters
theValue

Referenced by gum::prm::PRMSystem< double >::__groundAttr(), gum::prm::PRMType::__updateName(), gum::FMDP< double >::addVariable(), and gum::TaxiSimulator::TaxiSimulator().

+ Here is the caller graph for this function:

◆ tick()

template<typename T_TICKS>
const T_TICKS& gum::DiscretizedVariable< T_TICKS >::tick ( Idx  i) const

from the index to the tick.

Exceptions
NotFound

◆ ticks()

template<typename T_TICKS>
const std::vector< T_TICKS >& gum::DiscretizedVariable< T_TICKS >::ticks ( ) const

Return the list of ticks.

◆ ticksAsDoubles()

template<typename T_TICKS>
virtual std::vector< double > gum::DiscretizedVariable< T_TICKS >::ticksAsDoubles ( ) const
virtual

return the list of ticks as a vector of doubles

Implements gum::IDiscretizedVariable.

◆ toString()

const std::string gum::DiscreteVariable::toString ( ) const
inherited

string version of *this

Referenced by gum::DiscreteVariable::operator[]().

+ Here is the caller graph for this function:

◆ toStringWithDescription()

const std::string gum::DiscreteVariable::toStringWithDescription ( ) const
inherited

string version of *this using description attribute instead of name.

Referenced by gum::DiscreteVariable::operator[]().

+ Here is the caller graph for this function:

◆ varType()

template<typename T_TICKS>
virtual VarType gum::DiscretizedVariable< T_TICKS >::varType ( ) const
virtual

returns the type of variable

Implements gum::DiscreteVariable.

Member Data Documentation

◆ __ticks

template<typename T_TICKS>
std::vector< T_TICKS > gum::DiscretizedVariable< T_TICKS >::__ticks
private

Definition at line 59 of file discretizedVariable.h.

◆ __ticks_size

template<typename T_TICKS>
Size gum::DiscretizedVariable< T_TICKS >::__ticks_size
private

Definition at line 60 of file discretizedVariable.h.


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