shark::PointSearch Class Reference

Optimize by trying out predefined configurations. More...

#include <shark/Algorithms/DirectSearch/GridSearch.h>

+ Inheritance diagram for shark::PointSearch:

Public Member Functions

 PointSearch ()
 Constructor.
 
std::string name () const
 From INameable: return the class name.
 
void configure (const std::vector< RealVector > &points)
 
void configure (size_t parameters, size_t samples, double min, double max)
 samples random points in the range [min,max]^parameters
 
virtual void read (InArchive &archive)
 Read the component from the supplied archive.
 
virtual void write (OutArchive &archive) const
 Write the component to the supplied archive.
 
void init (ObjectiveFunctionType const &objectiveFunction, SearchPointType const &startingPoint)
 If the class wasn't configured before, this method samples random uniform distributed points in [-1,1]^n.
 
void step (ObjectiveFunctionType const &objectiveFunction)
 
- Public Member Functions inherited from shark::AbstractSingleObjectiveOptimizer< RealVector >
std::size_t numInitPoints () const
 By default most single objective optimizers only require a single point.
 
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.
 
virtual const SolutionTypesolution () const
 returns the current solution of the optimizer
 
- Public Member Functions inherited from shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >
const Featuresfeatures () 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.
 
virtual void init (ObjectiveFunctionType const &function, std::vector< SearchPointType > const &initPoints)=0
 Initialize the optimizer for the supplied objective function using a set of initialisation points.
 
virtual void step (ObjectiveFunctionType const &function)=0
 Carry out one step of the optimizer for the supplied objective function.
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
- Public Member Functions inherited from shark::ISerializable
virtual ~ISerializable ()
 Virtual d'tor.
 
void load (InArchive &archive, unsigned int version)
 Versioned loading of components, calls read(...).
 
void save (OutArchive &archive, unsigned int version) const
 Versioned storing of components, calls write(...).
 
 BOOST_SERIALIZATION_SPLIT_MEMBER ()
 

Protected Attributes

std::vector< RealVector > m_points
 The array holds one parameter configuration in every column.
 
bool m_configured
 verbosity level
 
- Protected Attributes inherited from shark::AbstractSingleObjectiveOptimizer< RealVector >
SolutionType m_best
 Current solution of the optimizer.
 
- Protected Attributes inherited from shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >
Features m_features
 

Additional Inherited Members

- Public Types inherited from shark::AbstractSingleObjectiveOptimizer< RealVector >
typedef base_type::SearchPointType SearchPointType
 
typedef base_type::SolutionType SolutionType
 
typedef base_type::ResultType ResultType
 
typedef base_type::ObjectiveFunctionType ObjectiveFunctionType
 
- Public Types inherited from shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >
enum  Feature {
  REQUIRES_VALUE = 1 , REQUIRES_FIRST_DERIVATIVE = 2 , REQUIRES_SECOND_DERIVATIVE = 4 , CAN_SOLVE_CONSTRAINED = 8 ,
  REQUIRES_CLOSEST_FEASIBLE = 16
}
 Models features that the optimizer requires from the objective function. More...
 
typedef PointType SearchPointType
 
typedef ResultT ResultType
 
typedef SolutionTypeT SolutionType
 
typedef AbstractObjectiveFunction< PointType, ResultTypeObjectiveFunctionType
 
typedef TypedFlags< FeatureFeatures
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 
- Protected Member Functions inherited from shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >
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.
 

Detailed Description

Optimize by trying out predefined configurations.

The PointSearch class is similair to the GridSearch class by the property that it optimizes a model in a single pass just trying out a predefined number of parameter configurations. The main difference is that every parameter configuration has to be explicitly defined. It is not possible to define a set of values for every axis; see GridSearch for this purpose. Thus, the PointSearch class allows for more flexibility.

If no configure method is called, this class just samples random points. They are uniformly distributed in [-1,1]. parameters^2 points but minimum 20 are sampled in this case.

Definition at line 564 of file GridSearch.h.

Constructor & Destructor Documentation

◆ PointSearch()

shark::PointSearch::PointSearch ( )
inline

Constructor.

Definition at line 568 of file GridSearch.h.

References m_configured.

Member Function Documentation

◆ configure() [1/2]

void shark::PointSearch::configure ( const std::vector< RealVector > &  points)
inline

Initialization of the search points.

Parameters
pointsarray of points to evaluate

Definition at line 580 of file GridSearch.h.

References m_configured, and m_points.

Referenced by init().

◆ configure() [2/2]

void shark::PointSearch::configure ( size_t  parameters,
size_t  samples,
double  min,
double  max 
)
inline

samples random points in the range [min,max]^parameters

Definition at line 586 of file GridSearch.h.

References shark::random::globalRng, m_configured, m_points, RANGE_CHECK, and shark::random::uni().

◆ init()

void shark::PointSearch::init ( ObjectiveFunctionType const &  objectiveFunction,
SearchPointType const &  startingPoint 
)
inlinevirtual

If the class wasn't configured before, this method samples random uniform distributed points in [-1,1]^n.

Implements shark::AbstractSingleObjectiveOptimizer< RealVector >.

Definition at line 617 of file GridSearch.h.

References shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::checkFeatures(), configure(), m_configured, and shark::sqr().

◆ name()

std::string shark::PointSearch::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 573 of file GridSearch.h.

◆ read()

virtual void shark::PointSearch::read ( InArchive archive)
inlinevirtual

Read the component from the supplied archive.

Parameters
[in,out]archiveThe archive to read from.

Reimplemented from shark::ISerializable.

Definition at line 600 of file GridSearch.h.

References shark::AbstractSingleObjectiveOptimizer< RealVector >::m_best, m_configured, and m_points.

◆ step()

void shark::PointSearch::step ( ObjectiveFunctionType const &  objectiveFunction)
inline

Please note that for the point search optimizer it does not make sense to call step more than once, as the solution does not improve iteratively.

Definition at line 631 of file GridSearch.h.

References shark::AbstractSingleObjectiveOptimizer< RealVector >::m_best, and m_points.

◆ write()

virtual void shark::PointSearch::write ( OutArchive archive) const
inlinevirtual

Write the component to the supplied archive.

Parameters
[in,out]archiveThe archive to write to.

Reimplemented from shark::ISerializable.

Definition at line 608 of file GridSearch.h.

References shark::AbstractSingleObjectiveOptimizer< RealVector >::m_best, m_configured, and m_points.

Member Data Documentation

◆ m_configured

bool shark::PointSearch::m_configured
protected

verbosity level

Definition at line 658 of file GridSearch.h.

Referenced by configure(), configure(), init(), PointSearch(), read(), and write().

◆ m_points

std::vector<RealVector> shark::PointSearch::m_points
protected

The array holds one parameter configuration in every column.

Definition at line 655 of file GridSearch.h.

Referenced by configure(), configure(), read(), step(), and write().


The documentation for this class was generated from the following file: