Gromacs  2021.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::NelderMeadSimplex Class Reference

#include <gromacs/math/neldermead.h>

Description

The simplex for the Nelder-Mead algorithm.

Contains the N+1 simplex N-dimensional coordinates and its function values. Allows for simplex manipulations as needed for the Nelder-Mead algorithm.

Note
Keeps the simplex sorted according to function values with the simplex at the lowest function value first.

Public Member Functions

 NelderMeadSimplex (const std::function< real(ArrayRef< const real >)> &f, ArrayRef< const real > initalGuess)
 Set up Nelder-Mead simplex from an initial guess. More...
 
const
RealFunctionvalueAtCoordinate
bestVertex () const
 Return the vertex with the lowest function value at any of the simplex vertices.
 
const
RealFunctionvalueAtCoordinate
worstVertex () const
 Return the vertex of the simplex with the highest (worst) function value.
 
real secondWorstValue () const
 Return the second largest function value at any of the simplex vertices.
 
RealFunctionvalueAtCoordinate evaluateReflectionPoint (const std::function< real(ArrayRef< const real >)> &f) const
 Return the reflection point and the evaluated function value at this point.
 
RealFunctionvalueAtCoordinate evaluateExpansionPoint (const std::function< real(ArrayRef< const real >)> &f) const
 Evaluate and return the expansion point and function value.
 
RealFunctionvalueAtCoordinate evaluateContractionPoint (const std::function< real(ArrayRef< const real >)> &f) const
 Evaluate and return the contraction point and function value.
 
void swapOutWorst (const RealFunctionvalueAtCoordinate &newVertex)
 Replace the simplex vertex with the largest function value. More...
 
void shrinkSimplexPointsExceptBest (const std::function< real(ArrayRef< const real >)> &f)
 Shrink the simplex. More...
 
real orientedLength () const
 The oriented length of the vertex. More...
 

Constructor & Destructor Documentation

gmx::NelderMeadSimplex::NelderMeadSimplex ( const std::function< real(ArrayRef< const real >)> &  f,
ArrayRef< const real initalGuess 
)

Set up Nelder-Mead simplex from an initial guess.

Note
Triggers N+1 function evaluations at all simplex points.
Parameters
[in]fthe function to be evaluated
[in]initalGuessinitial guess of the coordinates.

Member Function Documentation

real gmx::NelderMeadSimplex::orientedLength ( ) const

The oriented length of the vertex.

The oriented length of the simplex is defined as the largest distance between the first simplex vertex coordinate (with the lowest, best function value) and any other simplex coordinate.

The oriented length is used as a computationally fast and simple convergence criterion because it is proven that orientedLegnth < simplex_diameter < 2 * orientedLength

void gmx::NelderMeadSimplex::shrinkSimplexPointsExceptBest ( const std::function< real(ArrayRef< const real >)> &  f)

Shrink the simplex.

All points move closer to the best point by a factor $\sigma$.

Replace all point coordinates, except the best, with $x_i = x_{\mathrm{best}} + \sigma (x_i - x_{\mathrm{best}})$

void gmx::NelderMeadSimplex::swapOutWorst ( const RealFunctionvalueAtCoordinate newVertex)

Replace the simplex vertex with the largest function value.

Parameters
[in]newVertexto replace the worst vertex with
Note
keeps the simplex list sorted and reevaluates the reflection point

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