aGrUM  0.16.0
gum::DiscreteVariable Class Referenceabstract

Base class for discrete random variable. More...

#include <discreteVariable.h>

+ Inheritance diagram for gum::DiscreteVariable:
+ Collaboration diagram for gum::DiscreteVariable:

Public Member Functions

Idx operator[] (const std::string &label) const
 from the label to its index in var. More...
 
virtual Idx index (const std::string &label) const =0
 
virtual std::string label (Idx i) const =0
 get the indice-th label. This method is pure virtual. More...
 
const std::string toString () const
 string version of *this More...
 
const std::string toStringWithDescription () const
 string version of *this using description attribute instead of name. More...
 
virtual const std::string domain () const =0
 string represent the domain of the variable More...
 
Constructors / Destructors
 DiscreteVariable (const std::string &aName, const std::string &aDesc)
 Default constructor. More...
 
 DiscreteVariable (const DiscreteVariable &aDRV)
 Copy constructor. More...
 
virtual ~DiscreteVariable ()
 destructor More...
 
virtual DiscreteVariableclone () const =0
 Copy Factory. More...
 
Accessors / Modifiers
bool empty () const
 
virtual Size domainSize () const =0
 
std::vector< std::string > labels () const
 vector of labels More...
 
virtual double numerical (Idx indice) const =0
 get a numerical representation of the indice-th value. More...
 
virtual VarType varType () const =0
 returns the varType of variable More...
 
Operators
DiscreteVariableoperator= (const DiscreteVariable &aRV)
 Copy operator. More...
 
virtual bool operator== (const DiscreteVariable &aRV) const
 equality operator More...
 
virtual bool operator!= (const DiscreteVariable &aRV) const
 inequality operator More...
 
Operators
virtual bool operator== (const Variable &aRV) const
 equality operator More...
 
virtual bool operator!= (const Variable &aRV) const
 inequality operator More...
 
Accessors / Modifiers
void setName (const std::string &theValue)
 sets the name of the variable More...
 
const std::string & name () const
 returns the name of the variable More...
 
void setDescription (const std::string &theValue) const
 sets the description of the variable More...
 
const std::string & description () const
 returns the description of the variable More...
 

Protected Member Functions

 DiscreteVariable ()
 (protected) Default constructor More...
 
void _copy (const Variable &aRV)
 protected copy More...
 

Detailed Description

Base class for discrete random variable.

This class is used as an interface.

Definition at line 60 of file discreteVariable.h.

Constructor & Destructor Documentation

◆ DiscreteVariable() [1/3]

gum::DiscreteVariable::DiscreteVariable ( const std::string &  aName,
const std::string &  aDesc 
)

Default constructor.

◆ DiscreteVariable() [2/3]

gum::DiscreteVariable::DiscreteVariable ( const DiscreteVariable aDRV)

Copy constructor.

Copy Constructor.

If aDRV haves any listener, it will not be copied.

Parameters
aDRVthe variable we copy

◆ ~DiscreteVariable()

virtual gum::DiscreteVariable::~DiscreteVariable ( )
virtual

destructor

◆ DiscreteVariable() [3/3]

gum::DiscreteVariable::DiscreteVariable ( )
inlineprotected

(protected) Default constructor

Definition at line 160 of file discreteVariable.h.

References gum::operator<<().

160 { GUM_CONSTRUCTOR(DiscreteVariable); };
DiscreteVariable()
(protected) Default constructor
+ Here is the call graph for this function:

Member Function Documentation

◆ _copy()

void gum::Variable::_copy ( const Variable aRV)
protectedinherited

protected copy

Parameters
aRVto be copied

◆ clone()

virtual DiscreteVariable* gum::DiscreteVariable::clone ( ) const
pure virtual

Copy Factory.

Returns
Returns a pointer on a new copy of this.

Implements gum::Variable.

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

Referenced by gum::FMDP< double >::addVariable(), and gum::TaxiSimulator::TaxiSimulator().

+ Here is the caller graph for this function:

◆ description()

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

returns the description of the variable

◆ domain()

virtual const std::string gum::DiscreteVariable::domain ( ) const
pure virtual

string represent the domain of the variable

Implements gum::Variable.

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

Referenced by operator[]().

+ Here is the caller graph for this function:

◆ domainSize()

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

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

Referenced by gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::__adjacentSwap(), gum::BNdistance< GUM_SCALAR >::__checkCompatibility(), gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::__checkIsomorphism(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkParameterValue(), gum::TreeOperator< GUM_SCALAR, COMBINEOPERATOR, TerminalNodePolicy >::__checkRedundancy(), gum::BayesNetFactory< GUM_SCALAR >::__checkVariableModality(), gum::Regress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::__compute(), gum::MultiDimFunctionGraphOperator< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >::__compute(), gum::prm::PRMSystem< double >::__groundAgg(), gum::StatesCounter::__incState(), gum::IMDDI< AttributeSelection, isScalar >::__insertLeafInFunctionGraph(), gum::StatesChecker::__insertState(), gum::ITI< AttributeSelection, isScalar >::__insertTerminalNode(), gum::credal::CredalNet< GUM_SCALAR >::__intervalToCredal(), gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::__isRedundant(), gum::prm::PRMType::__isValid(), gum::StructuredPlaner< double >::__recurArgMaxCopy(), gum::StructuredPlaner< double >::__recurExtractOptPol(), gum::NodeDatabase< AttributeSelection, isScalar >::__valueDomain(), gum::AdaptiveRMaxPlaner::__visitLearner(), gum::TreeOperator< GUM_SCALAR, COMBINEOPERATOR, TerminalNodePolicy >::__xPloreDT2(), gum::TreeRegress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::__xPloreVFunc(), gum::aggregator::Median< GUM_SCALAR >::_buildValue(), gum::MultiDimWithOffset< GUM_SCALAR >::_computeInstantiationValue(), gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::_nodeRedundancyCheck(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_transpose(), gum::prm::PRMFormAttribute< GUM_SCALAR >::_type(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::_type(), gum::MultiDimWithOffset< GUM_SCALAR >::add(), gum::MultiDimDecorator< GUM_SCALAR >::add(), gum::MultiDimArray< GUM_SCALAR >::add(), gum::MultiDimImplementation< std::string >::add(), gum::BayesNet< double >::addAND(), gum::BayesNet< double >::addEXISTS(), gum::BayesNet< double >::addFORALL(), gum::prm::PRMFactory< GUM_SCALAR >::addLabel(), gum::BayesNet< double >::addOR(), gum::InfluenceDiagram< GUM_SCALAR >::addUtilityNode(), gum::InternalNode::allocateNodeSons(), gum::Instantiation::chgVal(), gum::InternalNode::deallocateNodeSons(), gum::Instantiation::decVar(), gum::Potential< GUM_SCALAR >::draw(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscreteType(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscretizedType(), gum::MultiDimWithOffset< GUM_SCALAR >::erase(), gum::MultiDimArray< GUM_SCALAR >::erase(), gum::MultiDimImplementation< std::string >::erase(), gum::credal::CredalNet< GUM_SCALAR >::fillConstraint(), gum::Potential< GUM_SCALAR >::fillWith(), gum::MultiDimFunctionGraphGenerator::generate(), gum::aggregator::MultiDimAggregator< GUM_SCALAR >::get(), gum::getMaxModality(), gum::Instantiation::incVar(), gum::credal::CredalNet< GUM_SCALAR >::intervalToCredal(), gum::credal::CredalNet< GUM_SCALAR >::intervalToCredalWithFiles(), gum::credal::CredalNet< GUM_SCALAR >::lagrangeNormalization(), gum::MultiDimFunctionGraphProjector< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >::project(), gum::MultiDimInterface::replace(), gum::VariableSelector::select(), gum::prm::PRMFactory< GUM_SCALAR >::setCPFByRule(), gum::credal::CredalNet< GUM_SCALAR >::setCPT(), gum::credal::CredalNet< GUM_SCALAR >::setCPTs(), gum::Instantiation::setLastVar(), gum::BayesNetFactory< GUM_SCALAR >::setVariableValues(), gum::prm::PRMFormAttribute< GUM_SCALAR >::swap(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::swap().

◆ empty()

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

◆ index()

virtual Idx gum::DiscreteVariable::index ( const std::string &  label) const
pure virtual

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

Referenced by operator[]().

+ Here is the caller graph for this function:

◆ label()

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

◆ labels()

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

vector of labels

◆ name()

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

returns the name of the variable

Referenced by gum::BNdistance< GUM_SCALAR >::__checkCompatibility(), gum::prm::PRMFactory< GUM_SCALAR >::__retrieveCommonType(), gum::prm::PRMFactory< GUM_SCALAR >::__retrieveInputs(), gum::BayesNetFactory< GUM_SCALAR >::__setCPTAndParents(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::MultiDimImplementation< std::string >::add(), gum::Instantiation::add(), gum::FMDP< double >::addTransitionForAction(), gum::FMDP< double >::addVariable(), gum::MultiDimICIModel< GUM_SCALAR >::causalWeight(), gum::Instantiation::chgVal(), gum::learning::genericBNLearner::Database::Database(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscreteType(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscretizedType(), gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration(), gum::BayesNetFactory< GUM_SCALAR >::endVariableDeclaration(), gum::MarkovBlanket::hasSameStructure(), gum::BayesNetFragment< GUM_SCALAR >::nodeId(), gum::StructuredPlaner< double >::optimalPolicy2String(), gum::Estimator< GUM_SCALAR >::posterior(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), gum::Instantiation::setValsFrom(), gum::BayesNetFactory< GUM_SCALAR >::setVariable(), gum::BayesNetFactory< GUM_SCALAR >::setVariableValues(), gum::BayesNetFactory< GUM_SCALAR >::setVariableValuesUnchecked(), gum::MarkovBlanket::toDot(), gum::EssentialGraph::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), gum::prm::ClassBayesNet< GUM_SCALAR >::toDot(), gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >::toDot(), gum::Estimator< GUM_SCALAR >::update(), and gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >::varNodeListe().

◆ numerical()

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

get a numerical representation of the indice-th value.

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

◆ operator!=() [1/2]

virtual bool gum::Variable::operator!= ( const Variable aRV) const
virtualinherited

inequality operator

◆ operator!=() [2/2]

virtual bool gum::DiscreteVariable::operator!= ( const DiscreteVariable aRV) const
virtual

inequality operator

◆ operator=()

DiscreteVariable& gum::DiscreteVariable::operator= ( const DiscreteVariable aRV)

Copy operator.

Parameters
aRVto be copied
Returns
a ref to *this

◆ operator==() [1/2]

virtual bool gum::Variable::operator== ( const Variable aRV) const
virtualinherited

equality operator

◆ operator==() [2/2]

virtual bool gum::DiscreteVariable::operator== ( const DiscreteVariable aRV) const
virtual

equality operator

◆ operator[]()

Idx gum::DiscreteVariable::operator[] ( const std::string &  label) const
inline

from the label to its index in var.

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

Definition at line 140 of file discreteVariable.h.

References domain(), index(), label(), toString(), and toStringWithDescription().

140 { return index(label); };
virtual std::string label(Idx i) const =0
get the indice-th label. This method is pure virtual.
virtual Idx index(const std::string &label) const =0
+ Here is the call graph for this function:

◆ setDescription()

void gum::Variable::setDescription ( const std::string &  theValue) const
inherited

sets the description of the variable

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

◆ setName()

void gum::Variable::setName ( const std::string &  theValue)
inherited

sets the name of the variable

Parameters
theValue

Referenced by gum::prm::PRMSystem< double >::__groundAttr(), gum::prm::PRMType::__updateName(), gum::FMDP< double >::addVariable(), and gum::TaxiSimulator::TaxiSimulator().

+ Here is the caller graph for this function:

◆ toString()

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

string version of *this

Referenced by operator[]().

+ Here is the caller graph for this function:

◆ toStringWithDescription()

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

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

Referenced by operator[]().

+ Here is the caller graph for this function:

◆ varType()

virtual VarType gum::DiscreteVariable::varType ( ) const
pure virtual

returns the varType of variable

Implements gum::Variable.

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


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