Unfit  3.1.1
Data fitting and optimization software
Bounds.hpp
1 // Unfit: Data fitting and optimization software
2 //
3 // Copyright (C) 2012- Dr Martin Buist & Dr Alberto Corrias
4 // Contacts: martin.buist _at_ nus.edu.sg; alberto _at_ nus.edu.sg
5 //
6 // See the 'Contributors' file for a list of those who have contributed
7 // to this work.
8 //
9 // This program is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 //
22 #ifndef UNFIT_INCLUDE_BOUNDS_HPP_
23 #define UNFIT_INCLUDE_BOUNDS_HPP_
24 
25 #include <vector>
26 
27 namespace Unfit
28 {
39 class Bounds
40 {
41  public:
45  Bounds();
46 
55  Bounds(std::size_t number_of_bounds);
56 
66  void ClampWithinBounds(std::vector<double> &point);
67 
75  void GetBounds(std::vector<double> &lower_bound,
76  std::vector<double> &upper_bound) const;
77 
85  std::size_t GetNumberOfBounds() const noexcept;
86 
99  bool IsAboveLowerBound(std::size_t index, double point) const noexcept;
100 
113  bool IsBelowUpperBound(std::size_t index, double point) const noexcept;
114 
127  bool IsWithinBounds(std::size_t index, double point) const noexcept;
128 
140  bool IsWithinBounds(const std::vector<double> &point) const noexcept;
141 
147  void ResetBounds();
148 
161  bool SetBounds(std::size_t index, double lower_bound, double upper_bound);
162 
178  bool SetBounds(const std::vector<double> &lower_bound,
179  const std::vector<double> &upper_bound);
180 
194  void SetNumberOfBounds(std::size_t number_of_bounds);
195 
206  double GetLowerBound(std::size_t index) const noexcept;
207 
220  bool SetLowerBound(std::size_t index, double lower_bound);
221 
232  double GetUpperBound(std::size_t index) const noexcept;
233 
246  bool SetUpperBound(std::size_t index, double upper_bound);
247 
248  private:
250  std::vector<double> upper_bound_;
252  std::vector<double> lower_bound_;
253 };
254 
255 } // namespace Unfit
256 
257 #endif
void GetBounds(std::vector< double > &lower_bound, std::vector< double > &upper_bound) const
Definition: Bounds.cpp:44
bool IsBelowUpperBound(std::size_t index, double point) const noexcept
Definition: Bounds.cpp:71
bool SetLowerBound(std::size_t index, double lower_bound)
Definition: Bounds.cpp:142
Definition: Bounds.hpp:27
double GetUpperBound(std::size_t index) const noexcept
Definition: Bounds.cpp:147
void ClampWithinBounds(std::vector< double > &point)
Definition: Bounds.cpp:51
std::vector< double > upper_bound_
Definition: Bounds.hpp:250
void ResetBounds()
Definition: Bounds.cpp:93
double GetLowerBound(std::size_t index) const noexcept
Definition: Bounds.cpp:136
std::size_t GetNumberOfBounds() const noexcept
Definition: Bounds.cpp:59
bool IsWithinBounds(std::size_t index, double point) const noexcept
Definition: Bounds.cpp:78
void SetNumberOfBounds(std::size_t number_of_bounds)
Definition: Bounds.cpp:130
bool IsAboveLowerBound(std::size_t index, double point) const noexcept
Definition: Bounds.cpp:64
Bounds()
Definition: Bounds.cpp:34
bool SetUpperBound(std::size_t index, double upper_bound)
Definition: Bounds.cpp:153
std::vector< double > lower_bound_
Definition: Bounds.hpp:252
Definition: Bounds.hpp:39
bool SetBounds(std::size_t index, double lower_bound, double upper_bound)
Definition: Bounds.cpp:99