aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
statesCounter.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
49
50// =========================================================================
51#ifndef GUM_STATES_COUNTER_H
52#define GUM_STATES_COUNTER_H
53// =========================================================================
54// =========================================================================
56
57// =========================================================================
58// =========================================================================
59
60namespace gum {
61
62
71 public:
72 // ==========================================================================
74 // ==========================================================================
76
81
86
88
89 // ==========================================================================
91 // ==========================================================================
93
94 void incState(const Instantiation&);
95
96 void reset(const Instantiation&);
97
99
101
102
103 // ###################################################################
105 // ###################################################################
107
108 public:
109 // ==========================================================================
111 // ==========================================================================
112 NodeId root() const { return _counter_->root(); }
113
114 // ==========================================================================
116 // ==========================================================================
117 bool isTerminal(NodeId ni) const { return _counter_->isTerminalNode(ni); }
118
119 // ==========================================================================
121 // ==========================================================================
122 const DiscreteVariable* nodeVar(NodeId ni) const { return _counter_->node(ni)->nodeVar(); }
123
124 // ==========================================================================
126 // ==========================================================================
127 NodeId nodeSon(NodeId ni, Idx modality) const { return _counter_->node(ni)->son(modality); }
128
129 // ==========================================================================
131 // ==========================================================================
132 Idx nodeNbObservation(NodeId ni) const { return _counter_->nodeValue(ni); }
133
136 = _counter_->variablesSequence().beginSafe();
137 varIter != _counter_->variablesSequence().endSafe();
138 ++varIter)
139 ret->add(**varIter);
140 }
141
143
144 private:
145 void _incState_(const Instantiation&, NodeId, Idx, Size);
146
148
150 };
151} /* namespace gum */
152
153#endif // GUM_STATES_COUNTER_H
Headers of the Learning Strategy interface.
Base class for discrete random variable.
<agrum/FMDP/SDyna/IVisitableGraphLearner.h>
Class for assigning/browsing values to tuples of discrete variables.
Class implementingting a function graph.
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
Safe iterators for Sequence.
Definition sequence.h:1134
Representation of a set.
Definition set.h:131
void _incState_(const Instantiation &, NodeId, Idx, Size)
const MultiDimFunctionGraph< int > * counter()
NodeId nodeSon(NodeId ni, Idx modality) const
StatesCounter()
Default constructor.
bool isTerminal(NodeId ni) const
Idx nodeNbObservation(NodeId ni) const
void incState(const Instantiation &)
void reset(const Instantiation &)
void insertSetOfVars(MultiDimFunctionGraph< double > *ret) const
MultiDimFunctionGraph< Size > * _counter_
~StatesCounter()
Default destructor.
NodeId root() const
Set< Instantiation * > _visitedStates_
const DiscreteVariable * nodeVar(NodeId ni) const
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size Idx
Type for indexes.
Definition types.h:79
Size NodeId
Type for node ids.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46