AbstractStoppingCriterion.h
Go to the documentation of this file.
1 /*!
2  *
3  *
4  * \brief Defines a base class for stopping criteria of optimization algorithms.
5  *
6  *
7  *
8  * \author O. Krause
9  * \date 2010
10  *
11  *
12  * \par Copyright 1995-2017 Shark Development Team
13  *
14  * <BR><HR>
15  * This file is part of Shark.
16  * <http://shark-ml.org/>
17  *
18  * Shark is free software: you can redistribute it and/or modify
19  * it under the terms of the GNU Lesser General Public License as published
20  * by the Free Software Foundation, either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * Shark is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU Lesser General Public License for more details.
27  *
28  * You should have received a copy of the GNU Lesser General Public License
29  * along with Shark. If not, see <http://www.gnu.org/licenses/>.
30  *
31  */
32 
33 #ifndef SHARK_ALGORITHMS_ABSTRACTSTOPPINGCRITERION_H
34 #define SHARK_ALGORITHMS_ABSTRACTSTOPPINGCRITERION_H
35 
36 namespace shark{
37 
38 /// \brief Base class for stopping criteria of optimization algorithms.
39 ///
40 /// Each stopping criterion provides a stop method which takes as argument
41 /// the latest result of an optimization algorithm. This result is passed
42 /// as a ResultSetT, which is a template type of this interface. In actual
43 /// implementations, that type will usually hold the latest objective
44 /// function value reached by the optimizer on the training set, but may
45 /// also additionally encapsulate a performance value reached on a validation
46 /// set. The stopping criteria may then use this information to reach their
47 /// characteristic decision of whether or not stopping the optimization
48 /// process is indicated or not.
49 ///
50 template<class ResultSetT>
52 public:
53  typedef ResultSetT ResultSet;
54  ///resets the internal state. call before a new trial
55  virtual void reset() = 0;
56  ///after an iteration, updates the internal state and checks whether the algorithm should stop
57  ///@param set the result of the current iteration
58  virtual bool stop(ResultSet const& set) = 0;
59 };
60 
61 }
62 
63 #endif