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-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_OBJECTIVEFUNCTIONS_ABSTRACTCONSTRAINTHANDLER_H
34 #define SHARK_OBJECTIVEFUNCTIONS_ABSTRACTCONSTRAINTHANDLER_H
35 
36 #include <shark/Core/Exception.h>
37 #include <shark/Core/Flags.h>
38 #include <shark/Core/Random.h>
39 
40 namespace shark{
41 
42 
43 /// \brief Implements the base class for constraint handling.
44 ///
45 /// A constraint handler provides information about the feasible region of a constrained optimization problem.
46 /// In the minimum it checks whether a point is feasible, or what the next fasible point would be.
47 template<class SearchPointType>
49 public:
50  enum Feature {
51  CAN_PROVIDE_CLOSEST_FEASIBLE = 1, ///< The constraint handler can provide a close feasible point to an infeasible one
52  IS_BOX_CONSTRAINED = 2, ///< The constraint handler is an instance of BoxConstraintHandler
53  CAN_GENERATE_RANDOM_POINT = 4 ///< The ConstraintHandler can generate a random point inside the feasible region
54  };
56 
58 
59  /// \brief Returns whether this function can calculate the closest feasible to an infeasible point.
62  }
63 
64  /// \brief Returns whether this function is an instance of BoxConstraintHandler
65  bool isBoxConstrained()const{
67  }
68  /// \brief Returns whether this function is an instance of BoxConstraintHandler
71  }
72 
73  /// \brief If supported, generates a random point inside the feasible region.
74  ///
75  /// \param rng The random number generator used for generating the point
76  /// \param startingPoint The proposed point
77  virtual void generateRandomPoint( random::rng_type& rng, SearchPointType & startingPoint )const {
79  }
80 
81  /// \brief Returns true if the point is in the feasible Region.
82  ///
83  /// This function must be implemented by a ConstraintHandler
84  virtual bool isFeasible(SearchPointType const&)const = 0;
85  virtual void closestFeasible(SearchPointType& )const{
87  }
88 
89 };
90 }
91 #endif