shark::AbstractObjectiveFunction< PointType, ResultT > Class Template Referenceabstract

Super class of all objective functions for optimization and learning. More...

#include <shark/ObjectiveFunctions/AbstractObjectiveFunction.h>

+ Inheritance diagram for shark::AbstractObjectiveFunction< PointType, ResultT >:

Classes

struct  SecondOrderDerivative
 

Public Types

enum  Feature {
  HAS_VALUE = 1 , HAS_FIRST_DERIVATIVE = 2 , HAS_SECOND_DERIVATIVE = 4 , CAN_PROPOSE_STARTING_POINT = 8 ,
  IS_CONSTRAINED_FEATURE = 16 , HAS_CONSTRAINT_HANDLER = 32 , CAN_PROVIDE_CLOSEST_FEASIBLE = 64 , IS_THREAD_SAFE = 128 ,
  IS_NOISY = 256
}
 List of features that are supported by an implementation. More...
 
typedef PointType SearchPointType
 
typedef ResultT ResultType
 
typedef boost::mpl::if_< std::is_arithmetic< ResultT >, SearchPointType, RealMatrix >::type FirstOrderDerivative
 
typedef TypedFlags< FeatureFeatures
 This statement declares the member m_features. See Core/Flags.h for details.
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 

Public Member Functions

const Featuresfeatures () const
 
virtual void updateFeatures ()
 
bool hasValue () const
 returns whether this function can calculate it's function value
 
bool hasFirstDerivative () const
 returns whether this function can calculate the first derivative
 
bool hasSecondDerivative () const
 returns whether this function can calculate the second derivative
 
bool canProposeStartingPoint () const
 returns whether this function can propose a starting point.
 
bool isConstrained () const
 returns whether this function can return
 
bool hasConstraintHandler () const
 returns whether this function can return
 
bool canProvideClosestFeasible () const
 Returns whether this function can calculate thee closest feasible to an infeasible point.
 
bool isThreadSafe () const
 Returns true, when the function can be usd in parallel threads.
 
bool isNoisy () const
 Returns true, when the function can be usd in parallel threads.
 
 AbstractObjectiveFunction ()
 Default ctor.
 
virtual ~AbstractObjectiveFunction ()
 Virtual destructor.
 
virtual void init ()
 
void setRng (random::rng_type *rng)
 Sets the Rng used by the objective function.
 
virtual std::size_t numberOfVariables () const =0
 Accesses the number of variables.
 
virtual bool hasScalableDimensionality () const
 
virtual void setNumberOfVariables (std::size_t numberOfVariables)
 Adjusts the number of variables if the function is scalable.
 
virtual std::size_t numberOfObjectives () const
 
virtual bool hasScalableObjectives () const
 
virtual void setNumberOfObjectives (std::size_t numberOfObjectives)
 Adjusts the number of objectives if the function is scalable.
 
std::size_t evaluationCounter () const
 Accesses the evaluation counter of the function.
 
AbstractConstraintHandler< SearchPointType > const & getConstraintHandler () const
 Returns the constraint handler of the function if it has one.
 
virtual bool isFeasible (const SearchPointType &input) const
 Tests whether a point in SearchSpace is feasible, e.g., whether the constraints are fulfilled.
 
virtual void closestFeasible (SearchPointType &input) const
 If supported, the supplied point is repaired such that it satisfies all of the function's constraints.
 
virtual SearchPointType proposeStartingPoint () const
 Proposes a starting point in the feasible search space of the function.
 
virtual ResultType eval (SearchPointType const &input) const
 Evaluates the objective function for the supplied argument.
 
ResultType operator() (SearchPointType const &input) const
 Evaluates the function. Useful together with STL-Algorithms like std::transform.
 
virtual ResultType evalDerivative (SearchPointType const &input, FirstOrderDerivative &derivative) const
 Evaluates the objective function and calculates its gradient.
 
virtual ResultType evalDerivative (SearchPointType const &input, SecondOrderDerivative &derivative) const
 Evaluates the objective function and calculates its gradient.
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
virtual std::string name () const
 returns the name of the object
 

Protected Member Functions

void announceConstraintHandler (AbstractConstraintHandler< SearchPointType > const *handler)
 helper function which is called to announce the presence of an constraint handler.
 

Protected Attributes

Features m_features
 
std::size_t m_evaluationCounter
 Evaluation counter, default value: 0.
 
AbstractConstraintHandler< SearchPointType > const * m_constraintHandler
 
random::rng_type * mep_rng
 

Detailed Description

template<typename PointType, typename ResultT>
class shark::AbstractObjectiveFunction< PointType, ResultT >

Super class of all objective functions for optimization and learning.

The AbstractObjectiveFunction template class is the most general interface for a function to be minimized by an optimizer. It subsumes many more specialized classes, ranging from classical test problems in evolutionary algorithms to data-dependent objective functions in supervised learning. This interface allows all general purpose optimization procedures to be used as model training algorithms in a learning task, with applications ranging from training of neural networks to direct policy search in reinforcement learning.

AbstractObjectiveFunction offers a rich interface to support different types of optimizers. Since not every objective function meets every requirement, a flag system exists which tells the optimizer which features are available. These are: HAS_VALUE: The function can be evaluated. If not set, evalDerivative returns a meaningless value (for example std::numeric_limits<double>::quiet_nan()); HAS_FIRST_DERIVATIVE: evalDerivative can be called for the FirstOrderDerivative. The Derivative is defined and as exact as possible; HAS_SECOND_DERIVATIVE: evalDerivative can be called for the second derivative. IS_CONSTRAINED_FEATURE: The function has constraints and isFeasible might return false; CAN_PROPOSE_STARTING_POINT: the function can return a possibly randomized starting point; CAN_PROVIDE_CLOSEST_FEASIBLE: if the function is constrained, closest feasible can be called to construct a feasible point.

In the single objective case, the shark convention is to return a double value, while in Multi objective optimization a RealVector is returned with an entry for every objective. Moreoever, derivatives in the single objective case are RealVectors, while they are RealMatrix in the multi-objective case (i.e. the jacobian of the function).

Calling the derivatives, proposeStartingPoint or closestFeasible when the flags are not set will throw an exception. The features can be queried using the method features() as in if(!(f.features()&Function::HAS_VALUE))

Template Parameters
PointTypeThe search space the function is defined upon.
ResultTThe objective space the function is defined upon.

Definition at line 92 of file AbstractObjectiveFunction.h.

Member Typedef Documentation

◆ FeatureNotAvailableException

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

Definition at line 123 of file AbstractObjectiveFunction.h.

◆ Features

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

This statement declares the member m_features. See Core/Flags.h for details.

Definition at line 123 of file AbstractObjectiveFunction.h.

◆ FirstOrderDerivative

template<typename PointType , typename ResultT >
typedef boost::mpl::if_<std::is_arithmetic<ResultT>,SearchPointType,RealMatrix>::type shark::AbstractObjectiveFunction< PointType, ResultT >::FirstOrderDerivative

Definition at line 102 of file AbstractObjectiveFunction.h.

◆ ResultType

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

Definition at line 95 of file AbstractObjectiveFunction.h.

◆ SearchPointType

template<typename PointType , typename ResultT >
typedef PointType shark::AbstractObjectiveFunction< PointType, ResultT >::SearchPointType

Definition at line 94 of file AbstractObjectiveFunction.h.

Member Enumeration Documentation

◆ Feature

template<typename PointType , typename ResultT >
enum shark::AbstractObjectiveFunction::Feature

List of features that are supported by an implementation.

Enumerator
HAS_VALUE 

The function can be evaluated and evalDerivative returns a meaningless value (for example std::numeric_limits<double>::quiet_nan()).

HAS_FIRST_DERIVATIVE 

The method evalDerivative is implemented for the first derivative and returns a sensible value.

HAS_SECOND_DERIVATIVE 

The method evalDerivative is implemented for the second derivative and returns a sensible value.

CAN_PROPOSE_STARTING_POINT 

The function can propose a sensible starting point to search algorithms.

IS_CONSTRAINED_FEATURE 

The objective function is constrained.

HAS_CONSTRAINT_HANDLER 

The constraints are governed by a constraint handler which can be queried by getConstraintHandler()

CAN_PROVIDE_CLOSEST_FEASIBLE 

If the function is constrained, the method closestFeasible is implemented and returns a "repaired" solution.

IS_THREAD_SAFE 

can eval or evalDerivative be called in parallel?

IS_NOISY 

The function value is perturbed by some kind of noise.

Definition at line 110 of file AbstractObjectiveFunction.h.

Constructor & Destructor Documentation

◆ AbstractObjectiveFunction()

template<typename PointType , typename ResultT >
shark::AbstractObjectiveFunction< PointType, ResultT >::AbstractObjectiveFunction ( )
inline

◆ ~AbstractObjectiveFunction()

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

Virtual destructor.

Definition at line 175 of file AbstractObjectiveFunction.h.

Member Function Documentation

◆ announceConstraintHandler()

template<typename PointType , typename ResultT >
void shark::AbstractObjectiveFunction< PointType, ResultT >::announceConstraintHandler ( AbstractConstraintHandler< SearchPointType > const *  handler)
inlineprotected

helper function which is called to announce the presence of an constraint handler.

This function quries the propabilities of the handler and sts up the flags accordingly

Definition at line 312 of file AbstractObjectiveFunction.h.

References shark::AbstractObjectiveFunction< PointType, ResultT >::CAN_PROPOSE_STARTING_POINT, shark::AbstractObjectiveFunction< PointType, ResultT >::CAN_PROVIDE_CLOSEST_FEASIBLE, shark::AbstractConstraintHandler< SearchPointType >::canGenerateRandomPoint(), shark::AbstractConstraintHandler< SearchPointType >::canProvideClosestFeasible(), shark::AbstractObjectiveFunction< PointType, ResultT >::HAS_CONSTRAINT_HANDLER, shark::AbstractObjectiveFunction< PointType, ResultT >::IS_CONSTRAINED_FEATURE, shark::AbstractObjectiveFunction< PointType, ResultT >::m_constraintHandler, shark::AbstractObjectiveFunction< PointType, ResultT >::m_features, and SHARK_RUNTIME_CHECK.

Referenced by shark::benchmarks::DTLZ1::DTLZ1(), shark::benchmarks::DTLZ2::DTLZ2(), shark::benchmarks::DTLZ3::DTLZ3(), shark::benchmarks::DTLZ4::DTLZ4(), shark::benchmarks::DTLZ5::DTLZ5(), shark::benchmarks::DTLZ6::DTLZ6(), shark::benchmarks::DTLZ7::DTLZ7(), shark::benchmarks::Fonseca::Fonseca(), shark::benchmarks::GSP::GSP(), shark::benchmarks::IHR1::IHR1(), shark::benchmarks::IHR2::IHR2(), shark::benchmarks::IHR3::IHR3(), shark::benchmarks::IHR4::IHR4(), shark::benchmarks::IHR6::IHR6(), shark::benchmarks::LZ1::LZ1(), shark::benchmarks::LZ2::LZ2(), shark::benchmarks::LZ3::LZ3(), shark::benchmarks::LZ4::LZ4(), shark::benchmarks::LZ5::LZ5(), shark::benchmarks::LZ6::LZ6(), shark::benchmarks::LZ7::LZ7(), shark::benchmarks::LZ8::LZ8(), shark::benchmarks::LZ9::LZ9(), shark::benchmarks::ZDT1::ZDT1(), shark::benchmarks::ZDT2::ZDT2(), shark::benchmarks::ZDT3::ZDT3(), shark::benchmarks::ZDT4::ZDT4(), and shark::benchmarks::ZDT6::ZDT6().

◆ canProposeStartingPoint()

template<typename PointType , typename ResultT >
bool shark::AbstractObjectiveFunction< PointType, ResultT >::canProposeStartingPoint ( ) const
inline

◆ canProvideClosestFeasible()

template<typename PointType , typename ResultT >
bool shark::AbstractObjectiveFunction< PointType, ResultT >::canProvideClosestFeasible ( ) const
inline

◆ closestFeasible()

template<typename PointType , typename ResultT >
virtual void shark::AbstractObjectiveFunction< PointType, ResultT >::closestFeasible ( SearchPointType input) const
inlinevirtual

◆ eval()

template<typename PointType , typename ResultT >
virtual ResultType shark::AbstractObjectiveFunction< PointType, ResultT >::eval ( SearchPointType const &  input) const
inlinevirtual

Evaluates the objective function for the supplied argument.

Parameters
[in]inputThe argument for which the function shall be evaluated.
Returns
The result of evaluating the function for the supplied argument.
Exceptions
FeatureNotAvailableExceptionin the default implementation and if a function does not support this feature.

Reimplemented in shark::LooError< ModelTypeT, LabelType >, shark::NegativeGaussianProcessEvidence< InputType, OutputType, LabelType >, shark::benchmarks::MarkovPole< HiddenNeuron, OutputNeuron >, shark::benchmarks::NonMarkovPole, shark::EvaluationArchive< PointType, ResultT >, shark::benchmarks::Ackley, shark::benchmarks::Cigar, shark::benchmarks::CigarDiscus, shark::benchmarks::ConstrainedSphere, shark::benchmarks::DiffPowers, shark::benchmarks::Ellipsoid, shark::benchmarks::Himmelblau, shark::benchmarks::Rosenbrock, shark::benchmarks::Schwefel, shark::benchmarks::CIGTAB1, shark::benchmarks::CIGTAB2, shark::benchmarks::DTLZ1, shark::benchmarks::DTLZ2, shark::benchmarks::DTLZ3, shark::benchmarks::DTLZ4, shark::benchmarks::DTLZ5, shark::benchmarks::DTLZ6, shark::benchmarks::DTLZ7, shark::benchmarks::ELLI1, shark::benchmarks::ELLI2, shark::benchmarks::Fonseca, shark::benchmarks::GSP, shark::benchmarks::IHR1, shark::benchmarks::IHR2, shark::benchmarks::IHR3, shark::benchmarks::IHR4, shark::benchmarks::IHR6, shark::benchmarks::LZ1, shark::benchmarks::LZ2, shark::benchmarks::LZ3, shark::benchmarks::LZ4, shark::benchmarks::LZ5, shark::benchmarks::LZ6, shark::benchmarks::LZ7, shark::benchmarks::LZ8, shark::benchmarks::LZ9, shark::benchmarks::ZDT1, shark::benchmarks::ZDT2, shark::benchmarks::ZDT3, shark::benchmarks::ZDT4, shark::benchmarks::ZDT6, shark::KernelTargetAlignment< InputType, LabelType >, shark::NegativeLogLikelihood, shark::CrossValidationError< ModelTypeT, LabelTypeT >, shark::MergeBudgetMaintenanceStrategy< RealVector >::MergingProblemFunction, shark::ErrorFunction< SearchPointType >, shark::OneNormRegularizer< SearchPointType >, shark::TwoNormRegularizer< SearchPointType >, shark::benchmarks::Discus, shark::benchmarks::RotatedObjectiveFunction, shark::ExactGradient< RBMType >, shark::RadiusMarginQuotient< InputType, CacheType >, shark::SvmLogisticInterpretation< InputType >, shark::VariationalAutoencoderError< SearchPointType >, shark::benchmarks::MultiObjectiveBenchmark< Objectives >, and shark::benchmarks::Sphere.

Definition at line 275 of file AbstractObjectiveFunction.h.

References shark::AbstractObjectiveFunction< PointType, ResultT >::HAS_VALUE, and SHARK_FEATURE_EXCEPTION.

Referenced by shark::EvaluationArchive< PointType, ResultT >::eval(), shark::ErrorFunction< SearchPointType >::eval(), shark::benchmarks::RotatedObjectiveFunction::eval(), shark::ExactGradient< RBMType >::eval(), shark::IndicatorBasedMOCMA< Indicator >::init(), shark::IndicatorBasedRealCodedNSGAII< Indicator >::init(), shark::SMSEMOA::init(), shark::IndicatorBasedSteadyStateMOCMA< Indicator >::init(), shark::AbstractObjectiveFunction< PointType, ResultT >::operator()(), shark::ValidatedStoppingCriterion::stop(), and shark::TwoPointStepSizeAdaptation::update().

◆ evalDerivative() [1/2]

template<typename PointType , typename ResultT >
virtual ResultType shark::AbstractObjectiveFunction< PointType, ResultT >::evalDerivative ( SearchPointType const &  input,
FirstOrderDerivative derivative 
) const
inlinevirtual

Evaluates the objective function and calculates its gradient.

Parameters
[in]inputThe argument to eval the function for.
[out]derivativeThe derivate is placed here.
Returns
The result of evaluating the function for the supplied argument.
Exceptions
FeatureNotAvailableExceptionin the default implementation and if a function does not support this feature.

Reimplemented in shark::NegativeGaussianProcessEvidence< InputType, OutputType, LabelType >, shark::MergeBudgetMaintenanceStrategy< RealVector >::MergingProblemFunction, shark::EvaluationArchive< PointType, ResultT >, shark::KernelTargetAlignment< InputType, LabelType >, shark::benchmarks::Ellipsoid, shark::benchmarks::Rosenbrock, shark::NegativeLogLikelihood, shark::benchmarks::Cigar, shark::benchmarks::Discus, shark::benchmarks::RotatedObjectiveFunction, shark::ContrastiveDivergence< Operator >, shark::ExactGradient< RBMType >, shark::MultiChainApproximator< MarkovChainType >, shark::SingleChainApproximator< MarkovChainType >, shark::RadiusMarginQuotient< InputType, CacheType >, shark::SvmLogisticInterpretation< InputType >, shark::benchmarks::MultiObjectiveBenchmark< Objectives >, and shark::benchmarks::Sphere.

Definition at line 290 of file AbstractObjectiveFunction.h.

References shark::AbstractObjectiveFunction< PointType, ResultT >::HAS_FIRST_DERIVATIVE, and SHARK_FEATURE_EXCEPTION.

Referenced by shark::EvaluationArchive< PointType, ResultT >::evalDerivative(), shark::EvaluationArchive< PointType, ResultT >::evalDerivative(), shark::ErrorFunction< SearchPointType >::evalDerivative(), shark::benchmarks::RotatedObjectiveFunction::evalDerivative(), shark::ContrastiveDivergence< Operator >::evalDerivative(), shark::ExactGradient< RBMType >::evalDerivative(), shark::MultiChainApproximator< MarkovChainType >::evalDerivative(), shark::SingleChainApproximator< MarkovChainType >::evalDerivative(), shark::Adam< SearchPointType >::init(), shark::SteepestDescent< SearchPointType >::init(), shark::Adam< SearchPointType >::step(), and shark::SteepestDescent< SearchPointType >::step().

◆ evalDerivative() [2/2]

template<typename PointType , typename ResultT >
virtual ResultType shark::AbstractObjectiveFunction< PointType, ResultT >::evalDerivative ( SearchPointType const &  input,
SecondOrderDerivative derivative 
) const
inlinevirtual

Evaluates the objective function and calculates its gradient.

Parameters
[in]inputThe argument to eval the function for.
[out]derivativeThe derivate and the Hessian are placed here.
Returns
The result of evaluating the function for the supplied argument.
Exceptions
FeatureNotAvailableExceptionin the default implementation and if a function does not support this feature.

Reimplemented in shark::EvaluationArchive< PointType, ResultT >, shark::benchmarks::Ellipsoid, and shark::benchmarks::Rosenbrock.

Definition at line 300 of file AbstractObjectiveFunction.h.

References shark::AbstractObjectiveFunction< PointType, ResultT >::HAS_SECOND_DERIVATIVE, and SHARK_FEATURE_EXCEPTION.

◆ evaluationCounter()

template<typename PointType , typename ResultT >
std::size_t shark::AbstractObjectiveFunction< PointType, ResultT >::evaluationCounter ( ) const
inline

Accesses the evaluation counter of the function.

Definition at line 222 of file AbstractObjectiveFunction.h.

References shark::AbstractObjectiveFunction< PointType, ResultT >::m_evaluationCounter.

Referenced by main(), and main().

◆ features()

◆ getConstraintHandler()

◆ hasConstraintHandler()

◆ hasFirstDerivative()

template<typename PointType , typename ResultT >
bool shark::AbstractObjectiveFunction< PointType, ResultT >::hasFirstDerivative ( ) const
inline

◆ hasScalableDimensionality()

template<typename PointType , typename ResultT >
virtual bool shark::AbstractObjectiveFunction< PointType, ResultT >::hasScalableDimensionality ( ) const
inlinevirtual

◆ hasScalableObjectives()

◆ hasSecondDerivative()

template<typename PointType , typename ResultT >
bool shark::AbstractObjectiveFunction< PointType, ResultT >::hasSecondDerivative ( ) const
inline

◆ hasValue()

template<typename PointType , typename ResultT >
bool shark::AbstractObjectiveFunction< PointType, ResultT >::hasValue ( ) const
inline

◆ init()

◆ isConstrained()

◆ isFeasible()

◆ isNoisy()

template<typename PointType , typename ResultT >
bool shark::AbstractObjectiveFunction< PointType, ResultT >::isNoisy ( ) const
inline

Returns true, when the function can be usd in parallel threads.

Definition at line 166 of file AbstractObjectiveFunction.h.

References shark::AbstractObjectiveFunction< PointType, ResultT >::IS_NOISY, and shark::AbstractObjectiveFunction< PointType, ResultT >::m_features.

◆ isThreadSafe()

template<typename PointType , typename ResultT >
bool shark::AbstractObjectiveFunction< PointType, ResultT >::isThreadSafe ( ) const
inline

Returns true, when the function can be usd in parallel threads.

Definition at line 161 of file AbstractObjectiveFunction.h.

References shark::AbstractObjectiveFunction< PointType, ResultT >::IS_THREAD_SAFE, and shark::AbstractObjectiveFunction< PointType, ResultT >::m_features.

◆ numberOfObjectives()

◆ numberOfVariables()

template<typename PointType , typename ResultT >
virtual std::size_t shark::AbstractObjectiveFunction< PointType, ResultT >::numberOfVariables ( ) const
pure virtual

Accesses the number of variables.

Implemented in shark::MergeBudgetMaintenanceStrategy< RealVector >::MergingProblemFunction, shark::benchmarks::Ackley, shark::benchmarks::Cigar, shark::benchmarks::CigarDiscus, shark::benchmarks::CIGTAB1, shark::benchmarks::CIGTAB2, shark::benchmarks::ConstrainedSphere, shark::benchmarks::DiffPowers, shark::benchmarks::Discus, shark::benchmarks::DTLZ1, shark::benchmarks::DTLZ2, shark::benchmarks::DTLZ3, shark::benchmarks::DTLZ4, shark::benchmarks::DTLZ5, shark::benchmarks::DTLZ6, shark::benchmarks::DTLZ7, shark::benchmarks::ELLI1, shark::benchmarks::ELLI2, shark::benchmarks::Ellipsoid, shark::benchmarks::Fonseca, shark::benchmarks::GSP, shark::benchmarks::Himmelblau, shark::benchmarks::IHR1, shark::benchmarks::IHR2, shark::benchmarks::IHR3, shark::benchmarks::IHR4, shark::benchmarks::IHR6, shark::benchmarks::LZ1, shark::benchmarks::LZ2, shark::benchmarks::LZ3, shark::benchmarks::LZ4, shark::benchmarks::LZ5, shark::benchmarks::LZ6, shark::benchmarks::LZ7, shark::benchmarks::LZ8, shark::benchmarks::LZ9, shark::benchmarks::MarkovPole< HiddenNeuron, OutputNeuron >, shark::benchmarks::MultiObjectiveBenchmark< Objectives >, shark::benchmarks::NonMarkovPole, shark::benchmarks::Rosenbrock, shark::benchmarks::RotatedObjectiveFunction, shark::benchmarks::Schwefel, shark::benchmarks::Sphere, shark::benchmarks::ZDT1, shark::benchmarks::ZDT2, shark::benchmarks::ZDT3, shark::benchmarks::ZDT4, shark::benchmarks::ZDT6, shark::CombinedObjectiveFunction< SearchPointType, ResultT >, shark::CrossValidationError< ModelTypeT, LabelTypeT >, shark::ErrorFunction< SearchPointType >, shark::EvaluationArchive< PointType, ResultT >, shark::KernelTargetAlignment< InputType, LabelType >, shark::LooError< ModelTypeT, LabelType >, shark::LooErrorCSvm< InputType, CacheType >, shark::NegativeGaussianProcessEvidence< InputType, OutputType, LabelType >, shark::NegativeLogLikelihood, shark::RadiusMarginQuotient< InputType, CacheType >, shark::OneNormRegularizer< SearchPointType >, shark::TwoNormRegularizer< SearchPointType >, shark::SvmLogisticInterpretation< InputType >, shark::VariationalAutoencoderError< SearchPointType >, shark::ContrastiveDivergence< Operator >, shark::ExactGradient< RBMType >, shark::MultiChainApproximator< MarkovChainType >, and shark::SingleChainApproximator< MarkovChainType >.

Referenced by shark::IndicatorBasedRealCodedNSGAII< Indicator >::init(), shark::SMSEMOA::init(), shark::Adam< SearchPointType >::init(), shark::SteepestDescent< SearchPointType >::init(), shark::benchmarks::RotatedObjectiveFunction::numberOfVariables(), and shark::EvaluationArchive< PointType, ResultT >::numberOfVariables().

◆ operator()()

template<typename PointType , typename ResultT >
ResultType shark::AbstractObjectiveFunction< PointType, ResultT >::operator() ( SearchPointType const &  input) const
inline

Evaluates the function. Useful together with STL-Algorithms like std::transform.

Definition at line 280 of file AbstractObjectiveFunction.h.

References shark::AbstractObjectiveFunction< PointType, ResultT >::eval().

◆ proposeStartingPoint()

template<typename PointType , typename ResultT >
virtual SearchPointType shark::AbstractObjectiveFunction< PointType, ResultT >::proposeStartingPoint ( ) const
inlinevirtual

Proposes a starting point in the feasible search space of the function.

Returns
The generated starting point.
Exceptions
FeatureNotAvailableExceptionin the default implementation and if a function does not support this feature.

Reimplemented in shark::benchmarks::Ackley, shark::benchmarks::Cigar, shark::benchmarks::CigarDiscus, shark::benchmarks::CIGTAB1, shark::benchmarks::CIGTAB2, shark::benchmarks::ConstrainedSphere, shark::benchmarks::DiffPowers, shark::benchmarks::Discus, shark::benchmarks::ELLI1, shark::benchmarks::ELLI2, shark::benchmarks::Ellipsoid, shark::benchmarks::Himmelblau, shark::benchmarks::MarkovPole< HiddenNeuron, OutputNeuron >, shark::benchmarks::MultiObjectiveBenchmark< Objectives >, shark::benchmarks::NonMarkovPole, shark::benchmarks::Rosenbrock, shark::benchmarks::RotatedObjectiveFunction, shark::benchmarks::Schwefel, shark::benchmarks::Sphere, shark::ErrorFunction< SearchPointType >, shark::KernelTargetAlignment< InputType, LabelType >, shark::NegativeLogLikelihood, shark::VariationalAutoencoderError< SearchPointType >, shark::ContrastiveDivergence< Operator >, shark::ExactGradient< RBMType >, shark::MultiChainApproximator< MarkovChainType >, and shark::SingleChainApproximator< MarkovChainType >.

Definition at line 259 of file AbstractObjectiveFunction.h.

References shark::AbstractObjectiveFunction< PointType, ResultT >::CAN_PROPOSE_STARTING_POINT, shark::AbstractObjectiveFunction< PointType, ResultT >::getConstraintHandler(), shark::AbstractObjectiveFunction< PointType, ResultT >::hasConstraintHandler(), shark::AbstractObjectiveFunction< PointType, ResultT >::mep_rng, and SHARK_FEATURE_EXCEPTION.

Referenced by shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::init(), shark::benchmarks::RotatedObjectiveFunction::proposeStartingPoint(), and shark::EvaluationArchive< PointType, ResultT >::proposeStartingPoint().

◆ setNumberOfObjectives()

template<typename PointType , typename ResultT >
virtual void shark::AbstractObjectiveFunction< PointType, ResultT >::setNumberOfObjectives ( std::size_t  numberOfObjectives)
inlinevirtual

Adjusts the number of objectives if the function is scalable.

Parameters
numberOfObjectivesThe new number of objectives to optimize for.

Reimplemented in shark::benchmarks::DTLZ1, shark::benchmarks::DTLZ2, shark::benchmarks::DTLZ3, shark::benchmarks::DTLZ4, shark::benchmarks::DTLZ5, shark::benchmarks::DTLZ6, shark::benchmarks::DTLZ7, and shark::EvaluationArchive< PointType, ResultT >.

Definition at line 216 of file AbstractObjectiveFunction.h.

References SHARKEXCEPTION.

Referenced by shark::EvaluationArchive< PointType, ResultT >::setNumberOfObjectives().

◆ setNumberOfVariables()

template<typename PointType , typename ResultT >
virtual void shark::AbstractObjectiveFunction< PointType, ResultT >::setNumberOfVariables ( std::size_t  numberOfVariables)
inlinevirtual

Adjusts the number of variables if the function is scalable.

Parameters
[in]numberOfVariablesThe new dimension.

Reimplemented in shark::benchmarks::Ackley, shark::benchmarks::Cigar, shark::benchmarks::CigarDiscus, shark::benchmarks::CIGTAB1, shark::benchmarks::CIGTAB2, shark::benchmarks::ConstrainedSphere, shark::benchmarks::DiffPowers, shark::benchmarks::Discus, shark::benchmarks::DTLZ1, shark::benchmarks::DTLZ2, shark::benchmarks::DTLZ3, shark::benchmarks::DTLZ4, shark::benchmarks::DTLZ5, shark::benchmarks::DTLZ6, shark::benchmarks::DTLZ7, shark::benchmarks::Ellipsoid, shark::benchmarks::Fonseca, shark::benchmarks::GSP, shark::benchmarks::IHR1, shark::benchmarks::IHR2, shark::benchmarks::IHR3, shark::benchmarks::IHR4, shark::benchmarks::IHR6, shark::benchmarks::LZ1, shark::benchmarks::LZ2, shark::benchmarks::LZ3, shark::benchmarks::LZ4, shark::benchmarks::LZ5, shark::benchmarks::LZ6, shark::benchmarks::LZ7, shark::benchmarks::LZ8, shark::benchmarks::LZ9, shark::benchmarks::MultiObjectiveBenchmark< Objectives >, shark::benchmarks::Rosenbrock, shark::benchmarks::RotatedObjectiveFunction, shark::benchmarks::Schwefel, shark::benchmarks::Sphere, shark::benchmarks::ZDT1, shark::benchmarks::ZDT2, shark::benchmarks::ZDT3, shark::benchmarks::ZDT4, shark::benchmarks::ZDT6, shark::OneNormRegularizer< SearchPointType >, shark::TwoNormRegularizer< SearchPointType >, shark::benchmarks::ELLI1, and shark::benchmarks::ELLI2.

Definition at line 203 of file AbstractObjectiveFunction.h.

References SHARKEXCEPTION.

Referenced by shark::benchmarks::RotatedObjectiveFunction::setNumberOfVariables().

◆ setRng()

template<typename PointType , typename ResultT >
void shark::AbstractObjectiveFunction< PointType, ResultT >::setRng ( random::rng_type *  rng)
inline

Sets the Rng used by the objective function.

Objective functions need random numbers for different tasks, e.g. to provide a first starting point or for example mini batch learning where batches are chosen randomly. By default, shark::random::globalRng is used. In a multi-threaded environment this might not be safe as the Rng is not thread safe. In this case, every thread should use its own Rng.

Definition at line 190 of file AbstractObjectiveFunction.h.

References shark::AbstractObjectiveFunction< PointType, ResultT >::mep_rng.

Referenced by shark::benchmarks::RotatedObjectiveFunction::init(), and shark::EvaluationArchive< PointType, ResultT >::init().

◆ updateFeatures()

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

Definition at line 123 of file AbstractObjectiveFunction.h.

Member Data Documentation

◆ m_constraintHandler

◆ m_evaluationCounter

template<typename PointType , typename ResultT >
std::size_t shark::AbstractObjectiveFunction< PointType, ResultT >::m_evaluationCounter
mutableprotected

Evaluation counter, default value: 0.

Definition at line 305 of file AbstractObjectiveFunction.h.

Referenced by shark::EvaluationArchive< PointType, ResultT >::eval(), shark::benchmarks::CIGTAB1::eval(), shark::benchmarks::CIGTAB2::eval(), shark::benchmarks::DTLZ1::eval(), shark::benchmarks::DTLZ2::eval(), shark::benchmarks::DTLZ3::eval(), shark::benchmarks::DTLZ4::eval(), shark::benchmarks::DTLZ5::eval(), shark::benchmarks::DTLZ6::eval(), shark::benchmarks::DTLZ7::eval(), shark::benchmarks::ELLI1::eval(), shark::benchmarks::ELLI2::eval(), shark::benchmarks::Fonseca::eval(), shark::benchmarks::GSP::eval(), shark::benchmarks::IHR1::eval(), shark::benchmarks::IHR2::eval(), shark::benchmarks::IHR3::eval(), shark::benchmarks::IHR4::eval(), shark::benchmarks::IHR6::eval(), shark::benchmarks::LZ1::eval(), shark::benchmarks::LZ2::eval(), shark::benchmarks::LZ3::eval(), shark::benchmarks::LZ4::eval(), shark::benchmarks::LZ5::eval(), shark::benchmarks::LZ6::eval(), shark::benchmarks::LZ7::eval(), shark::benchmarks::LZ8::eval(), shark::benchmarks::LZ9::eval(), shark::benchmarks::ZDT1::eval(), shark::benchmarks::ZDT2::eval(), shark::benchmarks::ZDT3::eval(), shark::benchmarks::ZDT4::eval(), shark::benchmarks::ZDT6::eval(), shark::ErrorFunction< SearchPointType >::eval(), shark::benchmarks::MultiObjectiveBenchmark< Objectives >::eval(), shark::EvaluationArchive< PointType, ResultT >::evalDerivative(), shark::EvaluationArchive< PointType, ResultT >::evalDerivative(), shark::ErrorFunction< SearchPointType >::evalDerivative(), shark::AbstractObjectiveFunction< PointType, ResultT >::evaluationCounter(), and shark::AbstractObjectiveFunction< PointType, ResultT >::init().

◆ m_features

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

Definition at line 123 of file AbstractObjectiveFunction.h.

Referenced by shark::AbstractObjectiveFunction< PointType, ResultT >::AbstractObjectiveFunction(), shark::AbstractObjectiveFunction< PointType, ResultT >::announceConstraintHandler(), shark::AbstractObjectiveFunction< PointType, ResultT >::canProposeStartingPoint(), shark::AbstractObjectiveFunction< PointType, ResultT >::canProvideClosestFeasible(), shark::benchmarks::CIGTAB1::CIGTAB1(), shark::benchmarks::CIGTAB2::CIGTAB2(), shark::benchmarks::ELLI1::ELLI1(), shark::benchmarks::ELLI2::ELLI2(), shark::ErrorFunction< SearchPointType >::ErrorFunction(), shark::ErrorFunction< SearchPointType >::ErrorFunction(), shark::ErrorFunction< SearchPointType >::ErrorFunction(), shark::EvaluationArchive< PointType, ResultT >::EvaluationArchive(), shark::AbstractObjectiveFunction< PointType, ResultT >::hasConstraintHandler(), shark::AbstractObjectiveFunction< PointType, ResultT >::hasFirstDerivative(), shark::AbstractObjectiveFunction< PointType, ResultT >::hasSecondDerivative(), shark::AbstractObjectiveFunction< PointType, ResultT >::hasValue(), shark::AbstractObjectiveFunction< PointType, ResultT >::isConstrained(), shark::AbstractObjectiveFunction< PointType, ResultT >::isNoisy(), shark::AbstractObjectiveFunction< PointType, ResultT >::isThreadSafe(), shark::benchmarks::MultiObjectiveBenchmark< Objectives >::MultiObjectiveBenchmark(), shark::OneNormRegularizer< SearchPointType >::OneNormRegularizer(), shark::ErrorFunction< SearchPointType >::operator=(), and shark::TwoNormRegularizer< SearchPointType >::TwoNormRegularizer().

◆ mep_rng


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