Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
Optimist::Optimizer::NelderMead< Real, N > Class Template Reference

Class container for the Nelder-Mead's method. More...

#include <NelderMead.hh>

Inherits Optimist::Optimizer::Optimizer< Real, N, NelderMead< Real, N > >.

Public Types

using Simplex = std::vector<Vector>
Public Types inherited from Optimist::Optimizer::Optimizer< Real, N, NelderMead< Real, N > >
using Vector
using RowVector
using Matrix
Public Types inherited from Optimist::SolverBase< Real, N, 1, NelderMead< Real, N >, false >
using InputType
using OutputType
using TraceType
using FirstDerivativeType
using SecondDerivativeType

Public Member Functions

 NelderMead ()
std::string name_impl () const
void initialize (Vector const &x_ini, Real delta)
Vector centroid () const
template<typename FunctionLambda>
void sort (FunctionLambda &&function)
Vector reflection () const
 Computes the reflection point.
Vector expansion (Vector const &x) const
 Computes the expansion point.
Vector outward_contraction (Vector const &x) const
Vector inward_contraction () const
void shrink ()
bool solve_impl (FunctionLambda &&function, Vector const &x_ini, Vector &x_sol)
Public Member Functions inherited from Optimist::Optimizer::Optimizer< Real, N, NelderMead< Real, N > >
 Optimizer ()
std::string name () const
Integer gradient_evaluations () const
Integer max_gradient_evaluations () const
Integer hessian_evaluations () const
Integer max_hessian_evaluations () const
Public Member Functions inherited from Optimist::SolverBase< Real, N, 1, NelderMead< Real, N >, false >
 SolverBase ()
InputType const & lower_bound () const
InputType const & upper_bound () const
void bounds (InputType const &t_lower_bound, InputType const &t_upper_bound)
constexpr Integer input_dimension () const
constexpr Integer output_dimension () const
Integer function_evaluations () const
void max_function_evaluations (Integer t_max_function_evaluations)
Integer iterations () const
Integer max_iterations () const
Real alpha () const
Integer relaxations () const
Integer max_relaxations () const
Real tolerance () const
void verbose_mode (bool t_verbose)
void enable_verbose_mode ()
void disable_verbose_mode ()
void damped_mode (bool t_damped)
void enable_damped_mode ()
void disable_damped_mode ()
std::string task () const
bool converged () const
const TraceTypetrace () const
std::ostream & ostream () const
bool solve (FunctionLambda &&function, InputType const &x_ini, InputType &x_sol)
bool rootfind (FunctionBase< Real, FunInDim, FunOutDim, DerivedFunction, ForceEigen &&FunOutDim==1 > const &function, InputType const &x_ini, InputType &x_sol)
bool optimize (FunctionBase< Real, FunInDim, FunOutDim, DerivedFunction, ForceEigen &&FunOutDim==1 > const &function, InputType const &x_ini, InputType &x_sol)
std::string name () const

Static Public Attributes

static constexpr bool requires_function {true}
static constexpr bool requires_first_derivative {false}
static constexpr bool requires_second_derivative {false}
Static Public Attributes inherited from Optimist::Optimizer::Optimizer< Real, N, NelderMead< Real, N > >
static constexpr bool is_rootfinder
static constexpr bool is_optimizer

Private Attributes

Simplex m_s
Vector m_c
Real m_alpha {1.0}
Real m_gamma {2.0}
Real m_rho {0.5}
Real m_sigma {0.5}

Additional Inherited Members

Protected Member Functions inherited from Optimist::Optimizer::Optimizer< Real, N, NelderMead< Real, N > >
bool evaluate_gradient (GradientLambda &&gradient, Vector const &x, Matrix &out)
bool evaluate_hessian (HessianLambda &&hessian, Vector const &x, Matrix &out)
bool solve (FunctionLambda &&function, Vector const &x_ini, Vector &x_sol)
Protected Member Functions inherited from Optimist::SolverBase< Real, N, 1, NelderMead< Real, N >, false >
Integer first_derivative_evaluations () const
Integer max_first_derivative_evaluations () const
Integer second_derivative_evaluations () const
Integer max_second_derivative_evaluations () const
void reset ()
bool evaluate_function (FunctionLambda &&function, InputType const &x, OutputType &out)
bool evaluate_first_derivative (FirstDerivativeLambda &&function, InputType const &x, FirstDerivativeType &out)
bool evaluate_second_derivative (SecondDerivativeLambda &&function, InputType const &x, SecondDerivativeType &out)
void store_trace (InputType const &x)
bool damp (FunctionLambda &&function, InputType const &x_old, InputType const &function_old, InputType const &step_old, InputType &x_new, InputType &function_new, InputType &step_new)
void header ()
void bottom ()
void info (Real residuals, std::string const &notes="-")
Protected Attributes inherited from Optimist::SolverBase< Real, N, 1, NelderMead< Real, N >, false >
InputType m_lower_bound
InputType m_upper_bound
Integer m_function_evaluations
Integer m_first_derivative_evaluations
Integer m_second_derivative_evaluations
Integer m_max_function_evaluations
Integer m_max_first_derivative_evaluations
Integer m_max_second_derivative_evaluations
Integer m_iterations
Integer m_max_iterations
Real m_alpha
Integer m_relaxations
Integer m_max_relaxations
Real m_tolerance
bool m_verbose
bool m_damped
std::ostream * m_ostream
std::string m_task
bool m_converged
TraceType m_trace

Detailed Description

template<typename Real, Integer N>
class Optimist::Optimizer::NelderMead< Real, N >
Template Parameters
RealScalar number type.
NDimension of the root-finding problem.

Member Typedef Documentation

◆ Simplex

template<typename Real, Integer N>
using Optimist::Optimizer::NelderMead< Real, N >::Simplex = std::vector<Vector>

Constructor & Destructor Documentation

◆ NelderMead()

template<typename Real, Integer N>
Optimist::Optimizer::NelderMead< Real, N >::NelderMead ( )
inline

Nelder-Mead shrink coefficient. Class constructor for the NelderMead solver.

Member Function Documentation

◆ centroid()

template<typename Real, Integer N>
Vector Optimist::Optimizer::NelderMead< Real, N >::centroid ( ) const
inline

Compute the centroid of the simplex.

Returns
The centroid of the simplex.

◆ expansion()

template<typename Real, Integer N>
Vector Optimist::Optimizer::NelderMead< Real, N >::expansion ( Vector const & x) const
inline
Parameters
[in]xThe reflection point.
Returns
The expansion point.

◆ initialize()

template<typename Real, Integer N>
void Optimist::Optimizer::NelderMead< Real, N >::initialize ( Vector const & x_ini,
Real delta )
inline

Initialize the simplex around a given centroid.

Parameters
[in]x_iniThe initial point.
[in]deltaThe initial step size.

◆ inward_contraction()

template<typename Real, Integer N>
Vector Optimist::Optimizer::NelderMead< Real, N >::inward_contraction ( ) const
inline

Computes the inward contraction point.

Returns
The contraction point.

◆ name_impl()

template<typename Real, Integer N>
std::string Optimist::Optimizer::NelderMead< Real, N >::name_impl ( ) const
inline

Get the Nelder-Mead's solver name.

Returns
The Nelder-Mead's solver name.

◆ outward_contraction()

template<typename Real, Integer N>
Vector Optimist::Optimizer::NelderMead< Real, N >::outward_contraction ( Vector const & x) const
inline

Computes the outward contraction point.

Parameters
[in]xThe reflection point.
Returns
The contraction point.

◆ reflection()

template<typename Real, Integer N>
Vector Optimist::Optimizer::NelderMead< Real, N >::reflection ( ) const
inline
Returns
The reflection point.

◆ shrink()

template<typename Real, Integer N>
void Optimist::Optimizer::NelderMead< Real, N >::shrink ( )
inline

Shrinks the simplex towards the best point.

◆ solve_impl()

template<typename Real, Integer N>
bool Optimist::Optimizer::NelderMead< Real, N >::solve_impl ( FunctionLambda && function,
Vector const & x_ini,
Vector & x_sol )
inline

Solve the nonlinear system of equations \( \mathbf{f}(\mathbf{x}) = 0 \), with \(\mathbf{f}: \mathbb{R}^n \rightarrow \mathbb{R}^n \).

Template Parameters
FunctionLambdaFunction lambda type.
Parameters
[in]functionFunction lambda.
[in]x_iniInitialization point.
[out]x_solSolution point.
Returns
The convergence boolean flag.

◆ sort()

template<typename Real, Integer N>
template<typename FunctionLambda>
void Optimist::Optimizer::NelderMead< Real, N >::sort ( FunctionLambda && function)
inline

Sort the points of the simplex based on the function values and updates the centroid.

Template Parameters
FunctionLambdaFunction lambda type.
Parameters
[in]functionFunction lambda.

Member Data Documentation

◆ m_alpha

template<typename Real, Integer N>
Real Optimist::Optimizer::NelderMead< Real, N >::m_alpha {1.0}
private

◆ m_c

template<typename Real, Integer N>
Vector Optimist::Optimizer::NelderMead< Real, N >::m_c
private

The centroid of the simplex (ex_cluding the worst point).

◆ m_gamma

template<typename Real, Integer N>
Real Optimist::Optimizer::NelderMead< Real, N >::m_gamma {2.0}
private

Nelder-Mead reflection coefficient.

◆ m_rho

template<typename Real, Integer N>
Real Optimist::Optimizer::NelderMead< Real, N >::m_rho {0.5}
private

Nelder-Mead expansion coefficient.

◆ m_s

template<typename Real, Integer N>
Simplex Optimist::Optimizer::NelderMead< Real, N >::m_s
private

Simplex representing the vertices of the simplex.

◆ m_sigma

template<typename Real, Integer N>
Real Optimist::Optimizer::NelderMead< Real, N >::m_sigma {0.5}
private

Nelder-Mead contraction coefficient.

◆ requires_first_derivative

template<typename Real, Integer N>
bool Optimist::Optimizer::NelderMead< Real, N >::requires_first_derivative {false}
staticconstexpr

◆ requires_function

template<typename Real, Integer N>
bool Optimist::Optimizer::NelderMead< Real, N >::requires_function {true}
staticconstexpr

◆ requires_second_derivative

template<typename Real, Integer N>
bool Optimist::Optimizer::NelderMead< Real, N >::requires_second_derivative {false}
staticconstexpr

The documentation for this class was generated from the following file: