Optimize by trying out a grid of configurations. More...
#include <shark/Algorithms/DirectSearch/GridSearch.h>
Inheritance diagram for shark::GridSearch:
Collaboration diagram for shark::GridSearch:Public Member Functions | |
| GridSearch () | |
| std::string | name () const |
| From INameable: return the class name. More... | |
| void | configure (size_t params, double min, double max, size_t numSections) |
| void | configure (const std::vector< double > &min, const std::vector< double > &max, const std::vector< size_t > §ions) |
| void | configure (double min1, double max1, size_t sections1, double min2, double max2, size_t sections2) |
| void | configure (size_t params, const std::vector< double > &values) |
| void | configure (const std::vector< std::vector< double > > &values) |
| virtual void | read (InArchive &archive) |
| Read the component from the supplied archive. More... | |
| virtual void | write (OutArchive &archive) const |
| Write the component to the supplied archive. More... | |
| virtual void | init (const ObjectiveFunctionType &objectiveFunction, const SearchPointType &startingPoint) |
| void | assignLinearRange (size_t index, size_t noOfSections, double min, double max) |
| void | assignExponentialRange (size_t index, double factor, double exp_base, int min, int max) |
| void | step (const ObjectiveFunctionType &objectiveFunction) |
Public Member Functions inherited from shark::AbstractSingleObjectiveOptimizer< VectorSpace< double > > | |
| virtual void | init (ObjectiveFunctionType const &function) |
| virtual const SolutionSetType & | solution () const |
| returns the current solution of the optimizer More... | |
Public Member Functions inherited from shark::AbstractOptimizer< SearchSpaceT, ResultT, SetT > | |
| const Features & | features () const |
| virtual void | updateFeatures () |
| bool | requiresValue () const |
| bool | requiresFirstDerivative () const |
| bool | requiresSecondDerivative () const |
| bool | canSolveConstrained () const |
| bool | requiresClosestFeasible () const |
| virtual | ~AbstractOptimizer () |
| Empty virtual d'tor. More... | |
Public Member Functions inherited from shark::IConfigurable | |
| virtual | ~IConfigurable () |
| Virtual d'tor. More... | |
| virtual void | configure (const PropertyTree &node) |
| Configures the component given a property tree. More... | |
Public Member Functions inherited from shark::INameable | |
| virtual | ~INameable () |
Public Member Functions inherited from shark::ISerializable | |
| virtual | ~ISerializable () |
| Virtual d'tor. More... | |
| void | load (InArchive &archive, unsigned int version) |
| Versioned loading of components, calls read(...). More... | |
| void | save (OutArchive &archive, unsigned int version) const |
| Versioned storing of components, calls write(...). More... | |
| BOOST_SERIALIZATION_SPLIT_MEMBER () | |
Protected Attributes | |
| std::vector< std::vector < double > > | m_nodeValues |
| The array columns contain the grid values for the corresponding parameter axis. More... | |
| bool | m_configured |
Protected Attributes inherited from shark::AbstractSingleObjectiveOptimizer< VectorSpace< double > > | |
| SolutionSetType | m_best |
| current solution of the optimizer More... | |
Protected Attributes inherited from shark::AbstractOptimizer< SearchSpaceT, ResultT, SetT > | |
| Features | m_features |
Additional Inherited Members | |
Public Types inherited from shark::AbstractSingleObjectiveOptimizer< VectorSpace< double > > | |
| typedef base_type::SearchSpaceType | SearchSpaceType |
| typedef base_type::SearchPointType | SearchPointType |
| typedef base_type::SolutionSetType | SolutionSetType |
| typedef base_type::ResultType | ResultType |
| typedef base_type::ObjectiveFunctionType | ObjectiveFunctionType |
Protected Member Functions inherited from shark::AbstractOptimizer< SearchSpaceT, ResultT, SetT > | |
| void | checkFeatures (const ObjectiveFunctionType &objectiveFunction) |
| Convenience function that checks whether the features of the supplied objective function match with the required features of the optimizer. More... | |
Optimize by trying out a grid of configurations.
Definition at line 67 of file GridSearch.h.
|
inline |
Definition at line 70 of file GridSearch.h.
References m_configured.
|
inline |
Set exponentially progressing grid values for one certain parameter only. This is especially useful if one parameter needs special treatment. The grid points will be filled with values \( factor \cdot expbase ^i \), where i does integer steps between min and max.
| index | the index of the parameter that gets new grid values |
| factor | the value that the exponential base grid should be multiplied by |
| exp_base | the exponential grid will progress on this base (e.g. 2, 10) |
| min | the smallest exponent for exp_base |
| max | the largest exponent for exp_base |
Definition at line 247 of file GridSearch.h.
References shark::blas::dimension::index(), m_nodeValues, shark::blas::min(), shark::blas::pow(), RANGE_CHECK, and SIZE_CHECK.
|
inline |
Assign linearly progressing grid values to one certain parameter only. This is especially useful if one parameter needs special treatment
| index | the index of the parameter to which grid values are assigned |
| noOfSections | how many grid points should be assigned to that parameter |
| min | smallest value for that parameter |
| max | largest value for that parameter |
Definition at line 219 of file GridSearch.h.
References shark::blas::dimension::index(), m_nodeValues, RANGE_CHECK, and SIZE_CHECK.
|
inline |
uniform initialization for all parameters
| params | number of model parameters to optimize |
| min | smallest parameter value |
| max | largest parameter value |
| numSections | total number of values in the interval |
Definition at line 83 of file GridSearch.h.
References m_configured, m_nodeValues, shark::blas::min(), RANGE_CHECK, and SIZE_CHECK.
|
inline |
individual definition for every parameter
| min | smallest value for every parameter |
| max | largest value for every parameter |
| sections | total number of values for every parameter |
Definition at line 102 of file GridSearch.h.
References m_configured, m_nodeValues, RANGE_CHECK, and SIZE_CHECK.
|
inline |
special case for 2D grid, individual definition for every parameter
| min1 | smallest value for first parameter |
| max1 | largest value for first parameter |
| sections1 | total number of values for first parameter |
| min2 | smallest value for second parameter |
| max2 | largest value for second parameter |
| sections2 | total number of values for second parameter |
Definition at line 136 of file GridSearch.h.
References m_nodeValues, and RANGE_CHECK.
|
inline |
uniform definition of the values to test for all parameters
| params | number of model parameters to optimize |
| values | values used for every coordinate |
Definition at line 163 of file GridSearch.h.
References m_configured, m_nodeValues, and SIZE_CHECK.
|
inline |
individual definition for every parameter
| values | values used. The first dimension is the parameter, the second dimension is the node. |
Definition at line 175 of file GridSearch.h.
References m_configured, m_nodeValues, and SIZE_CHECK.
|
inlinevirtual |
If Gridsearch wasn't configured before calling this method, it is default constructed as a net spanning the range [-1,1] in all dimensions with 5 searchpoints (-1,-0.5,0,0.5,1). so don't forget to scale the parameter-ranges of the objective function! The startingPoint can actually be anything, only its dimension has to be correct.
Implements shark::AbstractSingleObjectiveOptimizer< VectorSpace< double > >.
Definition at line 204 of file GridSearch.h.
References configure(), shark::AbstractSingleObjectiveOptimizer< VectorSpace< double > >::m_best, m_configured, m_nodeValues, and SIZE_CHECK.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 75 of file GridSearch.h.
|
inlinevirtual |
Read the component from the supplied archive.
| [in,out] | archive | The archive to read from. |
Reimplemented from shark::ISerializable.
Definition at line 183 of file GridSearch.h.
References shark::AbstractSingleObjectiveOptimizer< VectorSpace< double > >::m_best, m_configured, and m_nodeValues.
|
inlinevirtual |
Please note that for the grid search optimizer it does not make sense to call step more than once, as the solution does not improve iteratively.
Implements shark::AbstractOptimizer< SearchSpaceT, ResultT, SetT >.
Definition at line 261 of file GridSearch.h.
References shark::AbstractObjectiveFunction< SearchSpaceType, ResultT >::eval(), shark::blas::dimension::index(), shark::AbstractObjectiveFunction< SearchSpaceType, ResultT >::isFeasible(), shark::AbstractSingleObjectiveOptimizer< VectorSpace< double > >::m_best, m_nodeValues, and shark::size().
Referenced by main().
|
inlinevirtual |
Write the component to the supplied archive.
| [in,out] | archive | The archive to write to. |
Reimplemented from shark::ISerializable.
Definition at line 191 of file GridSearch.h.
References shark::AbstractSingleObjectiveOptimizer< VectorSpace< double > >::m_best, m_configured, and m_nodeValues.
|
protected |
Definition at line 306 of file GridSearch.h.
Referenced by configure(), GridSearch(), init(), read(), and write().
|
protected |
The array columns contain the grid values for the corresponding parameter axis.
Definition at line 304 of file GridSearch.h.
Referenced by assignExponentialRange(), assignLinearRange(), configure(), init(), read(), step(), and write().