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 const &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) |
![]() | |
std::size_t | numInitPoints () const |
By default most single objective optimizers only require a single point. More... | |
virtual void | init (ObjectiveFunctionType const &function, std::vector< SearchPointType > const &initPoints) |
Initialize the optimizer for the supplied objective function using a set of initialisation points. More... | |
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 () |
virtual void | init (ObjectiveFunctionType const &function) |
Initialize the optimizer for the supplied objective function. 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 63 of file GridSearch.h.
|
inline |
Definition at line 66 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⋅expbasei, 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 263 of file GridSearch.h.
|
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 237 of file GridSearch.h.
|
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 81 of file GridSearch.h.
Referenced by init(), and shark::NestedGridSearch::init().
|
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 100 of file GridSearch.h.
|
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 134 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 162 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 181 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 193 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 222 of file GridSearch.h.
References shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > >::checkFeatures(), configure(), 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 71 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 201 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 277 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, and shark::ResultSet< SearchPointT, ResultT >::value.
Referenced by 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 209 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 328 of file GridSearch.h.
Referenced by 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 326 of file GridSearch.h.
Referenced by configure(), init(), read(), step(), and write().