aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
variableselector.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Headers of the Variable Selector class.
25  *
26  * @author Jean-Christophe MAGNAN
27  */
28 
29 // =========================================================================
30 #ifndef GUM_VARIABLE_SELECTOR_H
31 #define GUM_VARIABLE_SELECTOR_H
32 // =========================================================================
33 #include <agrum/tools/core/multiPriorityQueue.h>
34 #include <agrum/tools/core/set.h>
35 // =========================================================================
36 #include <agrum/tools/variables/discreteVariable.h>
37 // =========================================================================
38 
39 namespace gum {
40 
41  /**
42  * @class VariableSelector variableselector.h
43  * <agrum/FMDP/planning/FunctionGraph/variableselector.h>
44  * @brief
45  * @ingroup fmdp_group
46  *
47  *
48  *
49  */
50 
52  public:
53  // ==========================================================================
54  /// @name Constructor & destructor.
55  // ==========================================================================
56  /// @{
57 
58  // ###################################################################
59  /// Default constructor
60  // ###################################################################
61  VariableSelector(Set< const DiscreteVariable* >& startingSet);
62 
63  // ###################################################################
64  /// Default destructor
65  // ###################################################################
67 
68  /// @}
69 
70  // ==========================================================================
71  /// @name
72  // ==========================================================================
73  /// @{
74 
75  // ###################################################################
76  ///
77  // ###################################################################
78  void updateScore(const DiscreteVariable* var, double score, double secondaryscore);
79  void downdateScore(const DiscreteVariable* var, double score, double secondaryscore);
80 
81 
82  // ###################################################################
83  /// Select the most relevant variable
84  // ###################################################################
85  const DiscreteVariable* select();
86 
87  bool isEmpty() { return _remainingVars_.empty(); }
88 
89  void begin() { _rvi_ = _remainingVars_.beginSafe(); }
90  bool hasNext() { return _rvi_ != _remainingVars_.endSafe(); }
91  void next() { ++_rvi_; }
92  const DiscreteVariable* current() { return *_rvi_; }
93 
94  private:
95  void _addVar_(const DiscreteVariable* var);
96  void _removeVar_(const DiscreteVariable* var);
97 
98  /// The set of remaining vars to select among
101 
102  /// Heap keeping best score on top for immediate access
103  MultiPriorityQueue< double, double, std::greater< double > > _remainingScores_;
104 
105  /// HashTable associating to each score the set of variable having that
106  /// score
108 
109  /// HashTable associating to each variable its score
111 
112  /// HashTable associating to each variable its 2nd score
114  };
115 
116 } // namespace gum
117 
118 #endif // GUM_VARIABLE_SELECTOR_H
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
void downdateScore(const DiscreteVariable *var, double score, double secondaryscore)
The set of remaining vars to select among.
void begin()
The set of remaining vars to select among.
~VariableSelector()
Default destructor.
Set< const DiscreteVariable *> _remainingVars_
The set of remaining vars to select among.
HashTable< const DiscreteVariable *, double > _remainingVarsOtherScore_
HashTable associating to each variable its 2nd score.
bool hasNext()
The set of remaining vars to select among.
const DiscreteVariable * select()
Select the most relevant variable.
HashTable< const DiscreteVariable *, double > _remainingVarsScore_
HashTable associating to each variable its score.
HashTable< double, Set< const DiscreteVariable *> *> _remainingVarsByScore_
HashTable associating to each score the set of variable having that score.
void _removeVar_(const DiscreteVariable *var)
The set of remaining vars to select among.
SetIteratorSafe< const DiscreteVariable *> _rvi_
The set of remaining vars to select among.
bool isEmpty()
The set of remaining vars to select among.
void updateScore(const DiscreteVariable *var, double score, double secondaryscore)
The set of remaining vars to select among.
void next()
The set of remaining vars to select among.
void _addVar_(const DiscreteVariable *var)
The set of remaining vars to select among.
const DiscreteVariable * current()
The set of remaining vars to select among.
VariableSelector(Set< const DiscreteVariable * > &startingSet)
Default constructor.