![]() |
aGrUM 2.3.2
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[] (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 | |
| RangeVariable (const std::string &aName, const std::string &aDesc, long minVal, long maxVal) | |
| constructors | |
| RangeVariable (const std::string &aName, const std::string &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 (const std::string &) 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 |
| 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 | |
| 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 | ( | const std::string & | aName, |
| const std::string & | 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 | ( | const std::string & | aName, |
| const std::string & | 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 137 of file rangeVariable_inl.h.
References RangeVariable(), _maxBound_, and _minBound_.
| INLINE bool gum::RangeVariable::belongs | ( | long | val | ) | const |
Returns true if the param belongs to the variable's interval.
Definition at line 122 of file rangeVariable_inl.h.
References _maxBound_, and _minBound_.
Referenced by index(), and label().
|
finalvirtual |
Copy Factory.
Implements gum::DiscreteVariable.
Definition at line 59 of file rangeVariable_inl.h.
References RangeVariable().
returns the closest index of the value
Implements gum::DiscreteVariable.
Definition at line 96 of file rangeVariable_inl.h.
References _maxBound_, _minBound_, and domainSize().
|
inherited |
for numerical variables, returns the closest label for the value
|
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 62 of file rangeVariable_inl.h.
References _maxBound_, and _minBound_.
Referenced by closestIndex().
|
inherited |
|
finalvirtual |
| NotFound |
Implements gum::DiscreteVariable.
Definition at line 85 of file rangeVariable_inl.h.
References _minBound_, belongs(), GUM_ERROR, and label().
|
inlinevirtualinherited |
Reimplemented in gum::IDiscretizedVariable.
Definition at line 124 of file discreteVariable.h.
|
finalvirtual |
Get the index-th label.
| index | the index of the label we wish to return |
| OutOfBound |
Implements gum::DiscreteVariable.
Definition at line 69 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 116 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 110 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::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.
Definition at line 81 of file rangeVariable_inl.h.
References _minBound_.
| INLINE RangeVariable & gum::RangeVariable::operator= | ( | const RangeVariable & | aRV | ) |
Copy operator.
| aRV | to be copied |
Definition at line 129 of file rangeVariable_inl.h.
References RangeVariable(), _maxBound_, and _minBound_.
|
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 |
| INLINE void gum::RangeVariable::setMaxVal | ( | long | maxVal | ) |
Set a new value of the upper bound.
Definition at line 119 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 113 of file rangeVariable_inl.h.
References _minBound_, and minVal().
|
inherited |
sets the name of the variable
| theValue |
|
inlinefinalvirtual |
string represent the type of the variable
Implements gum::DiscreteVariable.
Definition at line 177 of file rangeVariable.h.
|
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 97 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 135 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 165 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(), operator=(), 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(), operator=(), and setMinVal().
|
privateinherited |
the name of the variable
Definition at line 160 of file variable.h.