![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
class IntegerVariable More...
#include <integerVariable.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 | |
| IntegerVariable (const std::string &aName, const std::string &aDesc="") | |
| constructor | |
| IntegerVariable (const std::string &aName, const std::string &aDesc, const std::vector< int > &domain) | |
| constructor assigning a domain to the variable | |
| IntegerVariable (const std::string &aName, const std::string &aDesc, int first, int last, Size nb) | |
| constructor assigning a domain to the variable | |
| IntegerVariable (const IntegerVariable &from) | |
| Copy constructor. | |
| IntegerVariable (IntegerVariable &&from) noexcept | |
| move constructor | |
| IntegerVariable * | clone () const final |
| virtual copy constructor | |
| ~IntegerVariable () final | |
| destructor | |
Operators | |
| IntegerVariable & | operator= (const IntegerVariable &from) |
| copy operator | |
| IntegerVariable & | operator= (IntegerVariable &&from) |
| move operator | |
Accessors / Modifiers | |
| Size | domainSize () const final |
| returns the domain size of the discrete random variable | |
| VarType | varType () const final |
| returns the type of variable | |
| std::string | toFast () const final |
| returns the domain size of the discrete random variable | |
| Idx | index (const std::string &label) const final |
| returns the index of a given label | |
| Idx | closestIndex (double val) const final |
| returns the closest index of the value | |
| std::string | label (Idx index) const final |
| returns a string corresponding to the ith value of the domain | |
| double | numerical (Idx index) const final |
| get a integer representation of the value at a given index | |
| std::string | domain () const final |
| Returns the domain as a string. | |
| std::string | stype () const final |
| string represent the type of the variable | |
| const std::vector< int > & | integerDomain () const |
| returns the domain as a sequence of values | |
| void | addValue (int value) |
| add a new value to the domain size | |
| bool | isValue (int value) const |
| does this value exist in the domain ? | |
| void | changeValue (int old_value, int new_value) |
| substitute a value by another one | |
| void | eraseValue (int value) |
| erase a value from the domain of the variable | |
| void | eraseValues () |
| clear the domain of the variable | |
| std::string | closestLabel (double val) const |
| gives the value closets to val | |
Accessors / Modifiers | |
| bool | empty () const |
| std::vector< std::string > | labels () const |
| vector of labels | |
| virtual bool | isEmpirical () const |
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 | |
| void | copy_ (const Variable &aRV) |
| protected copy | |
Private Member Functions | |
| bool | _checkSameDomain_ (const Variable &aRV) const final |
| check the domain | |
Private Attributes | |
| std::vector< int > | _domain_ |
| the domain of 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 IntegerVariable
The class representing discrete integer random variables
Definition at line 62 of file integerVariable.h.
| gum::IntegerVariable::IntegerVariable | ( | const std::string & | aName, |
| const std::string & | aDesc = "" ) |
constructor
| aName | the name of the variable |
| aDesc | the Description of the variable, if any |
References domain().
Referenced by IntegerVariable(), IntegerVariable(), IntegerVariable(), IntegerVariable(), ~IntegerVariable(), clone(), operator=(), and operator=().
| gum::IntegerVariable::IntegerVariable | ( | const std::string & | aName, |
| const std::string & | aDesc, | ||
| const std::vector< int > & | domain ) |
constructor assigning a domain to the variable
| aName | the name of the variable |
| aDesc | the Description of the variable, if any |
| domain | the domain (set of values) of the variable |
Definition at line 53 of file integerVariable.cpp.
References gum::DiscreteVariable::DiscreteVariable(), IntegerVariable(), _domain_, domain(), GUM_ERROR, gum::isfinite(), isValue(), and gum::DiscreteVariable::toString().
| gum::IntegerVariable::IntegerVariable | ( | const std::string & | aName, |
| const std::string & | aDesc, | ||
| int | first, | ||
| int | last, | ||
| Size | nb ) |
constructor assigning a domain to the variable
| aName | the name of the variable |
| aDesc | the Description of the variable, if any |
| first | the first value |
| last | the last value |
| nb | the number of values |
Definition at line 72 of file integerVariable.cpp.
References gum::DiscreteVariable::DiscreteVariable(), IntegerVariable(), _domain_, and GUM_ERROR.
| gum::IntegerVariable::IntegerVariable | ( | const IntegerVariable & | from | ) |
Copy constructor.
| from | the variable we copy |
References IntegerVariable().
|
noexcept |
|
final |
check the domain
this function use the assumption that the concrete type of the variable is the same as *this
Implements gum::Variable.
| void gum::IntegerVariable::addValue | ( | int | value | ) |
add a new value to the domain size
| DuplicateElement | is raised if the variable already contains the value |
| void gum::IntegerVariable::changeValue | ( | int | old_value, |
| int | new_value ) |
substitute a value by another one
|
finalvirtual |
virtual copy constructor
Implements gum::DiscreteVariable.
References IntegerVariable().
returns the closest index of the value
Implements gum::DiscreteVariable.
References closestIndex().
Referenced by closestIndex().
| std::string gum::IntegerVariable::closestLabel | ( | double | val | ) | const |
gives the value closets to val
| val | the desired value |
|
protectedinherited |
protected copy
| aRV | to be copied |
References Variable().
|
inherited |
returns the description of the variable
|
finalvirtual |
Returns the domain as a string.
Implements gum::DiscreteVariable.
Definition at line 105 of file integerVariable.cpp.
References _domain_, and domainSize().
Referenced by IntegerVariable(), IntegerVariable(), and numerical().
|
finalvirtual |
returns the domain size of the discrete random variable
Implements gum::DiscreteVariable.
References domainSize().
Referenced by domain(), and domainSize().
|
inherited |
| void gum::IntegerVariable::eraseValue | ( | int | value | ) |
erase a value from the domain of the variable
| void gum::IntegerVariable::eraseValues | ( | ) |
clear the domain of the variable
|
finalvirtual |
returns the index of a given label
| label | searched label |
| NotFound |
Implements gum::DiscreteVariable.
References index(), and label().
Referenced by index(), label(), and numerical().
| const std::vector< int > & gum::IntegerVariable::integerDomain | ( | ) | const |
returns the domain as a sequence of values
|
inlinevirtualinherited |
Reimplemented in gum::IDiscretizedVariable.
Definition at line 124 of file discreteVariable.h.
| bool gum::IntegerVariable::isValue | ( | int | value | ) | const |
does this value exist in the domain ?
Referenced by IntegerVariable().
|
finalvirtual |
returns a string corresponding to the ith value of the domain
Implements gum::DiscreteVariable.
References index(), and label().
Referenced by index(), and label().
|
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 integer representation of the value at a given index
Implements gum::DiscreteVariable.
References domain(), index(), and numerical().
Referenced by numerical().
| IntegerVariable & gum::IntegerVariable::operator= | ( | const IntegerVariable & | from | ) |
copy operator
| from | the integer discrete random variable we copy |
References IntegerVariable().
| IntegerVariable & gum::IntegerVariable::operator= | ( | IntegerVariable && | from | ) |
move operator
| from | the integer discrete random variable we copy |
References IntegerVariable().
|
inlineinherited |
from the label to its index in var.
| NotFound |
Definition at line 156 of file discreteVariable.h.
References index(), and label().
|
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 165 of file integerVariable.h.
References stype().
Referenced by stype().
|
finalvirtual |
returns the domain size of the discrete random variable
Implements gum::DiscreteVariable.
References toFast().
Referenced by toFast().
|
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 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.
|
private |
the domain of the variable
Definition at line 205 of file integerVariable.h.
Referenced by IntegerVariable(), IntegerVariable(), and domain().
|
privateinherited |
the name of the variable
Definition at line 160 of file variable.h.