|
LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
|
Nelder-Meade Simplex Optimizer (based loosely on the NRC (1996) implementation) More...
#include <Simplex.hpp>
Public Member Functions | |
| Simplex (const int n) | |
| void | dim (const int n) |
| Set the number of dimensions. | |
| void | seedLengths (const std::vector< T > &seeds) |
| Initial guess. | |
| void | tolerance (const double d) |
| Convergence criterion. | |
| void | maximumIterations (const int n) |
| Limit on the number of function evaluations to perform. | |
| int | maximumIterations () const |
| int | numberOfIterations () const |
| Return the number of iterations that it actually went through. | |
| std::vector< T > | finalParameters (void) const |
| Retrieve the final (best fit) parameters. | |
| T | finalValue (void) const |
| Final (best) value. | |
| template<class C > | |
| std::vector< T > | optimize (std::vector< T > &f, C &ftor) |
| Optimize via a functor. | |
Nelder-Meade Simplex Optimizer (based loosely on the NRC (1996) implementation)
The Simplex class is templated so it can work with doubles, floats, etc. What is actually optimized is a functor that takes a vector containing the parameters.
For example, suppose you're trying to optimize the 2D Rosenbrock function, you could define a functor like,
Now to optimize this, create a Simplex instance with the same type, and appropriate number of dimensions,
This create a new 2-D Simplex optimizer. The optimizer needs to have a starting guess (seed) as well as an initial step size (length). For the Rosenbrock, let's make the initial guess (0,0) and length of 2 in both dimensions,
Now final is a vector containing the best fit parameters and final_value is the value of the Rosenbrock function at that location.