Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
Optimist::TestSet::Ackley< Vector, N > Class Template Reference

Ackley's function. More...

#include <Ackley.hh>

Inherits Optimist::TestSet::DenseCostFunction< Vector, N, Ackley< Vector, N > >.

Public Types

using Base = DenseCostFunction<Vector, N, Ackley<Vector, N>>
using Dense
using DenseMatrix
using Scalar
Public Types inherited from Optimist::TestSet::DenseCostFunction< Vector, N, Ackley< Vector, N > >
using VectorTrait
using Scalar
using Dense
using DenseMatrix
Public Types inherited from Optimist::FunctionBase< Input, Output, DerivedFunction >
using InputTrait = TypeTrait<Input>
using OutputTrait = TypeTrait<Output>
using Scalar = typename InputTrait::Scalar
using FirstDerivative
using SecondDerivative

Public Member Functions

 Ackley ()
constexpr std::string name_impl () const
Scalar value (const Dense &x) const
void gradient (const Dense &x, Dense &g) const
void hessian (const Dense &x, DenseMatrix &H) const
Public Member Functions inherited from Optimist::TestSet::DenseCostFunction< Vector, N, Ackley< Vector, N > >
bool evaluate_impl (const Vector &x, Scalar &out) const
bool first_derivative_impl (const Vector &x, FirstDerivative &out) const
bool second_derivative_impl (const Vector &x, SecondDerivative &out) const
Public Member Functions inherited from Optimist::Function< Input, Output, DerivedFunction >
 Function ()
constexpr std::string name () const
bool evaluate (const Input &x, Output &out) const
bool jacobian (const Input &x, FirstDerivative &out) const
bool hessian (const Input &x, SecondDerivative &out) const
Public Member Functions inherited from Optimist::FunctionBase< Input, Output, DerivedFunction >
 FunctionBase ()
constexpr std::string name () const
bool evaluate (const Input &x, Output &out) const
bool first_derivative (const Input &x, FirstDerivative &out) const
bool second_derivative (const Input &x, SecondDerivative &out) const
constexpr Integer input_dimension () const
constexpr Integer output_dimension () const
const std::vector< Input > & solutions () const
const std::vector< Input > & guesses () const
const Input & solution (const Integer i) const
const Input & guess (const Integer i) const
bool is_solution (const Input &x, const Scalar tol=FunctionBase::SQRT_EPSILON) const

Static Public Member Functions

static constexpr Scalar domain ()
Static Public Member Functions inherited from Optimist::TestSet::DenseCostFunction< Vector, N, Ackley< Vector, N > >
static constexpr Integer dimension ()

Static Private Member Functions

template<typename T>
static Eigen::Matrix< T, Eigen::Dynamic, 1 > gradient_t (const Eigen::Matrix< T, Eigen::Dynamic, 1 > &x)

Additional Inherited Members

Protected Member Functions inherited from Optimist::TestSet::DenseCostFunction< Vector, N, Ackley< Vector, N > >
void add_solution (const Dense &x)
void add_guess (const Dense &x)
Static Protected Member Functions inherited from Optimist::TestSet::DenseCostFunction< Vector, N, Ackley< Vector, N > >
static Dense make (std::initializer_list< Scalar > values)
Protected Attributes inherited from Optimist::FunctionBase< Input, Output, DerivedFunction >
std::vector< Input > m_solutions
std::vector< Input > m_guesses

Detailed Description

template<typename Vector, Integer N>
class Optimist::TestSet::Ackley< Vector, N >

\[ f(\mathbf{x}) = -20\exp\left(-0.2\sqrt{\frac{1}{N}\sum x_i^2}\right) - \exp\left(\frac{1}{N}\sum\cos(2\pi x_i)\right) + 20 + e \text{,} \]

a nearly flat outer region riddled with local minima around a deep funnel with global minimum \( f(\mathbf{0}) = 0 \). The usual search domain is \( [-5, 5]^N \). It is meant for global optimizers. The Hessian is obtained by forward-mode automatic differentiation of the gradient (Eigen's AutoDiffScalar). The function is not differentiable at the origin, where the gradient is set to zero.

Template Parameters
VectorEigen vector type.
NProblem dimension.

Member Typedef Documentation

◆ Base

template<typename Vector, Integer N>
using Optimist::TestSet::Ackley< Vector, N >::Base = DenseCostFunction<Vector, N, Ackley<Vector, N>>

◆ Dense

template<typename Vector, Integer N>
using Optimist::TestSet::DenseCostFunction< Vector, N, Ackley< Vector, N > >::Dense

◆ DenseMatrix

template<typename Vector, Integer N>
using Optimist::TestSet::DenseCostFunction< Vector, N, Ackley< Vector, N > >::DenseMatrix

◆ Scalar

template<typename Vector, Integer N>
using Optimist::TestSet::DenseCostFunction< Vector, N, Ackley< Vector, N > >::Scalar

Constructor & Destructor Documentation

◆ Ackley()

template<typename Vector, Integer N>
Optimist::TestSet::Ackley< Vector, N >::Ackley ( )
inline

Class constructor for Ackley's function.

Member Function Documentation

◆ domain()

template<typename Vector, Integer N>
constexpr Scalar Optimist::TestSet::Ackley< Vector, N >::domain ( )
inlinestaticconstexpr

Usual half-width of the search domain.

◆ gradient()

template<typename Vector, Integer N>
void Optimist::TestSet::Ackley< Vector, N >::gradient ( const Dense & x,
Dense & g ) const
inline

◆ gradient_t()

template<typename Vector, Integer N>
template<typename T>
Eigen::Matrix< T, Eigen::Dynamic, 1 > Optimist::TestSet::Ackley< Vector, N >::gradient_t ( const Eigen::Matrix< T, Eigen::Dynamic, 1 > & x)
inlinestaticprivate

Gradient written for a generic scalar type, so that it can be differentiated automatically.

◆ hessian()

template<typename Vector, Integer N>
void Optimist::TestSet::Ackley< Vector, N >::hessian ( const Dense & x,
DenseMatrix & H ) const
inline

◆ name_impl()

template<typename Vector, Integer N>
std::string Optimist::TestSet::Ackley< Vector, N >::name_impl ( ) const
inlineconstexpr

◆ value()

template<typename Vector, Integer N>
Scalar Optimist::TestSet::Ackley< Vector, N >::value ( const Dense & x) const
inline

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