Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
DownhillSimplexMinimization.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include <optional>
#include "Stroika/Foundation/Characters/String.h"
#include "Stroika/Foundation/Containers/Sequence.h"
#include "Stroika/Foundation/Traversal/Iterable.h"
#include "DownhillSimplexMinimization.inl"

Go to the source code of this file.

Classes

struct  Stroika::Foundation::Math::Optimization::DownhillSimplexMinimization::Options< FLOAT_TYPE >
 
struct  Stroika::Foundation::Math::Optimization::DownhillSimplexMinimization::Results< FLOAT_TYPE >
 

Namespaces

namespace  Stroika::Foundation
 

Functions

template<typename FLOAT_TYPE >
Results< FLOAT_TYPE > Stroika::Foundation::Math::Optimization::DownhillSimplexMinimization::Run (const TargetFunction< FLOAT_TYPE > &function2Minimize, const Sequence< FLOAT_TYPE > &initialValues, const Options< FLOAT_TYPE > &options=Options< FLOAT_TYPE >{})
 Downhill Simplex Minimization, AKA Nelder-Mead algorithm, to compute minimization.
 

Detailed Description

Note
Code-Status: Beta

Definition in file DownhillSimplexMinimization.h.

Function Documentation

◆ Run()

template<typename FLOAT_TYPE >
Results< FLOAT_TYPE > Stroika::Foundation::Math::Optimization::DownhillSimplexMinimization::Run ( const TargetFunction< FLOAT_TYPE > &  function2Minimize,
const Sequence< FLOAT_TYPE > &  initialValues,
const Options< FLOAT_TYPE > &  options = Options<FLOAT_TYPE>{} 
)

Downhill Simplex Minimization, AKA Nelder-Mead algorithm, to compute minimization.

Take an argument function with argument 'initialValues' and try many values to find where the targetFunction is least (ie minimize it).

If the function is naturally periodic - you can add checks in the minimization function for the desired target range and produce LARGE answers there so they wont appear as minima of the 'targetFunction'.

Reference: https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method
Reference: https://github.com/fchollet/nelder-mead/blob/master/nelder_mead.py
Reference: http://www.aip.de/groups/soe/local/numres/bookcpdf/c10-4.pdf
Reference: https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/20398/versions/1/previews/fminsearch2.m/index.html
Note
The size of the Sequence<> in initialValues will be the same as the size of the Sequence passed to 'function2Minimize', which in turn will the the size of the Sequence<> in the Results.
Example Usage
TargetFunction<double> f = [](const Sequence<double>& x) {
double d = x[0];
if (d < 0 or d >= numbers::pi) { // avoid falling off ends of ranges - periodic function
return 100.0;
}
return -std::cos (d);
};
Results<double> result = Run (f, {.1});
EXPECT_TRUE (Math::NearlyEquals (result.fOptimizedParameters[0], 0.0, 1e-10));
Results< FLOAT_TYPE > Run(const TargetFunction< FLOAT_TYPE > &function2Minimize, const Sequence< FLOAT_TYPE > &initialValues, const Options< FLOAT_TYPE > &options=Options< FLOAT_TYPE >{})
Downhill Simplex Minimization, AKA Nelder-Mead algorithm, to compute minimization.

Definition at line 183 of file DownhillSimplexMinimization.inl.