shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT > Class Template Referenceabstract

An optimizer that optimizes general objective functions. More...

#include <shark/Algorithms/AbstractOptimizer.h>

+ Inheritance diagram for shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >:

Public Types

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
 

Public Member Functions

const Featuresfeatures () const
 
virtual void updateFeatures ()
 
bool requiresValue () const
 
bool requiresFirstDerivative () const
 
bool requiresSecondDerivative () const
 
bool canSolveConstrained () const
 
bool requiresClosestFeasible () const
 
virtual ~AbstractOptimizer ()
 
virtual std::size_t numInitPoints () const =0
 Returns the number of points this method requires for initialisation. More...
 
virtual void init (ObjectiveFunctionType const &function)
 Initialize the optimizer for the supplied objective function. More...
 
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. More...
 
virtual void step (ObjectiveFunctionType const &function)=0
 Carry out one step of the optimizer for the supplied objective function. More...
 
virtual SolutionType const & solution () const =0
 Accesses the best solution obtained so far. More...
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
virtual std::string name () const
 returns the name of the object More...
 
- Public Member Functions inherited from shark::ISerializable
virtual ~ISerializable ()
 Virtual d'tor. More...
 
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...
 
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 Member Functions

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...
 

Protected Attributes

Features m_features
 

Detailed Description

template<typename PointType, typename ResultT, typename SolutionTypeT>
class shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >

An optimizer that optimizes general objective functions.

After construction and configurationg the optimizer, init() is called with the objective function to be used. After that step() can be called until the required solution is found. The solution can be queried using solution(). The type of the solution depends on the optimisation problem at hand. It is allowed to add constrains on the features the objective function needs to offer

These are:

  • REQUIRES_VALUE: The function is evaluated to use the optimizer and the HAS_VALUE-flag must be set
  • REQUIRES_FIRST_DERIVATIVE: The first derivative needs to be evaluated and
  • HAS_FIRST_DERIVATIVE must be set
  • REQUIRES_SECOND_DERIVATIVE: The second derivative needs to be evaluated and
  • HAS_SECOND_DERIVATIVE must be set
  • CAN_SOLVE_CONSTRAINED: The optimizer can solve functions which are constrained and where the IS_CONSTRAINED_FEATURE is set.
  • REQUIRES_CLOSEST_FEASIBLE: If the function is constrained, it must offer a way to construct the closest feasible point and
  • CAN_PROVIDE_CLOSEST_FEASIBLE must be set

Also when init() is called as offered by the AbstractOptimizer interface, the function is required to have the CAN_PROPOSE_STARTING_POINT flag.

Template Parameters
PointTypeThe type of search space the optimizer works upon.
ResultTThe objective space the optimizer works upon.
SolutionTypeTThe type of the final solution.

Definition at line 68 of file AbstractOptimizer.h.

Member Typedef Documentation

◆ FeatureNotAvailableException

template<typename PointType, typename ResultT, typename SolutionTypeT>
typedef TypedFeatureNotAvailableException<Feature> shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::FeatureNotAvailableException

Definition at line 85 of file AbstractOptimizer.h.

◆ Features

template<typename PointType, typename ResultT, typename SolutionTypeT>
typedef TypedFlags<Feature> shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::Features

Definition at line 85 of file AbstractOptimizer.h.

◆ ObjectiveFunctionType

template<typename PointType, typename ResultT, typename SolutionTypeT>
typedef AbstractObjectiveFunction<PointType,ResultType> shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::ObjectiveFunctionType

Definition at line 73 of file AbstractOptimizer.h.

◆ ResultType

template<typename PointType, typename ResultT, typename SolutionTypeT>
typedef ResultT shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::ResultType

Definition at line 71 of file AbstractOptimizer.h.

◆ SearchPointType

template<typename PointType, typename ResultT, typename SolutionTypeT>
typedef PointType shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::SearchPointType

Definition at line 70 of file AbstractOptimizer.h.

◆ SolutionType

template<typename PointType, typename ResultT, typename SolutionTypeT>
typedef SolutionTypeT shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::SolutionType

Definition at line 72 of file AbstractOptimizer.h.

Member Enumeration Documentation

◆ Feature

template<typename PointType, typename ResultT, typename SolutionTypeT>
enum shark::AbstractOptimizer::Feature

Models features that the optimizer requires from the objective function.

See also
AbstractObjectiveFunction
Enumerator
REQUIRES_VALUE 
REQUIRES_FIRST_DERIVATIVE 
REQUIRES_SECOND_DERIVATIVE 
CAN_SOLVE_CONSTRAINED 
REQUIRES_CLOSEST_FEASIBLE 

Definition at line 77 of file AbstractOptimizer.h.

Constructor & Destructor Documentation

◆ ~AbstractOptimizer()

template<typename PointType, typename ResultT, typename SolutionTypeT>
virtual shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::~AbstractOptimizer ( )
inlinevirtual

Definition at line 104 of file AbstractOptimizer.h.

Member Function Documentation

◆ canSolveConstrained()

template<typename PointType, typename ResultT, typename SolutionTypeT>
bool shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::canSolveConstrained ( ) const
inline

◆ checkFeatures()

template<typename PointType, typename ResultT, typename SolutionTypeT>
void shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::checkFeatures ( ObjectiveFunctionType const &  objectiveFunction)
inlineprotected

Convenience function that checks whether the features of the supplied objective function match with the required features of the optimizer.

Parameters
[in]objectiveFunctionThe function to match with.
Exceptions
shark::Exception

Definition at line 152 of file AbstractOptimizer.h.

◆ features()

◆ init() [1/2]

template<typename PointType, typename ResultT, typename SolutionTypeT>
virtual void shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::init ( ObjectiveFunctionType const &  function)
inlinevirtual

Initialize the optimizer for the supplied objective function.

Be aware that function.init() has to be called before calling this function! This function will initialize the algorithm with a number of points proposed by the function. Note that this must fail if the function can not propose starting point(s).

Parameters
[in]functionThe objective function to initialize for.

Definition at line 119 of file AbstractOptimizer.h.

Referenced by shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::init().

◆ init() [2/2]

template<typename PointType, typename ResultT, typename SolutionTypeT>
virtual void shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::init ( ObjectiveFunctionType const &  function,
std::vector< SearchPointType > const &  initPoints 
)
pure virtual

Initialize the optimizer for the supplied objective function using a set of initialisation points.

Most single objective algorithms only require a single point. However multi-objective algorithms need a set of initialisation points. The number of points required should be numInitPoints(). Otherwise the algorithm might use heuristics to generate additional points if needed.

Be aware that function.init() has to be called before calling this function!

Parameters
[in]functionThe objective function to initialize for.
[in]initPointspoints used for initialisation. Should be at least numInitPoints().

Implemented in shark::RVEA, shark::IndicatorBasedRealCodedNSGAII< Indicator >, shark::IndicatorBasedRealCodedNSGAII< NSGA3Indicator >, shark::IndicatorBasedSteadyStateMOCMA< Indicator >, shark::SMSEMOA, shark::IndicatorBasedMOCMA< Indicator >, shark::AbstractSingleObjectiveOptimizer< PointType >, and shark::AbstractSingleObjectiveOptimizer< RealVector >.

◆ numInitPoints()

template<typename PointType, typename ResultT, typename SolutionTypeT>
virtual std::size_t shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::numInitPoints ( ) const
pure virtual

◆ requiresClosestFeasible()

template<typename PointType, typename ResultT, typename SolutionTypeT>
bool shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::requiresClosestFeasible ( ) const
inline

◆ requiresFirstDerivative()

template<typename PointType, typename ResultT, typename SolutionTypeT>
bool shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::requiresFirstDerivative ( ) const
inline

◆ requiresSecondDerivative()

template<typename PointType, typename ResultT, typename SolutionTypeT>
bool shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::requiresSecondDerivative ( ) const
inline

◆ requiresValue()

template<typename PointType, typename ResultT, typename SolutionTypeT>
bool shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::requiresValue ( ) const
inline

◆ solution()

template<typename PointType, typename ResultT, typename SolutionTypeT>
virtual SolutionType const& shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::solution ( ) const
pure virtual

◆ step()

◆ updateFeatures()

template<typename PointType, typename ResultT, typename SolutionTypeT>
virtual void shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::updateFeatures ( )
inlinevirtual

Definition at line 85 of file AbstractOptimizer.h.

Member Data Documentation

◆ m_features

template<typename PointType, typename ResultT, typename SolutionTypeT>
Features shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::m_features
protected

Definition at line 85 of file AbstractOptimizer.h.


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