AbstractSingleObjectiveOptimizer.h
Go to the documentation of this file.
1 //===========================================================================
2 /*!
3  *
4  *
5  * \brief AbstractSingleObjectiveOptimizer
6  *
7  *
8  *
9  * \author T.Voss, T. Glasmachers, O.Krause
10  * \date 2010-2011
11  *
12  *
13  * \par Copyright 1995-2015 Shark Development Team
14  *
15  * <BR><HR>
16  * This file is part of Shark.
17  * <http://image.diku.dk/shark/>
18  *
19  * Shark is free software: you can redistribute it and/or modify
20  * it under the terms of the GNU Lesser General Public License as published
21  * by the Free Software Foundation, either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * Shark is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU Lesser General Public License for more details.
28  *
29  * You should have received a copy of the GNU Lesser General Public License
30  * along with Shark. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
33 //===========================================================================
34 #ifndef SHARK_OBJECTIVEFUNCTIONS_ABSTRACTSINGLEOBJECTIVEOPTIMIZER_H
35 #define SHARK_OBJECTIVEFUNCTIONS_ABSTRACTSINGLEOBJECTIVEOPTIMIZER_H
36 
38 #include <shark/Core/ResultSets.h>
39 
40 namespace shark {
41  ///\brief Base class for all single objective optimizer
42  ///
43  ///This class is a spezialization of the AbstractOptimizer itnerface for the class of single objective optimizers. A single objective optimizer is an optimizer
44  ///which can only optimize functions with a single objective. This is the default case for most optimisation problems.
45  ///the class requires the ObjectiveFunction to provide a feasible starting point. If this is not possible, a second version of init is provided where the starting point can be
46  ///explicitely defined.
47  ///The Return type of an SingleObjectiveOptimizer is the SingleObjectiveResultSet which is a struct returning the best value of the function and together with it's point.
48  template<class PointType>
49  class AbstractSingleObjectiveOptimizer: public AbstractOptimizer<PointType,double,SingleObjectiveResultSet<PointType> >{
50  private:
52  public:
57 
58  ///initializes the optimizer. The objectivefunction is required to provide a starting point, so CAN_PROPOSE_STARTING_POINT
59  ///must be set. If this is not the case, an exception is thrown
60  virtual void init(ObjectiveFunctionType& function ){
62  throw SHARKEXCEPTION( "[AbstractSingleObjectiveOptimizer::init] Objective function does not propose a starting point");
63  init(function,function.proposeStartingPoint());
64  }
65  ///initializes the optimizer using a predefined starting point
66  virtual void init(ObjectiveFunctionType& function, SearchPointType const& startingPoint)=0;
67  ///returns the current solution of the optimizer
68  virtual const SolutionType& solution() const{
69  return m_best;
70  }
71 
72  protected:
73  ///current solution of the optimizer
74  SolutionType m_best;
75  };
76 
77 }
78 #endif