aGrUM  0.16.0
statesCounter.h
Go to the documentation of this file.
1 
30 // =========================================================================
31 #ifndef GUM_STATES_COUNTER_H
32 #define GUM_STATES_COUNTER_H
33 // =========================================================================
34 #include <agrum/core/sequence.h>
35 // =========================================================================
37 // =========================================================================
39 // =========================================================================
40 
41 namespace gum {
42 
43 
52  public:
53  // ==========================================================================
55  // ==========================================================================
57 
61  StatesCounter();
62 
67 
69 
70  // ==========================================================================
72  // ==========================================================================
74 
75  void incState(const Instantiation&);
76 
77  void reset(const Instantiation&);
78 
80 
82 
83 
84  // ###################################################################
86  // ###################################################################
88  public:
89  // ==========================================================================
91  // ==========================================================================
92  NodeId root() const { return __counter->root(); }
93 
94  // ==========================================================================
96  // ==========================================================================
97  bool isTerminal(NodeId ni) const { return __counter->isTerminalNode(ni); }
98 
99  // ==========================================================================
101  // ==========================================================================
102  const DiscreteVariable* nodeVar(NodeId ni) const {
103  return __counter->node(ni)->nodeVar();
104  }
105 
106  // ==========================================================================
108  // ==========================================================================
109  NodeId nodeSon(NodeId ni, Idx modality) const {
110  return __counter->node(ni)->son(modality);
111  }
112 
113  // ==========================================================================
115  // ==========================================================================
116  Idx nodeNbObservation(NodeId ni) const { return __counter->nodeValue(ni); }
117 
120  __counter->variablesSequence().beginSafe();
121  varIter != __counter->variablesSequence().endSafe();
122  ++varIter)
123  ret->add(**varIter);
124  }
125 
126 
128 
129  private:
130  void __incState(const Instantiation&, NodeId, Idx, Size);
131 
133 
135  };
136 } /* namespace gum */
137 
138 #endif // GUM_STATES_COUNTER_H
NodeId root() const
Definition: statesCounter.h:92
Safe iterators for Sequence.
Definition: sequence.h:1206
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool isTerminalNode(const NodeId &node) const
Indicates if given node is terminal or not.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const InternalNode * node(NodeId n) const
Returns internalNode structure associated to that nodeId.
<agrum/FMDP/simulation/statesCounter.h>
Definition: statesCounter.h:51
const DiscreteVariable * nodeVar() const
Returns the node variable.
NodeId son(Idx modality) const
Returns the son at a given index.
<agrum/FMDP/SDyna/IVisitableGraphLearner.h>
void insertSetOfVars(MultiDimFunctionGraph< double > *ret) const
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
const MultiDimFunctionGraph< int > * counter()
Idx nodeNbObservation(NodeId ni) const
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
const GUM_SCALAR & nodeValue(NodeId n) const
Returns value associated to given node.
MultiDimFunctionGraph< Size > * __counter
const DiscreteVariable * nodeVar(NodeId ni) const
const NodeId & root() const
Returns the id of the root node from the diagram.
Class implementingting a function graph.
~StatesCounter()
Default destructor.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void reset(const Instantiation &)
NodeId nodeSon(NodeId ni, Idx modality) const
void __incState(const Instantiation &, NodeId, Idx, Size)
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
Set< Instantiation *> __visitedStates
void incState(const Instantiation &)
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
StatesCounter()
Default constructor.
bool isTerminal(NodeId ni) const
Definition: statesCounter.h:97
Size NodeId
Type for node ids.
Definition: graphElements.h:98