openGPMP
Open Source Mathematics Package
|
A class containing various utility functions and optimization methods. More...
#include <function.hpp>
Public Member Functions | |
std::vector< double > | generate_random_point (const std::vector< double > &lower_bounds, const std::vector< double > &upper_bounds) const |
Generates a random point within specified bounds. More... | |
std::vector< double > | generate_fibonacci_sequence (size_t length) const |
Generates a Fibonacci sequence up to a specified length. More... | |
std::vector< double > | vector_addition (const std::vector< double > &a, const std::vector< double > &b) const |
Performs vector addition. More... | |
std::vector< double > | vector_subtraction (const std::vector< double > &a, const std::vector< double > &b) const |
Performs vector subtraction. More... | |
std::vector< double > | vector_scalar_multiply (double scalar, const std::vector< double > &vec) const |
Performs vector scalar multiplication. More... | |
double | calculate_midpoint (double a, double b, double fraction) const |
Calculates the midpoint between two values. More... | |
double | golden_section_search (const std::function< double(double)> &func, double a, double b, double tol) |
Finds the minimum of a univariate function using Golden-section search. More... | |
double | linear_interpolation (double x, double x0, double x1, double y0, double y1) |
Interpolates a univariate function using linear interpolation. More... | |
double | cubic_interpolation (double x, double x0, double x1, double y0, double y1, double y0_prime, double y1_prime) |
Interpolates a univariate function using cubic interpolation. More... | |
std::vector< double > | golden_section_search_multivariate (const std::function< double(const std::vector< double > &)> &func, const std::vector< double > &lower_bounds, const std::vector< double > &upper_bounds, double tol) |
Finds the minimum of a multivariate function using Golden-section search. More... | |
double | random_search (const std::function< double(const std::vector< double > &)> &func, const std::vector< double > &lower_bounds, const std::vector< double > &upper_bounds, size_t max_iterations) |
Performs random search for function optimization. More... | |
std::vector< double > | fit_linear (const std::vector< double > &x, const std::vector< double > &y) |
Fits a linear function to given data points. More... | |
double | fibonacci_search (const std::function< double(const std::vector< double > &)> &func, const std::vector< double > &lower_bounds, const std::vector< double > &upper_bounds, size_t max_iterations) |
Performs Fibonacci search for function optimization. More... | |
double | ternary_search (const std::function< double(const std::vector< double > &)> &func, const std::vector< double > &lower_bounds, const std::vector< double > &upper_bounds, size_t max_iterations) const |
Performs ternary search for function optimization. More... | |
std::vector< double > | bisection_method (const std::function< double(const std::vector< double > &)> &func, double lower_bound, double upper_bound, size_t max_iterations) |
Performs the bisection method for function optimization. More... | |
std::vector< double > | newton_method (const std::function< double(const std::vector< double > &)> &func, const std::function< double(const std::vector< double > &)> &derivative, double initial_guess, size_t max_iterations) |
Performs Newton's method for function optimization. More... | |
std::vector< double > | regula_falsi (const std::function< double(const std::vector< double > &)> &func, double lower_bound, double upper_bound, size_t max_iterations) |
Performs Regula Falsi (False Position) method for function optimization. More... | |
std::vector< double > | cubic_fit (const std::vector< double > &x, const std::vector< double > &y) |
Fits a cubic function to given data points. More... | |
std::vector< double > | nelder_mead (const std::function< double(const std::vector< double > &)> &func, std::vector< double > initial_point, double tolerance, size_t max_iterations) |
Finds the minimum of a multivariate function using the Nelder–Mead method. More... | |
std::vector< double > | calculate_centroid (const std::vector< std::vector< double >> &simplex, size_t exclude_index) |
Calculates the centroid of a simplex excluding a specific point. More... | |
std::vector< double > | reflect (const std::vector< double > &point, const std::vector< double > ¢roid, double reflection_coefficient) |
Reflects a point with respect to a centroid. More... | |
double | calculate_range (const std::vector< double > &values) |
Calculates the range of values. More... | |
bool | is_valid_interval (double a, double b) |
Checks if a given interval is valid (lower bound < upper bound) More... | |
Private Member Functions | |
double | golden_section_search_minimize (const std::function< double(double)> &func, double a, double b, double tol, double x1, double x2) |
Finds the minimum of a univariate function using Golden-section search (Internal helper function) More... | |
std::vector< double > | golden_section_search_minimize_multivariate (const std::function< double(const std::vector< double > &)> &func, const std::vector< double > &lower_bounds, const std::vector< double > &upper_bounds, double tol, const std::vector< double > &x1, const std::vector< double > &x2) |
Finds the minimum of a multivariate function using Golden-section search (Internal helper function) More... | |
A class containing various utility functions and optimization methods.
Definition at line 49 of file function.hpp.
std::vector< double > gpmp::optim::Func::bisection_method | ( | const std::function< double(const std::vector< double > &)> & | func, |
double | lower_bound, | ||
double | upper_bound, | ||
size_t | max_iterations | ||
) |
Performs the bisection method for function optimization.
func | The univariate function to optimize |
lower_bound | The lower bound of the search interval |
upper_bound | The upper bound of the search interval |
max_iterations | The maximum number of iterations |
Definition at line 362 of file function.cpp.
std::vector< double > gpmp::optim::Func::calculate_centroid | ( | const std::vector< std::vector< double >> & | simplex, |
size_t | exclude_index | ||
) |
Calculates the centroid of a simplex excluding a specific point.
simplex | The simplex |
exclude_index | The index of the point to exclude |
Definition at line 606 of file function.cpp.
double gpmp::optim::Func::calculate_midpoint | ( | double | a, |
double | b, | ||
double | fraction | ||
) | const |
Calculates the midpoint between two values.
a | The first value |
b | The second value |
fraction | The fraction determining the midpoint |
Definition at line 116 of file function.cpp.
double gpmp::optim::Func::calculate_range | ( | const std::vector< double > & | values | ) |
Calculates the range of values.
values | The vector of values |
Definition at line 642 of file function.cpp.
std::vector< double > gpmp::optim::Func::cubic_fit | ( | const std::vector< double > & | x, |
const std::vector< double > & | y | ||
) |
Fits a cubic function to given data points.
x | The x-coordinates of data points |
y | The corresponding y-coordinates of data points |
Definition at line 449 of file function.cpp.
double gpmp::optim::Func::cubic_interpolation | ( | double | x, |
double | x0, | ||
double | x1, | ||
double | y0, | ||
double | y1, | ||
double | y0_prime, | ||
double | y1_prime | ||
) |
Interpolates a univariate function using cubic interpolation.
x | The point at which to interpolate |
x0 | The left point of the interval |
x1 | The right point of the interval |
y0 | The function value at x0 |
y1 | The function value at x1 |
y0_prime | The derivative value at x0 |
y1_prime | The derivative value at x1 |
Definition at line 147 of file function.cpp.
double gpmp::optim::Func::fibonacci_search | ( | const std::function< double(const std::vector< double > &)> & | func, |
const std::vector< double > & | lower_bounds, | ||
const std::vector< double > & | upper_bounds, | ||
size_t | max_iterations | ||
) |
Performs Fibonacci search for function optimization.
func | The multivariate function to optimize |
lower_bounds | The lower bounds of the search interval |
upper_bounds | The upper bounds of the search interval |
max_iterations | The maximum number of iterations |
Definition at line 289 of file function.cpp.
std::vector< double > gpmp::optim::Func::fit_linear | ( | const std::vector< double > & | x, |
const std::vector< double > & | y | ||
) |
Fits a linear function to given data points.
x | The x-coordinates of data points |
y | The corresponding y-coordinates of data points |
Definition at line 264 of file function.cpp.
std::vector< double > gpmp::optim::Func::generate_fibonacci_sequence | ( | size_t | length | ) | const |
Generates a Fibonacci sequence up to a specified length.
length | The length of the Fibonacci sequence |
Definition at line 57 of file function.cpp.
std::vector< double > gpmp::optim::Func::generate_random_point | ( | const std::vector< double > & | lower_bounds, |
const std::vector< double > & | upper_bounds | ||
) | const |
Generates a random point within specified bounds.
lower_bounds | The lower bounds for each dimension |
upper_bounds | The upper bounds for each dimension |
Definition at line 37 of file function.cpp.
double gpmp::optim::Func::golden_section_search | ( | const std::function< double(double)> & | func, |
double | a, | ||
double | b, | ||
double | tol | ||
) |
Finds the minimum of a univariate function using Golden-section search.
func | The univariate function to minimize |
a | The lower bound of the search interval |
b | The upper bound of the search interval |
tol | The tolerance for stopping criterion |
Definition at line 122 of file function.cpp.
|
private |
Finds the minimum of a univariate function using Golden-section search (Internal helper function)
func | The univariate function to minimize |
a | The lower bound of the search interval |
b | The upper bound of the search interval |
tol | The tolerance for stopping criterion |
x1 | Internal helper parameter |
x2 | Internal helper parameter |
Definition at line 167 of file function.cpp.
|
private |
Finds the minimum of a multivariate function using Golden-section search (Internal helper function)
func | The multivariate function to minimize |
lower_bounds | The lower bounds of the search interval |
upper_bounds | The upper bounds of the search interval |
tol | The tolerance for stopping criterion |
x1 | Internal helper parameter |
x2 | Internal helper parameter |
Definition at line 650 of file function.cpp.
std::vector< double > gpmp::optim::Func::golden_section_search_multivariate | ( | const std::function< double(const std::vector< double > &)> & | func, |
const std::vector< double > & | lower_bounds, | ||
const std::vector< double > & | upper_bounds, | ||
double | tol | ||
) |
Finds the minimum of a multivariate function using Golden-section search.
func | The multivariate function to minimize |
lower_bounds | The lower bounds of the search interval |
upper_bounds | The upper bounds of the search interval |
tol | The tolerance for stopping criterion |
Definition at line 200 of file function.cpp.
bool gpmp::optim::Func::is_valid_interval | ( | double | a, |
double | b | ||
) |
Checks if a given interval is valid (lower bound < upper bound)
a | The lower bound of the interval |
b | The upper bound of the interval |
Definition at line 690 of file function.cpp.
double gpmp::optim::Func::linear_interpolation | ( | double | x, |
double | x0, | ||
double | x1, | ||
double | y0, | ||
double | y1 | ||
) |
Interpolates a univariate function using linear interpolation.
x | The point at which to interpolate |
x0 | The left point of the interval |
x1 | The right point of the interval |
y0 | The function value at x0 |
y1 | The function value at x1 |
Definition at line 139 of file function.cpp.
std::vector< double > gpmp::optim::Func::nelder_mead | ( | const std::function< double(const std::vector< double > &)> & | func, |
std::vector< double > | initial_point, | ||
double | tolerance, | ||
size_t | max_iterations | ||
) |
Finds the minimum of a multivariate function using the Nelder–Mead method.
func | The multivariate function to minimize |
initial_point | The initial guess for the minimum |
tolerance | The tolerance for stopping criterion |
max_iterations | The maximum number of iterations |
Definition at line 519 of file function.cpp.
std::vector< double > gpmp::optim::Func::newton_method | ( | const std::function< double(const std::vector< double > &)> & | func, |
const std::function< double(const std::vector< double > &)> & | derivative, | ||
double | initial_guess, | ||
size_t | max_iterations | ||
) |
Performs Newton's method for function optimization.
func | The univariate function to optimize |
derivative | The derivative of the function |
initial_guess | The initial guess for the minimum |
max_iterations | The maximum number of iterations |
Definition at line 393 of file function.cpp.
double gpmp::optim::Func::random_search | ( | const std::function< double(const std::vector< double > &)> & | func, |
const std::vector< double > & | lower_bounds, | ||
const std::vector< double > & | upper_bounds, | ||
size_t | max_iterations | ||
) |
Performs random search for function optimization.
func | The multivariate function to optimize |
lower_bounds | The lower bounds of the search interval |
upper_bounds | The upper bounds of the search interval |
max_iterations | The maximum number of iterations |
Definition at line 233 of file function.cpp.
std::vector< double > gpmp::optim::Func::reflect | ( | const std::vector< double > & | point, |
const std::vector< double > & | centroid, | ||
double | reflection_coefficient | ||
) |
Reflects a point with respect to a centroid.
point | The point to reflect |
centroid | The centroid |
reflection_coefficient | The reflection coefficient |
Definition at line 628 of file function.cpp.
std::vector< double > gpmp::optim::Func::regula_falsi | ( | const std::function< double(const std::vector< double > &)> & | func, |
double | lower_bound, | ||
double | upper_bound, | ||
size_t | max_iterations | ||
) |
Performs Regula Falsi (False Position) method for function optimization.
func | The univariate function to optimize |
lower_bound | The lower bound of the search interval |
upper_bound | The upper bound of the search interval |
max_iterations | The maximum number of iterations |
Definition at line 414 of file function.cpp.
double gpmp::optim::Func::ternary_search | ( | const std::function< double(const std::vector< double > &)> & | func, |
const std::vector< double > & | lower_bounds, | ||
const std::vector< double > & | upper_bounds, | ||
size_t | max_iterations | ||
) | const |
Performs ternary search for function optimization.
func | The multivariate function to optimize |
lower_bounds | The lower bounds of the search interval |
upper_bounds | The upper bounds of the search interval |
max_iterations | The maximum number of iterations |
Definition at line 331 of file function.cpp.
std::vector< double > gpmp::optim::Func::vector_addition | ( | const std::vector< double > & | a, |
const std::vector< double > & | b | ||
) | const |
Performs vector addition.
a | The first vector |
b | The second vector |
Definition at line 74 of file function.cpp.
std::vector< double > gpmp::optim::Func::vector_scalar_multiply | ( | double | scalar, |
const std::vector< double > & | vec | ||
) | const |
Performs vector scalar multiplication.
scalar | The scalar value |
vec | The vector |
Definition at line 105 of file function.cpp.
std::vector< double > gpmp::optim::Func::vector_subtraction | ( | const std::vector< double > & | a, |
const std::vector< double > & | b | ||
) | const |
Performs vector subtraction.
a | The first vector |
b | The second vector |
Definition at line 90 of file function.cpp.