aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::IDiscretizedVariable Class Referenceabstract

A base class for discretized variables, independent of the ticks type. More...

#include <agrum/base/variables/IDiscretizedVariable.h>

Inheritance diagram for gum::IDiscretizedVariable:
Collaboration diagram for gum::IDiscretizedVariable:

Public Member Functions

Idx operator[] (std::string_view label) const
 from the label to its index in var.
virtual Idx index (std::string_view label) const =0
virtual std::string label (Idx i) const =0
 get the indice-th label. This method is pure virtual.
std::string toString () const
 string version of *this
std::string toStringWithDescription () const
 string version of *this using description attribute instead of name.
std::string domain () const override=0
 string represent the domain of the variable
virtual std::string stype () const =0
 string represent the type of the variable
Constructors / Destructors
 IDiscretizedVariable (std::string_view aName, std::string_view aDesc)
 Default constructor.
 IDiscretizedVariable (const IDiscretizedVariable &from)
 Copy Constructor.
 ~IDiscretizedVariable () override
 destructor
IDiscretizedVariableclone () const override=0
 Copy Factory.
Accessors / Modifiers
bool isEmpirical () const final
void setEmpirical (bool state)
virtual std::vector< doubleticksAsDoubles () const =0
 return the list of ticks as a vector of doubles
virtual double draw (Idx indice) const =0
 get a (double) random value in the intervall indice
Accessors / Modifiers
bool empty () const
virtual Size domainSize () const =0
std::vector< std::string > labels () const
 vector of labels
virtual double numerical (Idx indice) const =0
 get a numerical representation of the indice-th value.
bool isNumerical () const
virtual Idx closestIndex (double val) const =0
 for numerical variables, returns the closest index for the value
virtual std::string closestLabel (double val) const
 for numerical variables, returns the closest label for the value
VarType varType () const override=0
 returns the varType of variable
virtual std::string toFast () const =0
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

IDiscretizedVariableoperator= (const IDiscretizedVariable &from)
 copy operator
void copy_ (const Variable &aRV)
 protected copy

Protected Attributes

bool _is_empirical

Private Member Functions

virtual bool _checkSameDomain_ (const Variable &aRV) const =0
 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.

Detailed Description

A base class for discretized variables, independent of the ticks type.

Definition at line 59 of file IDiscretizedVariable.h.

Constructor & Destructor Documentation

◆ IDiscretizedVariable() [1/2]

gum::IDiscretizedVariable::IDiscretizedVariable ( std::string_view aName,
std::string_view aDesc )

Default constructor.

Referenced by IDiscretizedVariable(), clone(), and operator=().

Here is the caller graph for this function:

◆ IDiscretizedVariable() [2/2]

gum::IDiscretizedVariable::IDiscretizedVariable ( const IDiscretizedVariable & from)

Copy Constructor.

If from has any listener, it will not be copied.

Parameters
fromthe variable we copy

References IDiscretizedVariable().

Here is the call graph for this function:

◆ ~IDiscretizedVariable()

gum::IDiscretizedVariable::~IDiscretizedVariable ( )
override

destructor

Member Function Documentation

◆ _checkSameDomain_()

virtual bool gum::Variable::_checkSameDomain_ ( const Variable & aRV) const
privatepure virtualinherited

check the domain

this function use the assumption that the concrete type of the variable is the same as *this

Implemented in gum::ContinuousVariable< GUM_SCALAR >, gum::DiscretizedVariable< T_TICKS >, gum::IntegerVariable, gum::LabelizedVariable, gum::NumericalDiscreteVariable, and gum::RangeVariable.

References Variable().

Here is the call graph for this function:

◆ clone()

IDiscretizedVariable * gum::IDiscretizedVariable::clone ( ) const
nodiscardoverridepure virtual

Copy Factory.

Implements gum::DiscreteVariable.

Implemented in gum::DiscretizedVariable< T_TICKS >.

References IDiscretizedVariable().

Here is the call graph for this function:

◆ closestIndex()

virtual Idx gum::DiscreteVariable::closestIndex ( double val) const
pure virtualinherited

for numerical variables, returns the closest index for the value

Implemented in gum::DiscretizedVariable< T_TICKS >, gum::IntegerVariable, gum::LabelizedVariable, gum::NumericalDiscreteVariable, and gum::RangeVariable.

Referenced by gum::Tensor< GUM_SCALAR >::evEq(), gum::Tensor< GUM_SCALAR >::evGt(), gum::Tensor< GUM_SCALAR >::evIn(), and gum::Tensor< GUM_SCALAR >::evLt().

Here is the caller graph for this function:

◆ closestLabel()

virtual std::string gum::DiscreteVariable::closestLabel ( double val) const
virtualinherited

for numerical variables, returns the closest label for the value

Reimplemented in gum::IntegerVariable, and gum::NumericalDiscreteVariable.

◆ copy_()

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

protected copy

Parameters
aRVto be copied

References Variable().

Here is the call graph for this function:

◆ description()

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

returns the description of the variable

◆ domain()

std::string gum::DiscreteVariable::domain ( ) const
overridepure virtualinherited

◆ domainSize()

virtual Size gum::DiscreteVariable::domainSize ( ) const
pure virtualinherited
Returns
the number of modalities of the random discrete

Implemented in gum::DiscretizedVariable< T_TICKS >, gum::IntegerVariable, gum::LabelizedVariable, gum::NumericalDiscreteVariable, and gum::RangeVariable.

Referenced by gum::Estimator< GUM_SCALAR >::Estimator(), gum::prm::ClassDependencyGraph< GUM_SCALAR >::_addNode_(), gum::MultiDimFunctionGraphManager< GUM_ELEMENT, TerminalNodePolicy >::_checkIsomorphism_(), gum::TreeOperator< GUM_ELEMENT, COMBINEOPERATOR, TerminalNodePolicy >::_checkRedundancy_(), gum::BayesNetFactory< GUM_SCALAR >::_checkVariableModality_(), gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_compute_(), gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_compute_(), gum::StatesCounter::_incState_(), gum::StatesChecker::_insertState_(), gum::MultiDimFunctionGraphManager< GUM_ELEMENT, TerminalNodePolicy >::_isRedundant_(), gum::StructuredPlaner< GUM_ELEMENT >::_recurArgMaxCopy_(), gum::StructuredPlaner< GUM_ELEMENT >::_recurExtractOptPol_(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_verticesSampling_(), gum::AdaptiveRMaxPlaner::_visitLearner_(), gum::TreeOperator< GUM_ELEMENT, COMBINEOPERATOR, TerminalNodePolicy >::_xPloreDT1_(), gum::TreeOperator< GUM_ELEMENT, COMBINEOPERATOR, TerminalNodePolicy >::_xPloreDT2_(), gum::MultiDimArray< GUM_ELEMENT >::add(), gum::MultiDimDecorator< GUM_ELEMENT >::add(), gum::MultiDimWithOffset< GUM_ELEMENT >::add(), gum::BayesNet< GUM_SCALAR >::addAND(), gum::BayesNet< GUM_SCALAR >::addEXISTS(), gum::BayesNet< GUM_SCALAR >::addFORALL(), gum::prm::PRMFactory< GUM_SCALAR >::addLabel(), gum::BayesNet< GUM_SCALAR >::addOR(), gum::InfluenceDiagram< GUM_SCALAR >::addUtilityNode(), gum::InternalNode::allocateNodeSons(), gum::aggregator::Median< GUM_SCALAR >::buildValue_(), gum::Instantiation::chgVal(), gum::MultiDimWithOffset< GUM_ELEMENT >::computeInstantiationValue_(), gum::InternalNode::deallocateNodeSons(), gum::Instantiation::decVar(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscreteType(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscretizedType(), gum::MultiDimArray< GUM_ELEMENT >::erase(), gum::MultiDimImplementation< GUM_ELEMENT >::erase(), gum::MultiDimWithOffset< GUM_ELEMENT >::erase(), gum::Tensor< GUM_SCALAR >::evGt(), gum::credal::CredalNet< GUM_SCALAR >::fillConstraint(), gum::getMaxModality(), gum::Instantiation::incVar(), gum::MultiDimFunctionGraphManager< GUM_ELEMENT, TerminalNodePolicy >::nodeRedundancyCheck_(), gum::MultiDimFunctionGraphProjector< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::project(), gum::MultiDimInterface::replace(), gum::VariableSelector::select(), gum::prm::PRMFactory< GUM_SCALAR >::setCPFByRule(), gum::prm::PRMFactory< GUM_SCALAR >::setCPFByRule(), gum::credal::CredalNet< GUM_SCALAR >::setCPT(), gum::Estimator< GUM_SCALAR >::setFromBN(), gum::Instantiation::setLastVar(), gum::prm::PRMFormAttribute< GUM_SCALAR >::swap(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::swap(), gum::prm::PRMFormAttribute< GUM_SCALAR >::type_(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::type_().

◆ draw()

virtual double gum::IDiscretizedVariable::draw ( Idx indice) const
pure virtual

get a (double) random value in the intervall indice

Implemented in gum::DiscretizedVariable< T_TICKS >.

References draw().

Referenced by draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

bool gum::DiscreteVariable::empty ( ) const
inherited
Returns
true if the domainSize() < 2;

◆ index()

virtual Idx gum::DiscreteVariable::index ( std::string_view label) const
pure virtualinherited

Implemented in gum::DiscretizedVariable< T_TICKS >, gum::IntegerVariable, gum::LabelizedVariable, gum::NumericalDiscreteVariable, and gum::RangeVariable.

References label().

Referenced by gum::Tensor< GUM_SCALAR >::deterministicTensor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEmpirical()

bool gum::IDiscretizedVariable::isEmpirical ( ) const
finalvirtual
Returns
true if the tick is considered as empirical (relaxeds bounds)

Reimplemented from gum::DiscreteVariable.

◆ isNumerical()

bool gum::DiscreteVariable::isNumerical ( ) const
inherited
Returns
true if the variable has a meaningful numerical representation (i.e. not Labelized)

◆ label()

virtual std::string gum::DiscreteVariable::label ( Idx i) const
pure virtualinherited

◆ labels()

std::vector< std::string > gum::DiscreteVariable::labels ( ) const
inherited

vector of labels

Referenced by gum::LabelizedVariable::LabelizedVariable().

Here is the caller graph for this function:

◆ name()

const std::string & gum::Variable::name ( ) const
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().

◆ numerical()

virtual double gum::DiscreteVariable::numerical ( Idx indice) const
pure virtualinherited

get a numerical representation of the indice-th value.

Implemented in gum::DiscretizedVariable< T_TICKS >, gum::IntegerVariable, gum::LabelizedVariable, gum::NumericalDiscreteVariable, and gum::RangeVariable.

Referenced by gum::learning::BNDatabaseGenerator< GUM_SCALAR >::_label_().

Here is the caller graph for this function:

◆ operator=()

IDiscretizedVariable & gum::IDiscretizedVariable::operator= ( const IDiscretizedVariable & from)
protected

copy operator

References IDiscretizedVariable().

Here is the call graph for this function:

◆ operator==()

bool gum::Variable::operator== ( const Variable & aRV) const
inherited

equality operator

References Variable().

Here is the call graph for this function:

◆ operator[]()

Idx gum::DiscreteVariable::operator[] ( std::string_view label) const
inherited

from the label to its index in var.

Warning
This operation may have different complexity in different subclasses.
Exceptions
NotFound

References label().

Here is the call graph for this function:

◆ setDescription()

void gum::Variable::setDescription ( std::string_view theValue) const
inherited

sets the description of the variable

Warning
since description is mutable, setDescription() is const
Parameters
theValue

◆ setEmpirical()

void gum::IDiscretizedVariable::setEmpirical ( bool state)
Parameters
state: change the variabl to empirical or not

References setEmpirical().

Referenced by setEmpirical().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setName()

void gum::Variable::setName ( std::string_view theValue)
inherited

sets the name of the variable

Parameters
theValue

◆ stype()

virtual std::string gum::DiscreteVariable::stype ( ) const
pure virtualinherited

◆ ticksAsDoubles()

virtual std::vector< double > gum::IDiscretizedVariable::ticksAsDoubles ( ) const
pure virtual

return the list of ticks as a vector of doubles

Implemented in gum::DiscretizedVariable< T_TICKS >.

References ticksAsDoubles().

Referenced by ticksAsDoubles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toFast()

virtual std::string gum::DiscreteVariable::toFast ( ) const
pure virtualinherited

◆ toString()

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

string version of *this

Referenced by gum::IntegerVariable::IntegerVariable(), and gum::BNdistance< GUM_SCALAR >::_checkCompatibility_().

Here is the caller graph for this function:

◆ toStringWithDescription()

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

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

◆ varType()

VarType gum::DiscreteVariable::varType ( ) const
overridepure virtualinherited

returns the varType of variable

Implements gum::Variable.

Implemented in gum::DiscretizedVariable< T_TICKS >, gum::IntegerVariable, gum::LabelizedVariable, gum::NumericalDiscreteVariable, and gum::RangeVariable.

Referenced by gum::learning::BNDatabaseGenerator< GUM_SCALAR >::_label_().

Here is the caller graph for this function:

Member Data Documentation

◆ _description_

std::string gum::Variable::_description_
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.

◆ _is_empirical

bool gum::IDiscretizedVariable::_is_empirical
protected

Definition at line 112 of file IDiscretizedVariable.h.

◆ _name_

std::string gum::Variable::_name_
privateinherited

the name of the variable

Definition at line 162 of file variable.h.


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