![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
class LabelizedVariable More...
#include <labelizedVariable.h>
Public Member Functions | |
| Idx | operator[] (const std::string &label) const |
| from the label to its index in var. | |
| std::string | toString () const |
| string version of *this | |
| std::string | toStringWithDescription () const |
| string version of *this using description attribute instead of name. | |
Constructors / Destructors | |
| LabelizedVariable (const std::string &aName, const std::string &aDesc="", const Size nbrLabel=2) | |
| constructor | |
| LabelizedVariable (const std::string &aName, const std::string &aDesc, const std::vector< std::string > &labels) | |
| constructor | |
| LabelizedVariable (const LabelizedVariable &aLDRV) | |
| Copy constructor. | |
| ~LabelizedVariable () final | |
| destructor | |
| LabelizedVariable * | clone () const final |
| a virtual clone ... | |
Operators | |
| LabelizedVariable & | operator= (const LabelizedVariable &aLDRV) |
| copy operator | |
| Idx | index (const std::string &label) const final |
| returns the index of a given label | |
Accessors / Modifiers | |
| bool | isLabel (const std::string &aLabel) const |
| indicates whether the variable already has the label passed in argument | |
| LabelizedVariable & | addLabel (const std::string &aLabel) |
| add a label with a new index (we assume that we will NEVER remove a label) | |
| void | changeLabel (Idx pos, const std::string &aLabel) const |
| change a label for this index | |
| void | eraseLabels () |
| erase all the labels | |
| std::string | label (Idx i) const final |
| returns the ith label | |
| Idx | posLabel (const std::string &label) const |
| return the pos from label | |
| double | numerical (Idx index) const final |
| get a numerical representation of the index-the value. | |
| Idx | closestIndex (double val) const final |
| returns the closest index of the value | |
| Size | domainSize () const final |
| returns the size of the random discrete variable domain | |
| VarType | varType () const final |
| returns the type of variable | |
| std::string | domain () const final |
| Returns the domain. | |
| std::string | stype () const final |
| string represent the type of the variable | |
| std::string | toFast () const final |
| indicates whether the variable already has the label passed in argument | |
Accessors / Modifiers | |
| bool | empty () const |
| std::vector< std::string > | labels () const |
| vector of labels | |
| virtual bool | isEmpirical () const |
| std::string | closestLabel (double val) const |
| for numerical variables, returns the closest label for the value | |
Operators | |
| bool | operator== (const Variable &aRV) const |
| equality operator | |
Accessors / Modifiers | |
| void | setName (const std::string &theValue) |
| sets the name of the variable | |
| const std::string & | name () const |
| returns the name of the variable | |
| void | setDescription (const std::string &theValue) const |
| sets the description of the variable | |
| const std::string & | description () const |
| returns the description of the variable | |
Protected Member Functions | |
| LabelizedVariable () | |
| (protected) Default constructor | |
| void | copy_ (const LabelizedVariable &aLDRV) |
| copies the content of aLDRV | |
| void | copy_ (const Variable &aRV) |
| protected copy | |
Private Member Functions | |
| bool | _checkSameDomain_ (const Variable &aRV) const final |
| check the domain | |
Private Attributes | |
| Sequence< std::string > | _labels_ |
| the set of labels contained in the variable | |
| std::string | _name_ |
| the name of the variable | |
| std::string | _description_ |
| the description of the variable since description is not a characteristic of a variable, we allow the description to be changed even in a const reference. | |
class LabelizedVariable
Base class for labelized discrete random variables
Definition at line 71 of file labelizedVariable.h.
| gum::LabelizedVariable::LabelizedVariable | ( | const std::string & | aName, |
| const std::string & | aDesc = "", | ||
| const Size | nbrLabel = 2 ) |
constructor
| aName | the name |
| aDesc | the Description |
| nbrLabel | the domainSize (2 by default) |
Referenced by LabelizedVariable(), LabelizedVariable(), addLabel(), clone(), copy_(), and operator=().
| gum::LabelizedVariable::LabelizedVariable | ( | const std::string & | aName, |
| const std::string & | aDesc, | ||
| const std::vector< std::string > & | labels ) |
constructor
| aName | the name |
| aDesc | the Description |
| labels | the labels |
References gum::DiscreteVariable::labels().
| gum::LabelizedVariable::LabelizedVariable | ( | const LabelizedVariable & | aLDRV | ) |
Copy constructor.
| aLDRV | the variable we copy |
References LabelizedVariable().
|
final |
destructor
|
inlineprotected |
(protected) Default constructor
Definition at line 209 of file labelizedVariable.h.
References LabelizedVariable().
check the domain
this function use the assumption that the concrete type of the variable is the same as *this
Implements gum::Variable.
References _checkSameDomain_().
Referenced by _checkSameDomain_().
| LabelizedVariable & gum::LabelizedVariable::addLabel | ( | const std::string & | aLabel | ) |
add a label with a new index (we assume that we will NEVER remove a label)
| aLabel | the label to be added to the labelized variable |
| DuplicateElement | is raised if the variable already contains the label |
References LabelizedVariable(), and addLabel().
Referenced by addLabel(), gum::prm::PRMFactory< GUM_SCALAR >::addLabel(), gum::prm::PRMType::boolean(), and gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration().
| void gum::LabelizedVariable::changeLabel | ( | Idx | pos, |
| const std::string & | aLabel ) const |
change a label for this index
| pos | the index of the label to be changed |
| aLabel | the label to be added to the labelized variable |
| DuplicateElement | is raised if the variable already contains |
| OutOfBounds |
References changeLabel().
Referenced by changeLabel(), and gum::BayesNet< GUM_SCALAR >::changeVariableLabel().
|
finalvirtual |
a virtual clone ...
Implements gum::DiscreteVariable.
References LabelizedVariable(), and clone().
Referenced by clone().
returns the closest index of the value
Implements gum::DiscreteVariable.
References closestIndex().
Referenced by closestIndex().
|
inherited |
for numerical variables, returns the closest label for the value
|
protected |
copies the content of aLDRV
References LabelizedVariable().
|
protectedinherited |
protected copy
| aRV | to be copied |
References Variable().
|
inherited |
returns the description of the variable
|
finalvirtual |
Returns the domain.
Implements gum::DiscreteVariable.
Definition at line 49 of file labelizedVariable.cpp.
References domainSize(), and label().
Referenced by varType().
|
finalvirtual |
returns the size of the random discrete variable domain
Implements gum::DiscreteVariable.
References domainSize().
Referenced by domain(), and domainSize().
|
inherited |
| void gum::LabelizedVariable::eraseLabels | ( | ) |
erase all the labels
References eraseLabels().
Referenced by eraseLabels().
|
finalvirtual |
returns the index of a given label
| label | searched label |
| NotFound |
Implements gum::DiscreteVariable.
References index(), and label().
Referenced by index(), and numerical().
|
inlinevirtualinherited |
Reimplemented in gum::IDiscretizedVariable.
Definition at line 124 of file discreteVariable.h.
| bool gum::LabelizedVariable::isLabel | ( | const std::string & | aLabel | ) | const |
|
finalvirtual |
returns the ith label
| i |
Implements gum::DiscreteVariable.
References label().
Referenced by domain(), index(), label(), and posLabel().
|
inherited |
vector of labels
Referenced by gum::LabelizedVariable::LabelizedVariable().
|
inherited |
returns the name of the variable
Referenced by gum::learning::IBNLearner::Database::Database(), gum::Estimator< GUM_SCALAR >::Estimator(), gum::MultiDimImplementation< double >::MultiDimImplementation(), gum::NumericalDiscreteVariable::NumericalDiscreteVariable(), gum::BNdistance< GUM_SCALAR >::_checkCompatibility_(), gum::BayesNet< double >::_copyTensors_(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveCommonType_(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveInputs_(), gum::BayesNetFactory< GUM_SCALAR >::_setCPTAndParents_(), gum::Instantiation::add(), gum::FMDP< double >::addCostForAction(), gum::FMDP< GUM_SCALAR >::addVariable(), gum::MultiDimICIModel< GUM_SCALAR >::causalWeight(), gum::Instantiation::chgVal(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::InfluenceDiagram< GUM_SCALAR >::copyStructureAndTables_(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscreteType(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscretizedType(), gum::BayesNetFactory< GUM_SCALAR >::endVariableDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration(), gum::Tensor< GUM_SCALAR >::fillWith(), gum::BayesNetFragment< GUM_SCALAR >::nodeId(), gum::Estimator< GUM_SCALAR >::posterior(), gum::Estimator< GUM_SCALAR >::setFromBN(), gum::Instantiation::setValsFrom(), gum::BayesNetFactory< GUM_SCALAR >::setVariable(), gum::BayesNetFactory< GUM_SCALAR >::setVariableValuesUnchecked(), gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::toDot(), gum::RangeVariable::toFast(), gum::Estimator< GUM_SCALAR >::update(), and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::varNodeListe().
get a numerical representation of the index-the value.
Implements gum::DiscreteVariable.
References index(), and numerical().
Referenced by numerical().
| LabelizedVariable & gum::LabelizedVariable::operator= | ( | const LabelizedVariable & | aLDRV | ) |
copy operator
| aLDRV | the labelized discrete random variable we copy |
References LabelizedVariable().
|
inlineinherited |
from the label to its index in var.
| NotFound |
Definition at line 156 of file discreteVariable.h.
References index(), and label().
| Idx gum::LabelizedVariable::posLabel | ( | const std::string & | label | ) | const |
return the pos from label
References label(), and posLabel().
Referenced by gum::BayesNet< GUM_SCALAR >::changeVariableLabel(), and posLabel().
|
inherited |
sets the description of the variable
| theValue |
|
inherited |
sets the name of the variable
| theValue |
|
inlinefinalvirtual |
string represent the type of the variable
Implements gum::DiscreteVariable.
Definition at line 192 of file labelizedVariable.h.
References stype().
Referenced by stype().
|
finalvirtual |
indicates whether the variable already has the label passed in argument
| aLabel | The label |
Implements gum::DiscreteVariable.
|
inherited |
string version of *this
Referenced by gum::IntegerVariable::IntegerVariable(), and gum::BNdistance< GUM_SCALAR >::_checkCompatibility_().
|
inherited |
string version of *this using description attribute instead of name.
|
finalvirtual |
returns the type of variable
Implements gum::DiscreteVariable.
References domain(), and varType().
Referenced by varType().
|
mutableprivateinherited |
the description of the variable since description is not a characteristic of a variable, we allow the description to be changed even in a const reference.
Definition at line 165 of file variable.h.
|
mutableprivate |
the set of labels contained in the variable
Definition at line 217 of file labelizedVariable.h.
|
privateinherited |
the name of the variable
Definition at line 160 of file variable.h.