aGrUM  0.14.2
statesCounter.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 // =========================================================================
28 #ifndef GUM_STATES_COUNTER_H
29 #define GUM_STATES_COUNTER_H
30 // =========================================================================
31 #include <agrum/core/sequence.h>
32 // =========================================================================
34 // =========================================================================
36 // =========================================================================
37 
38 namespace gum {
39 
40 
49  public:
50  // ==========================================================================
52  // ==========================================================================
54 
58  StatesCounter();
59 
64 
66 
67  // ==========================================================================
69  // ==========================================================================
71 
72  void incState(const Instantiation&);
73 
74  void reset(const Instantiation&);
75 
77 
79 
80 
81  // ###################################################################
83  // ###################################################################
85  public:
86  // ==========================================================================
88  // ==========================================================================
89  NodeId root() const { return __counter->root(); }
90 
91  // ==========================================================================
93  // ==========================================================================
94  bool isTerminal(NodeId ni) const { return __counter->isTerminalNode(ni); }
95 
96  // ==========================================================================
98  // ==========================================================================
99  const DiscreteVariable* nodeVar(NodeId ni) const {
100  return __counter->node(ni)->nodeVar();
101  }
102 
103  // ==========================================================================
105  // ==========================================================================
106  NodeId nodeSon(NodeId ni, Idx modality) const {
107  return __counter->node(ni)->son(modality);
108  }
109 
110  // ==========================================================================
112  // ==========================================================================
113  Idx nodeNbObservation(NodeId ni) const { return __counter->nodeValue(ni); }
114 
117  __counter->variablesSequence().beginSafe();
118  varIter != __counter->variablesSequence().endSafe();
119  ++varIter)
120  ret->add(**varIter);
121  }
122 
123 
125 
126  private:
127  void __incState(const Instantiation&, NodeId, Idx, Size);
128 
130 
132  };
133 } /* namespace gum */
134 
135 #endif // GUM_STATES_COUNTER_H
NodeId root() const
Definition: statesCounter.h:89
Safe iterators for Sequence.
Definition: sequence.h:1203
Headers of the Learning Strategy interface.
bool isTerminalNode(const NodeId &node) const
Indicates if given node is terminal or not.
Header file of gum::Sequence, a class for storing (ordered) sequences of objects. ...
const InternalNode * node(NodeId n) const
Returns internalNode structure associated to that nodeId.
<agrum/FMDP/simulation/statesCounter.h>
Definition: statesCounter.h:48
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.
gum is the global namespace for all aGrUM entities
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:162
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
Definition: statesCounter.h:99
const NodeId & root() const
Returns the id of the root node from the diagram.
Class implementingting a function graph.
~StatesCounter()
Default destructor.
Headers of MultiDimFunctionGraph.
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:80
Set< Instantiation *> __visitedStates
void incState(const Instantiation &)
Size Idx
Type for indexes.
Definition: types.h:50
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
StatesCounter()
Default constructor.
bool isTerminal(NodeId ni) const
Definition: statesCounter.h:94
Size NodeId
Type for node ids.
Definition: graphElements.h:97