6#ifndef THEORETICA_MULTI_EXTREMA_H
7#define THEORETICA_MULTI_EXTREMA_H
9#include "../core/constants.h"
10#include "../autodiff/autodiff.h"
31 template<
unsigned int N>
40 TH_MATH_ERROR(
"multi_minimize_grad", gamma, INVALID_ARGUMENT);
46 unsigned int iter = 0;
50 grad = gradient(f, x);
77 template<
unsigned int N>
100 template<
unsigned int N>
109 unsigned int iter = 0;
151 template<
unsigned int N>
160 unsigned int iter = 0;
164 grad = -gradient(f, x);
200 template<
unsigned int N>
218 template<
unsigned int N>
Multidual number algebra for functions of the form .
Definition multidual.h:26
A statically allocated N-dimensional vector with elements of the given type.
Definition vec.h:92
#define TH_MATH_ERROR(F_NAME, VALUE, EXCEPTION)
TH_MATH_ERROR is a macro which throws exceptions or modifies errno (depending on which compiling opti...
Definition error.h:219
Extrema approximation of real functions.
auto gradient(Function f, const Vector &x)
Compute the gradient for a given of a scalar field of the form using automatic differentiation.
Definition autodiff.h:148
Main namespace of the library which contains all functions and objects.
Definition algebra.h:27
vec< real, N > multi_minimize_lingrad(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE, unsigned int max_iter=OPTIMIZATION_MINGRAD_ITER)
Find a local minimum of the given multivariate function using gradient descent with linear search.
Definition multi_extrema.h:101
double real
A real number, defined as a floating point type.
Definition constants.h:198
vec< real, N > multi_minimize(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE)
Use the best available algorithm to find a local minimum of the given multivariate function.
Definition multi_extrema.h:201
std::remove_reference_t< decltype(std::declval< Structure >()[0])> vector_element_t
Extract the type of a vector (or any indexable container) from its operator[].
Definition core_traits.h:134
vec< real, N > multi_maximize(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE)
Use the best available algorithm to find a local maximum of the given multivariate function.
Definition multi_extrema.h:219
constexpr real OPTIMIZATION_MINGRAD_TOLERANCE
Default tolerance for gradient descent minimization.
Definition constants.h:324
vec< real, N > multi_maximize_lingrad(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE, unsigned int max_iter=OPTIMIZATION_MINGRAD_ITER)
Find a local maximum of the given multivariate function using gradient descent with linear search.
Definition multi_extrema.h:152
constexpr unsigned int OPTIMIZATION_MINGRAD_ITER
Maximum number of iterations for gradient descent minimization.
Definition constants.h:327
vec< real, N > multi_maximize_grad(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real gamma=OPTIMIZATION_MINGRAD_GAMMA, real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE, unsigned int max_iter=OPTIMIZATION_MINGRAD_ITER)
Find a local maximum of the given multivariate function using fixed-step gradient descent.
Definition multi_extrema.h:78
constexpr real MACH_EPSILON
Machine epsilon for the real type.
Definition constants.h:207
real maximize_goldensection(RealFunction f, real a, real b)
Approximate a function maximum using the Golden Section search algorithm.
Definition extrema.h:24
vec< real, N > multi_minimize_grad(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real gamma=OPTIMIZATION_MINGRAD_GAMMA, real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE, unsigned int max_iter=OPTIMIZATION_MINGRAD_ITER)
Find a local minimum of the given multivariate function using fixed-step gradient descent.
Definition multi_extrema.h:32
real minimize_goldensection(RealFunction f, real a, real b)
Approximate a function minimum using the Golden Section search algorithm.
Definition extrema.h:69
real nan()
Return a quiet NaN number in floating point representation.
Definition error.h:54
constexpr real OPTIMIZATION_MINGRAD_GAMMA
Default step size for gradient descent minimization.
Definition constants.h:321