#include <optimizerNelderMead.h>
Inheritance diagram for dlr::optimization::OptimizerNelderMead< Functor >:


Public Types | |
| typedef Functor::argument_type | argument_type |
| This is the Type of the objective function argument. | |
| typedef Functor::result_type | result_type |
| This is the Type of the objective function return value. | |
Public Member Functions | |
| OptimizerNelderMead () | |
| Default constructor sets parameters to reasonable values for functions which take values and arguments in the "normal" range of 0 to 100 or so. | |
| OptimizerNelderMead (const Functor &functor) | |
| Constructor which specifies the specific Functor instance to use. | |
| OptimizerNelderMead (const OptimizerNelderMead &source) | |
| Copy constructor. | |
| ~OptimizerNelderMead () | |
| Destructor. | |
| virtual std::vector< size_t > | getNumberOfFunctionCalls () |
| Queries the number of iterations required to complete the previous minimization. | |
| void | setDelta (const argument_type &delta) |
| This method sets the spacing of the initial points used in the nonlinear optimization, without affecting any other optimization parameters. | |
| void | setNumberOfRestarts (size_t numberOfRestarts) |
| Sets how many times the optimization will be restarted. | |
| void | setParameters (argument_type delta, size_t functionCallLimit=5000, size_t numberOfRestarts=1, double alpha=1.0, double beta=0.5, double gamma=2.0, double minimumSimplexValueSpan=0.0001, size_t verbosity=0) |
| Sets minimization parameters. | |
| virtual void | setStartPoint (argument_type startPoint) |
| Sets the initial conditions for the minimization. | |
| virtual void | setVerbosity (int verbosity) |
| This function sets the level of text sent to standard output by the class. | |
| OptimizerNelderMead & | operator= (const OptimizerNelderMead &source) |
| Assignment operator. | |
| Functor | objectiveFunction () |
| This method returns a copy of the Functor instance used for optimization. | |
| result_type | optimalValue () |
| This method finds the optimum of the current Functor, if necessary, and returns the Functor value at that point. | |
| argument_type | optimum () |
| This method finds the optimum of the current Functor, if necessary, and returns the Functor argument which produces that optimum. | |
| void | setObjectiveFunction (const Functor &functor) |
| This method specifies the Functor instance to use for the optimization. | |
Protected Member Functions | |
| void | computeAxisSums (const std::vector< argument_type > ¤tPoints, argument_type &axisSums) |
| This protected member function collapses a vector of points by summing the corresponding elements of each point (useful for averaging a bunch of locations in parameter space). | |
| void | doNelderMead (std::vector< argument_type > ¤tPoints, std::vector< result_type > ¤tValues, size_t &numberOfFunctionCalls) |
| This protected member function runs the actual simplex search. | |
| result_type | evaluateMove (std::vector< argument_type > ¤tPoints, std::vector< result_type > ¤tValues, const argument_type &axisSums, double factor) |
| This protected member function is used to decide whether a proposed step is in fact a good one, and also updates its arguments if the move is accepted. | |
| std::pair< typename Functor::argument_type, typename Functor::result_type > | run () |
| This protected member function performs the minimization. | |
| virtual void | setOptimum (const typename Functor::argument_type &optimum, const typename Functor::result_type &optimalValue, bool needsFurtherOptimization) |
| This protected member function provides a way for subclasses to communicate intermediate optimization results outside of the normal "return value of this->run()" method. | |
Protected Attributes | |
| argument_type | m_delta |
| size_t | m_functionCallLimit |
| size_t | m_numberOfRestarts |
| double | m_alpha |
| double | m_beta |
| double | m_gamma |
| double | m_minimumSimplexValueSpan |
| bool | m_deltaValueHack |
| std::vector< size_t > | m_functionCallCount |
| argument_type | m_theta0 |
| size_t | m_verbosity |
| Functor | m_functor |
| m_functor->operator()() should compute the objective function. | |
| bool | m_needsOptimization |
| Set to false if m_optimum contains a valid optimum, true otherwise. | |
| argument_type | m_optimum |
| Caches the result of the most recent optimization. | |
| result_type | m_optimalValue |
| Caches the result of the most recent optimization. | |
This algorithm seeks the parameter value which minimizes the objective function. The template parameter (Functor) defines the type to use as the objective function of the minimization.
[1] W. H. Press et al., Numerical Recipes in C The Art of Scientific Computing, Cambridge University Press, 1988.
[2] J.A. Nelder and R. Mead. A simplex method for function minimization. Computer Journal, 7:303--313, 1965.
Definition at line 42 of file optimizerNelderMead.h.
| typedef Functor::argument_type dlr::optimization::OptimizerNelderMead< Functor >::argument_type |
This is the Type of the objective function argument.
Reimplemented from dlr::optimization::Optimizer< Functor >.
Definition at line 47 of file optimizerNelderMead.h.
| typedef Functor::result_type dlr::optimization::OptimizerNelderMead< Functor >::result_type |
This is the Type of the objective function return value.
Reimplemented from dlr::optimization::Optimizer< Functor >.
Definition at line 48 of file optimizerNelderMead.h.
| dlr::optimization::OptimizerNelderMead< Functor >::OptimizerNelderMead | ( | ) | [inline] |
Default constructor sets parameters to reasonable values for functions which take values and arguments in the "normal" range of 0 to 100 or so.
Definition at line 404 of file optimizerNelderMead.h.
References dlr::optimization::OptimizerNelderMead< Functor >::m_deltaValueHack, and dlr::optimization::OptimizerNelderMead< Functor >::setParameters().
| dlr::optimization::OptimizerNelderMead< Functor >::OptimizerNelderMead | ( | const Functor & | functor | ) | [inline, explicit] |
Constructor which specifies the specific Functor instance to use.
Using this constructor exclusively avoids the danger of calling optimalValue() or optimum() before a Functor instance has been specified.
| functor | A copy of this argument will be stored internally for use in optimization. |
Definition at line 419 of file optimizerNelderMead.h.
References dlr::optimization::OptimizerNelderMead< Functor >::m_deltaValueHack, and dlr::optimization::OptimizerNelderMead< Functor >::setParameters().
| dlr::optimization::OptimizerNelderMead< Functor >::OptimizerNelderMead | ( | const OptimizerNelderMead< Functor > & | source | ) | [inline] |
Copy constructor.
| source | The OptimizerNelderMead instance to be copied. |
Definition at line 432 of file optimizerNelderMead.h.
References dlr::optimization::copyArgumentType(), and dlr::optimization::OptimizerNelderMead< Functor >::m_delta.
| dlr::optimization::OptimizerNelderMead< Functor >::~OptimizerNelderMead | ( | ) | [inline] |
| std::vector< size_t > dlr::optimization::OptimizerNelderMead< Functor >::getNumberOfFunctionCalls | ( | ) | [inline, virtual] |
Queries the number of iterations required to complete the previous minimization.
If the minimization parameter "restarts" is 0, there will be only one number to report. If restarts is greater than 0, the first element of the return value will reflect the number of iterations in the initial minimization, and subsequent numbers will reflect the number of iterations in the following restarted minimizations.
Definition at line 462 of file optimizerNelderMead.h.
References dlr::optimization::OptimizerNelderMead< Functor >::m_functionCallCount.
| void dlr::optimization::OptimizerNelderMead< Functor >::setDelta | ( | const argument_type & | delta | ) |
This method sets the spacing of the initial points used in the nonlinear optimization, without affecting any other optimization parameters.
| delta | The method of Nelder and Mead requires not only a point in parameter space at which to start the minimization, but also N additional initial points, where N is the dimensionality of the parameter space. These will be automatically generated according to: p[i+1] = p[0] + delta[i]*e[i] where e[i] is all zeros except for a one in the i(th) position. |
| void dlr::optimization::OptimizerNelderMead< Functor >::setNumberOfRestarts | ( | size_t | numberOfRestarts | ) | [inline] |
Sets how many times the optimization will be restarted.
No smaller than 1 unless your objective function is very simple, since downhill simplex search often benefits from a restart or two.
| numberOfRestarts |
Definition at line 124 of file optimizerNelderMead.h.
References dlr::optimization::OptimizerNelderMead< Functor >::m_numberOfRestarts.
| void dlr::optimization::OptimizerNelderMead< Functor >::setParameters | ( | argument_type | delta, | |
| size_t | functionCallLimit = 5000, |
|||
| size_t | numberOfRestarts = 1, |
|||
| double | alpha = 1.0, |
|||
| double | beta = 0.5, |
|||
| double | gamma = 2.0, |
|||
| double | minimumSimplexValueSpan = 0.0001, |
|||
| size_t | verbosity = 0 | |||
| ) |
Sets minimization parameters.
Default values are reasonable for functions which take values and arguments in the "normal" range of 0 to 100 or so.
Since it is difficult to provide a default value for the template parameter type Functory::argument_type, no default is provided. If a default were provided, it would be a vector of all ones, with length equal to the dimensionality of the space over which the optimization is to be performed.
| delta | The method of Nelder and Mead requires not only a point in parameter space at which to start the minimization, but also N additional initial points, where N is the dimensionality of the parameter space. These will be automatically generated according to: p[i+1] = p[0] + delta[i]*e[i] where e[i] is all zeros except for a one in the i(th) position. | |
| functionCallLimit | Each minimization will terminate after this many iterations, even if a minimum has not been found. | |
| numberOfRestarts | Following successful termination, the minimization will be re-run this many times to refine the result accuracy. Generally you should set this to at least one for this algorithm, since restarting the algorithm frequently leads to significantly better final results. | |
| alpha | Specifies the size of the initial reflection step. | |
| beta | Specifies the size of the second reflection step. | |
| gamma | Specifies the "shrink" factor if neither reflection step is successful. | |
| minimumSimplexValueSpan | Terminate if, among the N + 1 current points, |
where pMax is the point generating the biggest value, and pMin is the point generating the smallest value.
| verbosity | Specifies how much standard output should be generated. Higher numbers mean more output. |
Referenced by dlr::optimization::OptimizerNelderMead< Functor >::OptimizerNelderMead().
| void dlr::optimization::OptimizerNelderMead< Functor >::setStartPoint | ( | argument_type | startPoint | ) | [inline, virtual] |
Sets the initial conditions for the minimization.
Gradient based search will start at this location in parameter space.
| startPoint | Indicates a point in the parameter space of the objective function. |
Definition at line 513 of file optimizerNelderMead.h.
References dlr::optimization::OptimizerNelderMead< Functor >::m_theta0.
| virtual void dlr::optimization::OptimizerNelderMead< Functor >::setVerbosity | ( | int | verbosity | ) | [inline, virtual] |
This function sets the level of text sent to standard output by the class.
| verbosity | This argument specifies how verbose to be. 0 means no output, 3 means lots. |
Definition at line 204 of file optimizerNelderMead.h.
References dlr::optimization::OptimizerNelderMead< Functor >::m_verbosity.
| OptimizerNelderMead< Functor > & dlr::optimization::OptimizerNelderMead< Functor >::operator= | ( | const OptimizerNelderMead< Functor > & | source | ) | [inline] |
Assignment operator.
| source | The OptimizerNelderMead instance to be copied. |
Definition at line 526 of file optimizerNelderMead.h.
References dlr::optimization::OptimizerNelderMead< Functor >::m_alpha, dlr::optimization::OptimizerNelderMead< Functor >::m_beta, dlr::optimization::OptimizerNelderMead< Functor >::m_delta, dlr::optimization::OptimizerNelderMead< Functor >::m_deltaValueHack, dlr::optimization::OptimizerNelderMead< Functor >::m_functionCallCount, dlr::optimization::OptimizerNelderMead< Functor >::m_functionCallLimit, dlr::optimization::OptimizerNelderMead< Functor >::m_gamma, dlr::optimization::OptimizerNelderMead< Functor >::m_minimumSimplexValueSpan, and dlr::optimization::OptimizerNelderMead< Functor >::m_numberOfRestarts.
| void dlr::optimization::OptimizerNelderMead< Functor >::computeAxisSums | ( | const std::vector< argument_type > & | currentPoints, | |
| argument_type & | axisSums | |||
| ) | [protected] |
This protected member function collapses a vector of points by summing the corresponding elements of each point (useful for averaging a bunch of locations in parameter space).
| currentPoints | This argument specifies the points to sum. | |
| axisSums | This argument is used to return the result. |
| void dlr::optimization::OptimizerNelderMead< Functor >::doNelderMead | ( | std::vector< argument_type > & | currentPoints, | |
| std::vector< result_type > & | currentValues, | |||
| size_t & | numberOfFunctionCalls | |||
| ) | [protected] |
This protected member function runs the actual simplex search.
It modifies all arguments.
| currentPoints | This argument specifies the initial set of points, and is used to return the final set of points. | |
| currentValues | This argument specifies the initial set of function values, and is used to return the final set of function values. | |
| numberOfFunctionCalls | This argument returns the total number of function calls required by the minimization. |
Referenced by dlr::optimization::OptimizerNelderMead< Functor >::run().
| OptimizerNelderMead< Functor >::result_type dlr::optimization::OptimizerNelderMead< Functor >::evaluateMove | ( | std::vector< argument_type > & | currentPoints, | |
| std::vector< result_type > & | currentValues, | |||
| const argument_type & | axisSums, | |||
| double | factor | |||
| ) | [inline, protected] |
This protected member function is used to decide whether a proposed step is in fact a good one, and also updates its arguments if the move is accepted.
| currentPoints | This argument specifies the current set of points in parameter space. | |
| currentValues | This argument specifies the function value at each of the points in currentPoints. | |
| axisSums | This argument passes in the sums of the elements of currentPoints. See protected member function computeAxisSums(). | |
| factor | This argument specifies the size of the step. |
Definition at line 653 of file optimizerNelderMead.h.
References dlr::optimization::Optimizer< Functor >::m_functor.
| std::pair< typename Functor::argument_type, typename Functor::result_type > dlr::optimization::OptimizerNelderMead< Functor >::run | ( | ) | [inline, protected, virtual] |
This protected member function performs the minimization.
Implements dlr::optimization::Optimizer< Functor >.
Definition at line 677 of file optimizerNelderMead.h.
References dlr::optimization::copyArgumentType(), DLR_THROW, dlr::optimization::OptimizerNelderMead< Functor >::doNelderMead(), dlr::optimization::OptimizerNelderMead< Functor >::m_delta, dlr::optimization::OptimizerNelderMead< Functor >::m_deltaValueHack, dlr::optimization::OptimizerNelderMead< Functor >::m_functionCallCount, dlr::optimization::Optimizer< Functor >::m_functor, dlr::optimization::OptimizerNelderMead< Functor >::m_numberOfRestarts, and dlr::optimization::OptimizerNelderMead< Functor >::m_theta0.
| Functor dlr::optimization::Optimizer< Functor >::objectiveFunction | ( | ) | [inline, inherited] |
This method returns a copy of the Functor instance used for optimization.
Definition at line 91 of file optimizer.h.
References dlr::optimization::Optimizer< Functor >::m_functor.
| Optimizer< Functor >::result_type dlr::optimization::Optimizer< Functor >::optimalValue | ( | ) | [inline, inherited] |
This method finds the optimum of the current Functor, if necessary, and returns the Functor value at that point.
Note that you must have specified an objective function (Functor) before calling this method.
Definition at line 282 of file optimizer.h.
References dlr::optimization::Optimizer< Functor >::m_needsOptimization, dlr::optimization::Optimizer< Functor >::m_optimalValue, dlr::optimization::Optimizer< Functor >::run(), and dlr::optimization::Optimizer< Functor >::setOptimum().
| Optimizer< Functor >::argument_type dlr::optimization::Optimizer< Functor >::optimum | ( | ) | [inline, inherited] |
This method finds the optimum of the current Functor, if necessary, and returns the Functor argument which produces that optimum.
Note that you must have specified an objective function (Functor) before calling this method.
Definition at line 297 of file optimizer.h.
References dlr::optimization::Optimizer< Functor >::m_needsOptimization, dlr::optimization::Optimizer< Functor >::m_optimum, dlr::optimization::Optimizer< Functor >::run(), and dlr::optimization::Optimizer< Functor >::setOptimum().
| void dlr::optimization::Optimizer< Functor >::setObjectiveFunction | ( | const Functor & | functor | ) | [inline, inherited] |
This method specifies the Functor instance to use for the optimization.
If this function is overridden by the base class, it should normally either call Optimizer::setObjectiveFunction(), or explicitly set the member variable m_needsOptimization to true.
| functor | A copy of this argument will be stored internally for use in optimization. |
Definition at line 311 of file optimizer.h.
References dlr::optimization::Optimizer< Functor >::m_functor, and dlr::optimization::Optimizer< Functor >::m_needsOptimization.
| virtual void dlr::optimization::Optimizer< Functor >::setOptimum | ( | const typename Functor::argument_type & | optimum, | |
| const typename Functor::result_type & | optimalValue, | |||
| bool | needsFurtherOptimization | |||
| ) | [inline, protected, virtual, inherited] |
This protected member function provides a way for subclasses to communicate intermediate optimization results outside of the normal "return value of this->run()" method.
| optimum | This argument will be saved as the current optimum. | |
| optimalValue | This argument will be saved as the function value a the current optimum. | |
| needsFurtherOptimization | This argument indicates whether or not further refinement is necessary. |
Definition at line 172 of file optimizer.h.
References dlr::optimization::Optimizer< Functor >::m_needsOptimization, dlr::optimization::Optimizer< Functor >::m_optimalValue, and dlr::optimization::Optimizer< Functor >::m_optimum.
Referenced by dlr::optimization::Optimizer< Functor >::optimalValue(), and dlr::optimization::Optimizer< Functor >::optimum().
Functor dlr::optimization::Optimizer< Functor >::m_functor [protected, inherited] |
m_functor->operator()() should compute the objective function.
Definition at line 182 of file optimizer.h.
Referenced by dlr::optimization::OptimizerBFGS< Functor >::doBfgs(), dlr::optimization::OptimizerNelderMead< Functor >::evaluateMove(), dlr::optimization::Optimizer< Functor >::objectiveFunction(), dlr::optimization::Optimizer< Functor >::operator=(), dlr::optimization::OptimizerNelderMead< Functor >::run(), dlr::optimization::OptimizerLM< Functor >::run(), dlr::optimization::OptimizerLineSearch< Functor >::run(), dlr::optimization::OptimizerBFGS< Functor >::run(), dlr::optimization::Optimizer< Functor >::setObjectiveFunction(), and dlr::optimization::OptimizerLineSearch< Functor >::setStartPoint().
bool dlr::optimization::Optimizer< Functor >::m_needsOptimization [protected, inherited] |
Set to false if m_optimum contains a valid optimum, true otherwise.
Definition at line 185 of file optimizer.h.
Referenced by dlr::optimization::Optimizer< Functor >::operator=(), dlr::optimization::Optimizer< Functor >::optimalValue(), dlr::optimization::Optimizer< Functor >::optimum(), dlr::optimization::OptimizerLineSearch< Functor >::setInitialStep(), dlr::optimization::Optimizer< Functor >::setObjectiveFunction(), dlr::optimization::Optimizer< Functor >::setOptimum(), dlr::optimization::OptimizerLineSearch< Functor >::setParameters(), and dlr::optimization::OptimizerLineSearch< Functor >::setStartPoint().
argument_type dlr::optimization::Optimizer< Functor >::m_optimum [protected, inherited] |
Caches the result of the most recent optimization.
Definition at line 188 of file optimizer.h.
Referenced by dlr::optimization::Optimizer< Functor >::operator=(), dlr::optimization::Optimizer< Functor >::Optimizer(), dlr::optimization::Optimizer< Functor >::optimum(), and dlr::optimization::Optimizer< Functor >::setOptimum().
result_type dlr::optimization::Optimizer< Functor >::m_optimalValue [protected, inherited] |
Caches the result of the most recent optimization.
Definition at line 191 of file optimizer.h.
Referenced by dlr::optimization::Optimizer< Functor >::optimalValue(), and dlr::optimization::Optimizer< Functor >::setOptimum().
1.5.2