![]() |
aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
|
Defines a discrete random variable over an integer interval. More...
#include <rangeVariable.h>
Public Member Functions | |
| std::string | domain () const final |
| string represent the domain of the variable | |
| std::string | stype () const final |
| string represent the type of the variable | |
| Idx | operator[] (std::string_view 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 | |
| RangeVariable (std::string_view aName, std::string_view aDesc, long minVal, long maxVal) | |
| constructors | |
| RangeVariable (std::string_view aName, std::string_view aDesc) | |
| by de default min=0, max=1 | |
| RangeVariable (const RangeVariable &aDRV) | |
| Copy Constructor. | |
| ~RangeVariable () final | |
| destructor | |
| RangeVariable * | clone () const final |
| Copy Factory. | |
Accessors / Modifiers | |
| Size | domainSize () const final |
| returns the size of the random discrete variable domain | |
| VarType | varType () const final |
| returns the type of variable | |
| std::string | toFast () const final |
| returns the size of the random discrete variable domain | |
| std::string | label (Idx index) const final |
| Get the index-th label. | |
| double | numerical (Idx index) const final |
| get a numerical representation of the index-the value. | |
| long | minVal () const |
| Returns the lower bound. | |
| void | setMinVal (long minVal) |
| Set a new value for the lower bound. | |
| long | maxVal () const |
| Returns the upper bound. | |
| void | setMaxVal (long maxVal) |
| Set a new value of the upper bound. | |
| bool | belongs (long val) const |
| Returns true if the param belongs to the variable's interval. | |
| Idx | index (std::string_view) const final |
| Idx | closestIndex (double val) const final |
| returns the closest index of the value | |
Operators | |
| RangeVariable & | operator= (const RangeVariable &aRV) |
| Copy operator. | |
Accessors / Modifiers | |
| bool | empty () const |
| std::vector< std::string > | labels () const |
| vector of labels | |
| virtual bool | isEmpirical () const |
| bool | isNumerical () const |
| virtual 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 (std::string_view theValue) |
| sets the name of the variable | |
| const std::string & | name () const |
| returns the name of the variable | |
| void | setDescription (std::string_view 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::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. | |
Private Members. | |
The lower bound. | |
| long | _minBound_ |
| The upper bound. | |
| long | _maxBound_ |
| The upper bound. | |
Defines a discrete random variable over an integer interval.
It is technically possible to create RangeVariable with minVal > maxVal (or modify in that way an already created RangeVariable). The result is an empty variable (i.e. empty() returns true). If maxVal - minVal < 0, then domainsize() = 0.
Definition at line 72 of file rangeVariable.h.
| gum::RangeVariable::RangeVariable | ( | std::string_view | aName, |
| std::string_view | aDesc, | ||
| long | minVal, | ||
| long | maxVal ) |
constructors
Definition at line 60 of file rangeVariable.cpp.
References gum::DiscreteVariable::DiscreteVariable(), RangeVariable(), _maxBound_, _minBound_, maxVal(), and minVal().
Referenced by RangeVariable(), RangeVariable(), RangeVariable(), ~RangeVariable(), _checkSameDomain_(), clone(), and operator=().
| gum::RangeVariable::RangeVariable | ( | std::string_view | aName, |
| std::string_view | aDesc ) |
by de default min=0, max=1
Definition at line 68 of file rangeVariable.cpp.
References gum::DiscreteVariable::DiscreteVariable(), RangeVariable(), _maxBound_, and _minBound_.
| gum::RangeVariable::RangeVariable | ( | const RangeVariable & | aDRV | ) |
Copy Constructor.
If aDRV haves any listener, it will not be copied.
| aDRV | the variable we copy |
Definition at line 78 of file rangeVariable.cpp.
References gum::DiscreteVariable::DiscreteVariable(), RangeVariable(), _maxBound_, and _minBound_.
|
final |
destructor
Definition at line 86 of file rangeVariable.cpp.
References RangeVariable().
check the domain
this function use the assumption that the concrete type of the variable is the same as *this
Implements gum::Variable.
Definition at line 134 of file rangeVariable_inl.h.
References RangeVariable(), _maxBound_, and _minBound_.
Referenced by operator=().
| INLINE bool gum::RangeVariable::belongs | ( | long | val | ) | const |
Returns true if the param belongs to the variable's interval.
Definition at line 123 of file rangeVariable_inl.h.
References _maxBound_, and _minBound_.
Referenced by index(), and label().
|
nodiscardfinalvirtual |
Copy Factory.
Implements gum::DiscreteVariable.
Definition at line 60 of file rangeVariable_inl.h.
References RangeVariable().
returns the closest index of the value
Implements gum::DiscreteVariable.
Definition at line 95 of file rangeVariable_inl.h.
References _maxBound_, _minBound_, and domainSize().
|
virtualinherited |
for numerical variables, returns the closest label for the value
Reimplemented in gum::IntegerVariable, and gum::NumericalDiscreteVariable.
|
protectedinherited |
protected copy
| aRV | to be copied |
References Variable().
|
inherited |
returns the description of the variable
|
finalvirtual |
string represent the domain of the variable
Implements gum::DiscreteVariable.
Definition at line 91 of file rangeVariable.cpp.
References maxVal(), and minVal().
|
finalvirtual |
returns the size of the random discrete variable domain
maxVal (or modify in that way an already created RangeVariable). The result is an empty variable (i.e. empty() returns true). If maxVal - minVal < 0, then domainsize() = 0.
Implements gum::DiscreteVariable.
Definition at line 63 of file rangeVariable_inl.h.
References _maxBound_, and _minBound_.
Referenced by closestIndex().
|
inherited |
|
finalvirtual |
| NotFound |
Implements gum::DiscreteVariable.
Definition at line 84 of file rangeVariable_inl.h.
References _minBound_, belongs(), GUM_ERROR, and label().
|
virtualinherited |
Reimplemented in gum::IDiscretizedVariable.
|
inherited |
|
finalvirtual |
Get the index-th label.
| index | the index of the label we wish to return |
| OutOfBound |
Implements gum::DiscreteVariable.
Definition at line 70 of file rangeVariable_inl.h.
References _minBound_, belongs(), and GUM_ERROR.
Referenced by index().
|
inherited |
vector of labels
Referenced by gum::LabelizedVariable::LabelizedVariable().
| INLINE long gum::RangeVariable::maxVal | ( | ) | const |
Returns the upper bound.
Definition at line 117 of file rangeVariable_inl.h.
References _maxBound_.
Referenced by RangeVariable(), gum::AggregatorDecomposition< GUM_SCALAR >::addDepthLayer_(), gum::AggregatorDecomposition< GUM_SCALAR >::decomposeAggregator_(), domain(), setMaxVal(), and toFast().
| INLINE long gum::RangeVariable::minVal | ( | ) | const |
Returns the lower bound.
Definition at line 111 of file rangeVariable_inl.h.
References _minBound_.
Referenced by RangeVariable(), gum::AggregatorDecomposition< GUM_SCALAR >::addDepthLayer_(), gum::AggregatorDecomposition< GUM_SCALAR >::decomposeAggregator_(), domain(), setMinVal(), and toFast().
|
inherited |
returns the name of the variable
Referenced by gum::learning::IBNLearner::Database::Database(), gum::Estimator< GUM_SCALAR >::Estimator(), gum::NumericalDiscreteVariable::NumericalDiscreteVariable(), gum::MultiDimImplementation< double >::~MultiDimImplementation(), gum::BNdistance< GUM_SCALAR >::_checkCompatibility_(), gum::ASTposteriorProba< GUM_SCALAR >::_compute_knw_from_bn(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveCommonType_(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveInputs_(), gum::BayesNetFactory< GUM_SCALAR >::_setCPTAndParents_(), gum::Instantiation::add(), gum::MultiDimImplementation< GUM_ELEMENT >::add(), gum::Instantiation::chgVal(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::InfluenceDiagram< GUM_SCALAR >::copyStructureAndTables_(), gum::FMDP< double >::cost(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscreteType(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscretizedType(), gum::BayesNetFactory< GUM_SCALAR >::endVariableDeclaration(), gum::FMDPFactory< GUM_ELEMENT >::endVariableDeclaration(), gum::BayesNetFragment< GUM_SCALAR >::nodeId(), gum::IBayesNet< GUM_SCALAR >::operator==(), 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_ELEMENT, TerminalNodePolicy >::toDot(), gum::RangeVariable::toFast(), gum::Estimator< GUM_SCALAR >::update(), and gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::varNodeListe().
get a numerical representation of the index-the value.
Implements gum::DiscreteVariable.
Definition at line 80 of file rangeVariable_inl.h.
References _minBound_.
|
default |
Copy operator.
| aRV | to be copied |
References RangeVariable(), _checkSameDomain_(), and stype().
|
inherited |
|
inherited |
sets the description of the variable
| theValue |
| INLINE void gum::RangeVariable::setMaxVal | ( | long | maxVal | ) |
Set a new value of the upper bound.
Definition at line 120 of file rangeVariable_inl.h.
References _maxBound_, and maxVal().
| INLINE void gum::RangeVariable::setMinVal | ( | long | minVal | ) |
Set a new value for the lower bound.
Definition at line 114 of file rangeVariable_inl.h.
References _minBound_, and minVal().
|
inherited |
sets the name of the variable
| theValue |
|
finalvirtual |
string represent the type of the variable
Implements gum::DiscreteVariable.
Definition at line 142 of file rangeVariable_inl.h.
Referenced by operator=().
|
finalvirtual |
returns the size of the random discrete variable domain
maxVal (or modify in that way an already created RangeVariable). The result is an empty variable (i.e. empty() returns true). If maxVal - minVal < 0, then domainsize() = 0.
Implements gum::DiscreteVariable.
Definition at line 93 of file rangeVariable.cpp.
References maxVal(), minVal(), and gum::Variable::name().
|
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.
Definition at line 132 of file rangeVariable_inl.h.
References gum::RANGE.
|
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 167 of file variable.h.
|
private |
The upper bound.
Definition at line 192 of file rangeVariable.h.
Referenced by RangeVariable(), RangeVariable(), RangeVariable(), _checkSameDomain_(), belongs(), closestIndex(), domainSize(), maxVal(), and setMaxVal().
|
private |
The upper bound.
Definition at line 189 of file rangeVariable.h.
Referenced by RangeVariable(), RangeVariable(), RangeVariable(), _checkSameDomain_(), belongs(), closestIndex(), domainSize(), index(), label(), minVal(), numerical(), and setMinVal().
|
privateinherited |
the name of the variable
Definition at line 162 of file variable.h.