AbstractConstraintHandler.h
Go to the documentation of this file.
1 //===========================================================================
2 /*!
3  *
4  *
5  * \brief Base class for constraints.
6  *
7  *
8  * \author O.Krause
9  * \date 2013
10  *
11  *
12  * \par Copyright 1995-2015 Shark Development Team
13  *
14  * <BR><HR>
15  * This file is part of Shark.
16  * <http://image.diku.dk/shark/>
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_OBJECTIVEFUNCTIONS_ABSTRACTCONSTRAINTHANDLER_H
34 #define SHARK_OBJECTIVEFUNCTIONS_ABSTRACTCONSTRAINTHANDLER_H
35 
36 #include <shark/Core/Exception.h>
37 #include <shark/Core/Flags.h>
38 
39 namespace shark{
40 
41 
42 /// \brief Implements the base class for constraint handling.
43 ///
44 /// A constraint handler provides information about the feasible region of a constrained optimization problem.
45 /// In the minimum it checks whether a point is feasible, or what the next fasible point would be.
46 template<class SearchPointType>
48 public:
49  enum Feature {
50  CAN_PROVIDE_CLOSEST_FEASIBLE = 1, ///< The constraint handler can provide a close feasible point to an infeasible one
51  IS_BOX_CONSTRAINED = 2, ///< The constraint handler is an instance of BoxConstraintHandler
52  CAN_GENERATE_RANDOM_POINT = 4 ///< The ConstraintHandler can generate a random point inside the feasible region
53  };
55 
57 
58  /// \brief Returns whether this function can calculate the closest feasible to an infeasible point.
61  }
62 
63  /// \brief Returns whether this function is an instance of BoxConstraintHandler
64  bool isBoxConstrained()const{
66  }
67  /// \brief Returns whether this function is an instance of BoxConstraintHandler
70  }
71 
72  /// \brief If supported, generates a random point inside the feasible region.
73  virtual void generateRandomPoint( SearchPointType & startingPoint )const {
75  }
76 
77  /// \brief Returns true if the point is in the feasible Region.
78  ///
79  /// This function must be implemented by a ConstraintHandler
80  virtual bool isFeasible(SearchPointType const&)const = 0;
81  virtual void closestFeasible(SearchPointType& )const{
83  }
84 
85 };
86 }
87 #endif