aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
localSearchWithTabuList.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 The local search learning with tabu list algorithm (for directed
25  * graphs)
26  *
27  * The LocalSearchWithTabuList class implements a greedy search in which we
28  * allow applying at most N consecutive graph changes that decrease the score.
29  * To prevent infinite loops, when using local search, you should use a
30  * structural constraint that includes a tabu list of at least N elements.
31  *
32  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
33  */
34 #ifndef GUM_LEARNING_LOCAL_SEARCH_WITH_TABU_LIST_H
35 #define GUM_LEARNING_LOCAL_SEARCH_WITH_TABU_LIST_H
36 
37 #include <string>
38 #include <vector>
39 
40 #include <agrum/BN/BayesNet.h>
41 #include <agrum/tools/core/approximations/approximationScheme.h>
42 #include <agrum/tools/graphs/DAG.h>
43 
44 namespace gum {
45 
46  namespace learning {
47 
48  /** @class LocalSearchWithTabuList
49  * @brief The local search with tabu list learning algorithm (for
50  * directed graphs)
51  *
52  * The LocalSearchWithTabuList class implements a greedy search in which we
53  * allow applying at most N consecutive graph changes that decrease the
54  *score.
55  * To prevent infinite loops, when using local search, you should use a
56  * structural constraint that includes a tabu list of at least N elements.
57  *
58  * @ingroup learning_group
59  */
61  public:
62  // ##########################################################################
63  /// @name Constructors / Destructors
64  // ##########################################################################
65  /// @{
66 
67  /// default constructor
69 
70  /// copy constructor
72 
73  /// move constructor
75 
76  /// destructor
77  virtual ~LocalSearchWithTabuList();
78 
79  /// @}
80 
81  // ##########################################################################
82  /// @name Operators
83  // ##########################################################################
84  /// @{
85 
86  /// copy operator
88 
89  /// move operator
91 
92  /// @}
93 
94  // ##########################################################################
95  /// @name Accessors / Modifiers
96  // ##########################################################################
97  /// @{
98 
99  /// returns the approximation policy of the learning algorithm
101 
102  /// set the max number of changes decreasing the score that we allow to
103  /// apply
104  void setMaxNbDecreasingChanges(Size nb);
105 
106  /// learns the structure of a Bayes net
107  /** @param selector A selector class that computes the best changes that
108  * can be applied and that enables the user to get them very easily.
109  * Typically, the selector is a GraphChangesSelector4DiGraph<SCORE,
110  * STRUCT_CONSTRAINT, GRAPH_CHANGES_GENERATOR>.
111  * @param initial_dag the DAG we start from for our learning */
112  template < typename GRAPH_CHANGES_SELECTOR >
114 
115  /// learns the structure and the parameters of a BN
116  template < typename GUM_SCALAR = double,
117  typename GRAPH_CHANGES_SELECTOR,
118  typename PARAM_ESTIMATOR >
121  DAG initial_dag = DAG());
122 
123  /// @}
124 
125  private:
126  /// the max number of changes decreasing the score that we allow to apply
128  };
129 
130  } /* namespace learning */
131 
132 } /* namespace gum */
133 
134 /// include the inlined functions if necessary
135 #ifndef GUM_NO_INLINE
136 # include <agrum/BN/learning/localSearchWithTabuList_inl.h>
137 #endif /* GUM_NO_INLINE */
138 
139 /// always include templated methods
140 #include <agrum/BN/learning/localSearchWithTabuList_tpl.h>
141 
142 #endif /* GUM_LEARNING_LOCAL_SEARCH_WITH_TABU_LIST_H */
LocalSearchWithTabuList()
default constructor
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
LocalSearchWithTabuList & operator=(LocalSearchWithTabuList &&from)
move operator
LocalSearchWithTabuList & operator=(const LocalSearchWithTabuList &from)
copy operator
Size _MaxNbDecreasing_
the max number of changes decreasing the score that we allow to apply
virtual ~LocalSearchWithTabuList()
destructor
LocalSearchWithTabuList(LocalSearchWithTabuList &&from)
move constructor
LocalSearchWithTabuList(const LocalSearchWithTabuList &from)
copy constructor
ApproximationScheme & approximationScheme()
returns the approximation policy of the learning algorithm
BayesNet< GUM_SCALAR > learnBN(GRAPH_CHANGES_SELECTOR &selector, PARAM_ESTIMATOR &estimator, DAG initial_dag=DAG())
learns the structure and the parameters of a BN
The local search with tabu list learning algorithm (for directed graphs)
DAG learnStructure(GRAPH_CHANGES_SELECTOR &selector, DAG initial_dag=DAG())
learns the structure of a Bayes net
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
void setMaxNbDecreasingChanges(Size nb)
set the max number of changes decreasing the score that we allow to apply