|
Unfit
3.1.1
Data fitting and optimization software
|
#include <Bounds.hpp>
Public Member Functions | |
| Bounds () | |
| Bounds (std::size_t number_of_bounds) | |
| void | ClampWithinBounds (std::vector< double > &point) |
| void | GetBounds (std::vector< double > &lower_bound, std::vector< double > &upper_bound) const |
| std::size_t | GetNumberOfBounds () const noexcept |
| bool | IsAboveLowerBound (std::size_t index, double point) const noexcept |
| bool | IsBelowUpperBound (std::size_t index, double point) const noexcept |
| bool | IsWithinBounds (std::size_t index, double point) const noexcept |
| bool | IsWithinBounds (const std::vector< double > &point) const noexcept |
| void | ResetBounds () |
| bool | SetBounds (std::size_t index, double lower_bound, double upper_bound) |
| bool | SetBounds (const std::vector< double > &lower_bound, const std::vector< double > &upper_bound) |
| void | SetNumberOfBounds (std::size_t number_of_bounds) |
| double | GetLowerBound (std::size_t index) const noexcept |
| bool | SetLowerBound (std::size_t index, double lower_bound) |
| double | GetUpperBound (std::size_t index) const noexcept |
| bool | SetUpperBound (std::size_t index, double upper_bound) |
Private Attributes | |
| std::vector< double > | upper_bound_ |
| std::vector< double > | lower_bound_ |
This class is designed to handle all of the bounds work for Unfit. To ensure safety, internally a pair of bounds should be created for all variables, even if there is no desire to set them to specific values. This is as easy as passing the number of variables to the constructor (if known), or later calling SetNumberOfBounds which will also create the default bounds for you. Remember that all indices start from zero in C++, so that is the location of the first bound. Note that bounds are always set (or removed) in pairs, so if there is an upper bound there will always be a lower bound.
| Unfit::Bounds::Bounds | ( | ) |
Create an empty Bounds object where no bounds are set.
| Unfit::Bounds::Bounds | ( | std::size_t | number_of_bounds | ) |
Create a Bounds object and sets number_of_bounds variables to have a lower bound at equal to the maximum negative float and an upper bound equal to the maximum positive float (stored as doubles). The reason for this is that on some platforms using the minimum and maximum doubles has caused issues.
| number_of_bounds | The number of variables in the problem |
| void Unfit::Bounds::ClampWithinBounds | ( | std::vector< double > & | point | ) |
Checks if the coordinates of the point provided to the method are within bounds of the domain. The check is INCLUSIVE. This means that if the value of a variable is on the domain boundary it is considered to be within the domain. If any of the variables are outside the bounds it will change that coordinate such that it lies on the bound.
| point | the coordinates of the point to check |
| void Unfit::Bounds::GetBounds | ( | std::vector< double > & | lower_bound, |
| std::vector< double > & | upper_bound | ||
| ) | const |
Here, the current values for all of the upper and lower bounds are written into the upper_bound and lower_bound arguments, respectively.
| lower_bound | (input) vector containing the lower bounds; |
| upper_bound | (input) vector containing the upper bounds; |
|
noexcept |
Returns the lower bound value of given index. The index should be the smaller than the size of the lower bound vector. If not, method assumes that there is no contraints and returns the largest negative double precision number.
| index | The position of the variable on which the bound will be set |
|
noexcept |
Returns the number of variables that are currently bounded. This should be the same as the number of variables in the problem. If not, use SetNumberOfBounds to fix this.
|
noexcept |
Returns the upper bound value of given index. The index should be the smaller than the size of the upper bound vector. If not, method assumes that there is no contraints and returns the largest positive double precision number.
| index | The position of the variable on which the bound will be set |
|
noexcept |
Checks if the point provided to the method is above the lower bound on that variable. The check is INCLUSIVE. This means that if the value of a variable is on the domain boundary it is considered to be within the domain. An invalid index will return false.
| index | the location of the point to check |
| point | the value of the point to check |
|
noexcept |
Checks if the point provided to the method is below the upper bound on that variable. The check is INCLUSIVE. This means that if the value of a variable is on the domain boundary it is considered to be within the domain. An invalid index will return false.
| index | the location of the point to check |
| point | the value of the point to check |
|
noexcept |
Checks if the point provided to the method is within the bounds of the variable. The check is INCLUSIVE. This means that if the value of a variable is on the domain boundary it is considered to be within the domain. An invalid index will return false.
| index | the location of the point to check |
| point | the value of the point to check |
|
noexcept |
Checks if the coordinates of the point provided to the method are within bounds of the domain. The check is INCLUSIVE. This means that if the value of a variable is on the domain boundary it is considered to be within the domain.
| point | the coordinates of the point to check |
| void Unfit::Bounds::ResetBounds | ( | ) |
This method keeps the number of bounds unchanged, but resets them such that all of the lower bounds are the maximum negative float and all of the upper bounds are the maximum positive float (stored as doubles).
| bool Unfit::Bounds::SetBounds | ( | std::size_t | index, |
| double | lower_bound, | ||
| double | upper_bound | ||
| ) |
Sets the upper and lower bound at the position "index". If setting the bound fails, the original state of the bounds will be preserved (including remaining undefined if they have not been set previously).
| index | The position of the variable on which the bound will be set |
| lower_bound | The value of the lower bound |
| upper_bound | The value of the upper bound |
| bool Unfit::Bounds::SetBounds | ( | const std::vector< double > & | lower_bound, |
| const std::vector< double > & | upper_bound | ||
| ) |
Sets the upper and lower bounds at all positions. All existing bounds will be overwritten if this method succeeds. This includes changing the number of bounds, if necessary. The number of upper bounds must be equal to the number of lower bounds, which should be equal to the number of variables you have. If setting the bounds fails, the original state of the bounds will be preserved (including remaining undefined if they have not been set previously).
| lower_bound | A vector containing the lower bounds |
| upper_bound | A vector containing the upper bounds |
| bool Unfit::Bounds::SetLowerBound | ( | std::size_t | index, |
| double | lower_bound | ||
| ) |
Set the lower bound at the position "index". The corresponding upper bound will be set to the largest positive double precision number. If setting the bound fails, the original state of the bounds will be preserved (including remaining undefined if they have not been set previously).
| index | The position of the variable on which the bound will be set |
| lower_bound | The value of the lower bound |
| void Unfit::Bounds::SetNumberOfBounds | ( | std::size_t | number_of_bounds | ) |
Set the number of bounds in the problem. This should be the same as the number of variables. If number_of_bounds is equal to the current number of bounds no updates will occur (existing bounds will be preserved). If number_of_bounds is less that the current number of bounds, the bounds above number_of_bounds will be deleted (other bounds will be preserved). If number_of_bounds is greater than the current number of bounds, new bounds will be appended (lower = -max; upper = +max) to the existing set of bounds (if any). NOTE: An upper and a lower bound on the same variable only count as one bound.
| number_of_bounds | The number of variables in the problem |
| bool Unfit::Bounds::SetUpperBound | ( | std::size_t | index, |
| double | upper_bound | ||
| ) |
Set the upper bound at the position "index". The corresponding lower bound will be set to the largest negative double precision number. If setting the bound fails, the original state of the bounds will be preserved (including remaining undefined if they have not been set previously).
| index | The position of the variable on which the bound will be set |
| upper_bound | The value of the upper bound |
|
private |
Stores the lower bounds of the variables
|
private |
Stores the upper bounds of the variables
1.8.13