An optimizer that optimizes general objective functions. More...
#include <shark/Algorithms/AbstractOptimizer.h>
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, ResultType > | ObjectiveFunctionType |
typedef TypedFlags< Feature > | Features |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Public Member Functions | |
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 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 |
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:
Also when init() is called as offered by the AbstractOptimizer interface, the function is required to have the CAN_PROPOSE_STARTING_POINT flag.
PointType | The type of search space the optimizer works upon. |
ResultT | The objective space the optimizer works upon. |
SolutionTypeT | The type of the final solution. |
Definition at line 68 of file AbstractOptimizer.h.
typedef TypedFeatureNotAvailableException<Feature> shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::FeatureNotAvailableException |
Definition at line 85 of file AbstractOptimizer.h.
typedef TypedFlags<Feature> shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::Features |
Definition at line 85 of file AbstractOptimizer.h.
typedef AbstractObjectiveFunction<PointType,ResultType> shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::ObjectiveFunctionType |
Definition at line 73 of file AbstractOptimizer.h.
typedef ResultT shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::ResultType |
Definition at line 71 of file AbstractOptimizer.h.
typedef PointType shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::SearchPointType |
Definition at line 70 of file AbstractOptimizer.h.
typedef SolutionTypeT shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::SolutionType |
Definition at line 72 of file AbstractOptimizer.h.
enum shark::AbstractOptimizer::Feature |
Models features that the optimizer requires from the objective function.
Enumerator | |
---|---|
REQUIRES_VALUE | |
REQUIRES_FIRST_DERIVATIVE | |
REQUIRES_SECOND_DERIVATIVE | |
CAN_SOLVE_CONSTRAINED | |
REQUIRES_CLOSEST_FEASIBLE |
Definition at line 77 of file AbstractOptimizer.h.
|
inlinevirtual |
Definition at line 104 of file AbstractOptimizer.h.
|
inline |
Definition at line 97 of file AbstractOptimizer.h.
Referenced by shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::checkFeatures().
|
inlineprotected |
Convenience function that checks whether the features of the supplied objective function match with the required features of the optimizer.
[in] | objectiveFunction | The function to match with. |
shark::Exception |
Definition at line 152 of file AbstractOptimizer.h.
|
inline |
Definition at line 85 of file AbstractOptimizer.h.
Referenced by shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::canSolveConstrained(), shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::requiresClosestFeasible(), shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::requiresFirstDerivative(), shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::requiresSecondDerivative(), and shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::requiresValue().
|
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).
[in] | function | The 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().
|
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!
[in] | function | The objective function to initialize for. |
[in] | initPoints | points 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 >.
|
pure virtual |
Returns the number of points this method requires for initialisation.
The number of points supplied is allowed to be smaller, however in this case the optimizer will resort to techniques generating additional points if needed.
Implemented in shark::RVEA, shark::IndicatorBasedRealCodedNSGAII< Indicator >, shark::IndicatorBasedRealCodedNSGAII< NSGA3Indicator >, shark::MOEAD, shark::SMSEMOA, shark::IndicatorBasedMOCMA< Indicator >, shark::IndicatorBasedSteadyStateMOCMA< Indicator >, shark::AbstractSingleObjectiveOptimizer< PointType >, and shark::AbstractSingleObjectiveOptimizer< RealVector >.
Referenced by shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::init(), and shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::~AbstractOptimizer().
|
inline |
Definition at line 100 of file AbstractOptimizer.h.
Referenced by shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::checkFeatures().
|
inline |
Definition at line 91 of file AbstractOptimizer.h.
Referenced by shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::checkFeatures().
|
inline |
Definition at line 94 of file AbstractOptimizer.h.
Referenced by shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::checkFeatures().
|
inline |
Definition at line 87 of file AbstractOptimizer.h.
Referenced by shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::checkFeatures().
|
pure virtual |
Accesses the best solution obtained so far.
Implemented in shark::AbstractSingleObjectiveOptimizer< PointType >, shark::AbstractSingleObjectiveOptimizer< RealVector >, shark::AbstractMultiObjectiveOptimizer< PointTypeT >, and shark::AbstractMultiObjectiveOptimizer< RealVector >.
Referenced by shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::init().
|
pure virtual |
Carry out one step of the optimizer for the supplied objective function.
[in] | function | The objective function to initialize for. |
Implemented in shark::PointSearch, shark::IRpropMinus, shark::NestedGridSearch, shark::IRpropPlusFull, shark::IRpropPlus, shark::LMCMA, shark::GridSearch, shark::RpropPlus, shark::RVEA, shark::IndicatorBasedRealCodedNSGAII< Indicator >, shark::IndicatorBasedRealCodedNSGAII< NSGA3Indicator >, shark::SMSEMOA, shark::CrossEntropyMethod, shark::IndicatorBasedSteadyStateMOCMA< Indicator >, shark::IndicatorBasedMOCMA< Indicator >, shark::VDCMA, shark::MOEAD, shark::Adam, shark::RpropMinus, shark::CMSA, shark::SimplexDownhill, shark::CMA, shark::TrustRegionNewton, shark::SteepestDescent, shark::ElitistCMA, and shark::AbstractLineSearchOptimizer.
Referenced by shark::AbstractOptimizer< RealVector, RealVector, std::vector< ResultSet< RealVector, RealVector > > >::init(), and shark::OptimizationTrainer< Model, LabelTypeT >::train().
|
inlinevirtual |
Definition at line 85 of file AbstractOptimizer.h.
|
protected |
Definition at line 85 of file AbstractOptimizer.h.