Optimize by trying out a grid of configurations. More...
#include <shark/Algorithms/DirectSearch/GridSearch.h>
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 (double min1, double max1, size_t sections1) |
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 (ObjectiveFunctionType &objectiveFunction, SearchPointType const &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 (ObjectiveFunctionType const &objectiveFunction) |
![]() | |
virtual void | init (ObjectiveFunctionType &function) |
virtual const SolutionType & | solution () const |
returns the current solution of the optimizer More... | |
![]() | |
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... | |
![]() | |
virtual | ~INameable () |
![]() | |
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 |
![]() | |
SolutionType | m_best |
current solution of the optimizer More... | |
![]() | |
Features | m_features |
Additional Inherited Members | |
![]() | |
typedef base_type::SearchPointType | SearchPointType |
typedef base_type::SolutionType | SolutionType |
typedef base_type::ResultType | ResultType |
typedef base_type::ObjectiveFunctionType | ObjectiveFunctionType |
![]() | |
enum | Feature |
Models features that the optimizer requires from the objective function. More... | |
typedef RealVector | SearchPointType |
typedef double | ResultType |
typedef SingleObjectiveResultSet< RealVector > | SolutionType |
typedef AbstractObjectiveFunction< RealVector, ResultType > | ObjectiveFunctionType |
typedef TypedFlags< Feature > | Features |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
![]() | |
void | checkFeatures (ObjectiveFunctionType const &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 64 of file GridSearch.h.
|
inline |
Definition at line 67 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 265 of file GridSearch.h.
References m_nodeValues, shark::blas::min(), 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 239 of file GridSearch.h.
References 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 82 of file GridSearch.h.
References m_configured, m_nodeValues, shark::blas::min(), RANGE_CHECK, and SIZE_CHECK.
Referenced by init(), shark::NestedGridSearch::init(), shark::PointSearch::init(), and main().
|
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 101 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 135 of file GridSearch.h.
References m_nodeValues, and RANGE_CHECK.
|
inline |
special case for line search
min1 | smallest value for first parameter |
max1 | largest value for first parameter |
sections1 | total number of values for first parameter |
Definition at line 163 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 182 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 194 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< RealVector >.
Definition at line 223 of file GridSearch.h.
References shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > >::checkFeatures(), configure(), shark::AbstractObjectiveFunction< PointType, ResultT >::init(), shark::AbstractSingleObjectiveOptimizer< RealVector >::m_best, m_configured, m_nodeValues, shark::ResultSet< SearchPointT, ResultT >::point, and SIZE_CHECK.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 72 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 202 of file GridSearch.h.
References shark::AbstractSingleObjectiveOptimizer< RealVector >::m_best, m_configured, m_nodeValues, shark::ResultSet< SearchPointT, ResultT >::point, and shark::ResultSet< SearchPointT, ResultT >::value.
|
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< RealVector, double, SingleObjectiveResultSet< RealVector > >.
Definition at line 279 of file GridSearch.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::eval(), shark::AbstractObjectiveFunction< PointType, ResultT >::isFeasible(), shark::AbstractSingleObjectiveOptimizer< RealVector >::m_best, m_nodeValues, shark::ResultSet< SearchPointT, ResultT >::point, shark::size(), and shark::ResultSet< SearchPointT, ResultT >::value.
Referenced by main(), and shark::NestedGridSearch::step().
|
inlinevirtual |
Write the component to the supplied archive.
[in,out] | archive | The archive to write to. |
Reimplemented from shark::ISerializable.
Definition at line 210 of file GridSearch.h.
References shark::AbstractSingleObjectiveOptimizer< RealVector >::m_best, m_configured, m_nodeValues, shark::ResultSet< SearchPointT, ResultT >::point, and shark::ResultSet< SearchPointT, ResultT >::value.
|
protected |
Definition at line 330 of file GridSearch.h.
Referenced by configure(), shark::NestedGridSearch::configure(), shark::PointSearch::configure(), GridSearch(), init(), shark::NestedGridSearch::init(), shark::PointSearch::init(), shark::NestedGridSearch::NestedGridSearch(), shark::PointSearch::PointSearch(), read(), shark::NestedGridSearch::read(), shark::PointSearch::read(), write(), shark::NestedGridSearch::write(), and shark::PointSearch::write().
|
protected |
The array columns contain the grid values for the corresponding parameter axis.
Definition at line 328 of file GridSearch.h.
Referenced by assignExponentialRange(), assignLinearRange(), configure(), init(), read(), step(), and write().