aGrUM  0.16.0
discreteVariable.h
Go to the documentation of this file.
1 
29 #ifndef GUM_DISCRETE_VARIABLE_H
30 #define GUM_DISCRETE_VARIABLE_H
31 
32 #include <ostream>
33 #include <string>
34 
35 #include <agrum/agrum.h>
36 
37 #include <agrum/core/hashFunc.h>
39 
40 namespace gum {
41 
42  /* ===========================================================================
43  */
44  /* ===========================================================================
45  */
46  /* === GUM_DISCRETE_VARIABLE ===
47  */
48  /* ===========================================================================
49  */
50  /* ===========================================================================
51  */
57  /* ===========================================================================
58  */
59 
60  class DiscreteVariable : public Variable {
61  public:
62  // ############################################################################
64  // ############################################################################
66 
68 
69  DiscreteVariable(const std::string& aName, const std::string& aDesc);
70 
72 
80 
82 
83  virtual ~DiscreteVariable();
84 
87 
88  virtual DiscreteVariable* clone() const = 0;
89 
91 
92  // ############################################################################
94  // ############################################################################
96 
98 
99  bool empty() const;
100 
102 
103  virtual Size domainSize() const = 0;
104 
106  std::vector< std::string > labels() const;
107 
109  virtual double numerical(Idx indice) const = 0;
110 
112 
113  virtual VarType varType() const = 0;
115 
116  // ############################################################################
118  // ############################################################################
120 
122 
126 
128  virtual bool operator==(const DiscreteVariable& aRV) const;
129 
131 
132  virtual bool operator!=(const DiscreteVariable& aRV) const;
133 
135 
140  Idx operator[](const std::string& label) const { return index(label); };
141  virtual Idx index(const std::string& label) const = 0;
142 
144 
147  virtual std::string label(Idx i) const = 0;
148 
150  const std::string toString() const;
151 
153  const std::string toStringWithDescription() const;
154 
156  virtual const std::string domain() const = 0;
157 
158  protected:
160  DiscreteVariable() { GUM_CONSTRUCTOR(DiscreteVariable); };
161  };
162 
164 
165  std::ostream& operator<<(std::ostream&, const DiscreteVariable&);
166 
167 } /* namespace gum */
168 
169 #ifndef GUM_NO_INLINE
171 #endif /* GUM_NO_INLINE */
172 
173 #endif /* GUM_DISCRETE_VARIABLE_H */
std::vector< std::string > labels() const
vector of labels
Base class for every random variable.
Definition: variable.h:66
DiscreteVariable & operator=(const DiscreteVariable &aRV)
Copy operator.
virtual double numerical(Idx indice) const =0
get a numerical representation of the indice-th value.
virtual const std::string domain() const =0
string represent the domain of the variable
virtual DiscreteVariable * clone() const =0
Copy Factory.
virtual VarType varType() const =0
returns the varType of variable
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Idx operator[](const std::string &label) const
from the label to its index in var.
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
virtual bool operator==(const DiscreteVariable &aRV) const
equality operator
const std::string toStringWithDescription() const
string version of *this using description attribute instead of name.
virtual Size domainSize() const =0
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map&#39;s DAG in output using the Graphviz-dot format.
Definition: BayesNet_tpl.h:605
virtual std::string label(Idx i) const =0
get the indice-th label. This method is pure virtual.
virtual bool operator!=(const DiscreteVariable &aRV) const
inequality operator
VarType
Definition: variable.h:41
virtual Idx index(const std::string &label) const =0
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual ~DiscreteVariable()
destructor
DiscreteVariable()
(protected) Default constructor
const std::string toString() const
string version of *this
Size Idx
Type for indexes.
Definition: types.h:53
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48