aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
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...
 
std::string toString () const
 string version of *this More...
 
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 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() & Christophe GONZALES()

Definition at line 56 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

◆ addTick()

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

add a tick.

Parameters
aTick
Exceptions
DefaultInLabel

◆ clone()

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

a virtual clone

Implements gum::IDiscretizedVariable.

◆ copy_() [1/2]

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

make a copy

Parameters
aDRVthe copied object

◆ copy_() [2/2]

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

protected copy

Parameters
aRVto be copied

◆ description()

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

returns the description of the variable

◆ 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

◆ 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

◆ 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 139 of file discreteVariable.h.

139 { 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

◆ 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

◆ 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

◆ 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()

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

string version of *this

◆ toStringWithDescription()

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

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

◆ 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 58 of file discretizedVariable.h.

◆ _ticks_size_

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

Definition at line 59 of file discretizedVariable.h.


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