aGrUM  0.13.2
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 57 of file discreteVariable.h.

Constructor & Destructor Documentation

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

Default constructor.

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
virtual gum::DiscreteVariable::~DiscreteVariable ( )
virtual

destructor

gum::DiscreteVariable::DiscreteVariable ( )
inlineprotected

(protected) Default constructor

Definition at line 157 of file discreteVariable.h.

References gum::operator<<().

157 { GUM_CONSTRUCTOR(DiscreteVariable); };
DiscreteVariable()
(protected) Default constructor

+ Here is the call graph for this function:

Member Function Documentation

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

protected copy

Parameters
aRVto be copied
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< GUM_SCALAR >::addVariable(), and gum::TaxiSimulator::TaxiSimulator().

+ Here is the caller graph for this function:

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

returns the description of the variable

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

string represent the domain of the variable

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

Referenced by operator[]().

+ Here is the caller graph for this function:

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< GUM_SCALAR, TerminalNodePolicy >::__adjacentSwap(), gum::KL< GUM_SCALAR >::__checkCompatibility(), gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::__checkIsomorphism(), 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< GUM_SCALAR >::__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< GUM_SCALAR, TerminalNodePolicy >::__isRedundant(), gum::prm::PRMType< GUM_SCALAR >::__isValid(), gum::StructuredPlaner< GUM_SCALAR >::__recurArgMaxCopy(), gum::StructuredPlaner< GUM_SCALAR >::__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< GUM_SCALAR, TerminalNodePolicy >::_nodeRedundancyCheck(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_transpose(), gum::MultiDimWithOffset< GUM_SCALAR >::add(), gum::MultiDimArray< GUM_SCALAR >::add(), gum::MultiDimImplementation< GUM_SCALAR >::add(), gum::BayesNet< GUM_SCALAR >::addAND(), gum::BayesNet< GUM_SCALAR >::addEXISTS(), gum::BayesNet< GUM_SCALAR >::addFORALL(), gum::BayesNet< GUM_SCALAR >::addOR(), gum::InfluenceDiagram< GUM_SCALAR >::addUtilityNode(), gum::InternalNode::allocateNodeSons(), gum::Instantiation::chgVal(), gum::InternalNode::deallocateNodeSons(), gum::Instantiation::decVar(), gum::IBayesNet< GUM_SCALAR >::dim(), gum::Potential< GUM_SCALAR >::draw(), gum::MultiDimWithOffset< GUM_SCALAR >::erase(), gum::MultiDimArray< GUM_SCALAR >::erase(), gum::MultiDimImplementation< GUM_SCALAR >::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::IBayesNet< GUM_SCALAR >::maxVarDomainSize(), 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(), and gum::BayesNetFactory< GUM_SCALAR >::setVariableValues().

bool gum::DiscreteVariable::empty ( ) const
Returns
true if the domainSize() < 2;
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:

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

get the indice-th label. This method is pure virtual.

Parameters
indicethe index of the label we wish to return
Exceptions
OutOfBound

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

Referenced by gum::KL< GUM_SCALAR >::__checkCompatibility(), gum::BayesNetFactory< GUM_SCALAR >::__checkVariableModality(), gum::prm::PRMSystem< GUM_SCALAR >::__groundAgg(), operator[](), gum::StructuredPlaner< GUM_SCALAR >::optimalPolicy2String(), gum::prm::o3prmr::O3prmrInterpreter::query(), gum::prm::PRMFactory< GUM_SCALAR >::setCPFByRule(), and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::toDot().

+ Here is the caller graph for this function:

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

vector of labels

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

returns the name of the variable

Referenced by gum::KL< GUM_SCALAR >::__checkCompatibility(), gum::BayesNetFactory< GUM_SCALAR >::__setCPTAndParents(), gum::GibbsKL< GUM_SCALAR >::_computeKL(), gum::MultiDimImplementation< GUM_SCALAR >::add(), gum::Instantiation::add(), gum::FMDP< GUM_SCALAR >::addTransitionForAction(), gum::FMDP< GUM_SCALAR >::addVariable(), gum::MultiDimICIModel< GUM_SCALAR >::causalWeight(), gum::Instantiation::chgVal(), gum::learning::genericBNLearner::Database::Database(), gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration(), gum::BayesNetFactory< GUM_SCALAR >::endVariableDeclaration(), gum::MarkovBlanket::hasSameStructure(), gum::BayesNetFragment< GUM_SCALAR >::nodeId(), gum::StructuredPlaner< GUM_SCALAR >::optimalPolicy2String(), gum::Estimator< GUM_SCALAR >::posterior(), 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::IBayesNet< GUM_SCALAR >::toDot(), gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::toDot(), gum::Estimator< GUM_SCALAR >::update(), and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::varNodeListe().

+ Here is the caller graph for this function:

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.

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

inequality operator

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

inequality operator

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

Copy operator.

Parameters
aRVto be copied
Returns
a ref to *this
virtual bool gum::Variable::operator== ( const Variable aRV) const
virtualinherited

equality operator

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

equality 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 137 of file discreteVariable.h.

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

137 { 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:

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
void gum::Variable::setName ( const std::string &  theValue)
inherited

sets the name of the variable

Parameters
theValue

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

+ Here is the caller graph for this function:

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

string version of *this

Referenced by operator[]().

+ Here is the caller graph for this function:

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

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

Referenced by operator[](), and gum::IBayesNet< GUM_SCALAR >::toDot().

+ Here is the caller graph for this function:

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: