Super class of all objective functions for optimization and learning. More...
#include <shark/ObjectiveFunctions/AbstractObjectiveFunction.h>
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< Feature > | Features |
This statement declares the member m_features. See Core/Flags.h for details. | |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Public Member Functions | |
const Features & | features () 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 |
Super class of all objective functions for optimization and 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))
PointType | The search space the function is defined upon. |
ResultT | The objective space the function is defined upon. |
Definition at line 92 of file AbstractObjectiveFunction.h.
typedef TypedFeatureNotAvailableException<Feature> shark::AbstractObjectiveFunction< PointType, ResultT >::FeatureNotAvailableException |
Definition at line 123 of file AbstractObjectiveFunction.h.
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.
typedef boost::mpl::if_<std::is_arithmetic<ResultT>,SearchPointType,RealMatrix>::type shark::AbstractObjectiveFunction< PointType, ResultT >::FirstOrderDerivative |
Definition at line 102 of file AbstractObjectiveFunction.h.
typedef ResultT shark::AbstractObjectiveFunction< PointType, ResultT >::ResultType |
Definition at line 95 of file AbstractObjectiveFunction.h.
typedef PointType shark::AbstractObjectiveFunction< PointType, ResultT >::SearchPointType |
Definition at line 94 of file AbstractObjectiveFunction.h.
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.
|
inline |
Default ctor.
Definition at line 171 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::HAS_VALUE, and shark::AbstractObjectiveFunction< PointType, ResultT >::m_features.
|
inlinevirtual |
Virtual destructor.
Definition at line 175 of file AbstractObjectiveFunction.h.
|
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().
|
inline |
returns whether this function can propose a starting point.
Definition at line 141 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::CAN_PROPOSE_STARTING_POINT, and shark::AbstractObjectiveFunction< PointType, ResultT >::m_features.
Referenced by shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::init(), and shark::benchmarks::RotatedObjectiveFunction::RotatedObjectiveFunction().
|
inline |
Returns whether this function can calculate thee closest feasible to an infeasible point.
Definition at line 156 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::CAN_PROVIDE_CLOSEST_FEASIBLE, and shark::AbstractObjectiveFunction< PointType, ResultT >::m_features.
Referenced by shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::checkFeatures().
|
inlinevirtual |
If supported, the supplied point is repaired such that it satisfies all of the function's constraints.
[in,out] | input | The point to be repaired. |
FeatureNotAvailableException | in the default implementation. |
Reimplemented in shark::EvaluationArchive< PointType, ResultT >.
Definition at line 248 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::CAN_PROVIDE_CLOSEST_FEASIBLE, shark::AbstractObjectiveFunction< PointType, ResultT >::getConstraintHandler(), shark::AbstractObjectiveFunction< PointType, ResultT >::hasConstraintHandler(), shark::AbstractObjectiveFunction< PointType, ResultT >::isConstrained(), and SHARK_FEATURE_EXCEPTION.
Referenced by shark::EvaluationArchive< PointType, ResultT >::closestFeasible().
|
inlinevirtual |
Evaluates the objective function for the supplied argument.
[in] | input | The argument for which the function shall be evaluated. |
FeatureNotAvailableException | in 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().
|
inlinevirtual |
Evaluates the objective function and calculates its gradient.
[in] | input | The argument to eval the function for. |
[out] | derivative | The derivate is placed here. |
FeatureNotAvailableException | in 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().
|
inlinevirtual |
Evaluates the objective function and calculates its gradient.
[in] | input | The argument to eval the function for. |
[out] | derivative | The derivate and the Hessian are placed here. |
FeatureNotAvailableException | in 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.
|
inline |
Accesses the evaluation counter of the function.
Definition at line 222 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::m_evaluationCounter.
|
inline |
Definition at line 123 of file AbstractObjectiveFunction.h.
Referenced by shark::CombinedObjectiveFunction< SearchPointType, ResultT >::add(), shark::ErrorFunction< SearchPointType >::ErrorFunction(), shark::ErrorFunction< SearchPointType >::ErrorFunction(), shark::ErrorFunction< SearchPointType >::ErrorFunction(), and shark::EvaluationArchive< PointType, ResultT >::EvaluationArchive().
|
inline |
Returns the constraint handler of the function if it has one.
If the function does not offer a constraint handler, an exception is thrown.
Definition at line 229 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::m_constraintHandler, and SHARK_RUNTIME_CHECK.
Referenced by shark::AbstractObjectiveFunction< PointType, ResultT >::closestFeasible(), shark::EvaluationArchive< PointType, ResultT >::EvaluationArchive(), shark::IndicatorBasedRealCodedNSGAII< Indicator >::init(), shark::SMSEMOA::init(), shark::AbstractObjectiveFunction< PointType, ResultT >::isFeasible(), and shark::AbstractObjectiveFunction< PointType, ResultT >::proposeStartingPoint().
|
inline |
returns whether this function can return
Definition at line 151 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::HAS_CONSTRAINT_HANDLER, and shark::AbstractObjectiveFunction< PointType, ResultT >::m_features.
Referenced by shark::AbstractObjectiveFunction< PointType, ResultT >::closestFeasible(), shark::EvaluationArchive< PointType, ResultT >::EvaluationArchive(), shark::IndicatorBasedRealCodedNSGAII< Indicator >::init(), shark::SMSEMOA::init(), shark::AbstractObjectiveFunction< PointType, ResultT >::isFeasible(), and shark::AbstractObjectiveFunction< PointType, ResultT >::proposeStartingPoint().
|
inline |
returns whether this function can calculate the first derivative
Definition at line 131 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::HAS_FIRST_DERIVATIVE, and shark::AbstractObjectiveFunction< PointType, ResultT >::m_features.
Referenced by shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::checkFeatures(), and shark::benchmarks::RotatedObjectiveFunction::RotatedObjectiveFunction().
|
inlinevirtual |
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::ELLI1, shark::benchmarks::ELLI2, 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 >, and shark::TwoNormRegularizer< SearchPointType >.
Definition at line 197 of file AbstractObjectiveFunction.h.
Referenced by shark::benchmarks::RotatedObjectiveFunction::hasScalableDimensionality().
|
inlinevirtual |
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 210 of file AbstractObjectiveFunction.h.
Referenced by shark::EvaluationArchive< PointType, ResultT >::hasScalableObjectives().
|
inline |
returns whether this function can calculate the second derivative
Definition at line 136 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::HAS_SECOND_DERIVATIVE, and shark::AbstractObjectiveFunction< PointType, ResultT >::m_features.
Referenced by shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::checkFeatures().
|
inline |
returns whether this function can calculate it's function value
Definition at line 126 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::HAS_VALUE, and shark::AbstractObjectiveFunction< PointType, ResultT >::m_features.
Referenced by shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::checkFeatures().
|
inlinevirtual |
Reimplemented in shark::benchmarks::CIGTAB1, shark::benchmarks::CIGTAB2, shark::benchmarks::ELLI1, shark::benchmarks::ELLI2, shark::benchmarks::IHR1, shark::benchmarks::IHR2, shark::benchmarks::IHR3, shark::benchmarks::IHR4, shark::benchmarks::IHR6, shark::benchmarks::MultiObjectiveBenchmark< Objectives >, shark::benchmarks::RotatedObjectiveFunction, shark::CombinedObjectiveFunction< SearchPointType, ResultT >, shark::ErrorFunction< SearchPointType >, and shark::EvaluationArchive< PointType, ResultT >.
Definition at line 177 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::m_evaluationCounter.
Referenced by shark::benchmarks::RotatedObjectiveFunction::init(), shark::EvaluationArchive< PointType, ResultT >::init(), main(), main(), run_one_trial(), and trainRBM().
|
inline |
returns whether this function can return
Definition at line 146 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::IS_CONSTRAINED_FEATURE, and shark::AbstractObjectiveFunction< PointType, ResultT >::m_features.
Referenced by shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >::checkFeatures(), shark::AbstractObjectiveFunction< PointType, ResultT >::closestFeasible(), shark::IndicatorBasedRealCodedNSGAII< Indicator >::init(), and shark::AbstractObjectiveFunction< PointType, ResultT >::isFeasible().
|
inlinevirtual |
Tests whether a point in SearchSpace is feasible, e.g., whether the constraints are fulfilled.
[in] | input | The point to be tested for feasibility. |
Reimplemented in shark::EvaluationArchive< PointType, ResultT >, shark::SvmLogisticInterpretation< InputType >, and shark::benchmarks::ConstrainedSphere.
Definition at line 237 of file AbstractObjectiveFunction.h.
References shark::AbstractObjectiveFunction< PointType, ResultT >::getConstraintHandler(), shark::AbstractObjectiveFunction< PointType, ResultT >::hasConstraintHandler(), shark::AbstractObjectiveFunction< PointType, ResultT >::isConstrained(), and SHARK_RUNTIME_CHECK.
Referenced by shark::IndicatorBasedMOCMA< Indicator >::init(), shark::IndicatorBasedRealCodedNSGAII< Indicator >::init(), shark::SMSEMOA::init(), shark::IndicatorBasedSteadyStateMOCMA< Indicator >::init(), and shark::EvaluationArchive< PointType, ResultT >::isFeasible().
|
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.
|
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.
|
inlinevirtual |
Reimplemented in 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::MultiObjectiveBenchmark< Objectives >, shark::benchmarks::ZDT1, shark::benchmarks::ZDT2, shark::benchmarks::ZDT3, shark::benchmarks::ZDT4, shark::benchmarks::ZDT6, and shark::EvaluationArchive< PointType, ResultT >.
Definition at line 207 of file AbstractObjectiveFunction.h.
Referenced by shark::EvaluationArchive< PointType, ResultT >::numberOfObjectives().
|
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().
|
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().
|
inlinevirtual |
Proposes a starting point in the feasible search space of the function.
FeatureNotAvailableException | in 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().
|
inlinevirtual |
Adjusts the number of objectives if the function is scalable.
numberOfObjectives | The 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().
|
inlinevirtual |
Adjusts the number of variables if the function is scalable.
[in] | numberOfVariables | The 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().
|
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().
|
inlinevirtual |
Definition at line 123 of file AbstractObjectiveFunction.h.
|
protected |
Definition at line 306 of file AbstractObjectiveFunction.h.
Referenced by shark::AbstractObjectiveFunction< PointType, ResultT >::announceConstraintHandler(), shark::EvaluationArchive< PointType, ResultT >::EvaluationArchive(), and shark::AbstractObjectiveFunction< PointType, ResultT >::getConstraintHandler().
|
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().
|
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().
|
protected |
Definition at line 307 of file AbstractObjectiveFunction.h.
Referenced by shark::benchmarks::CIGTAB1::init(), shark::benchmarks::CIGTAB2::init(), shark::benchmarks::ELLI1::init(), shark::benchmarks::ELLI2::init(), shark::benchmarks::IHR1::init(), shark::benchmarks::IHR2::init(), shark::benchmarks::IHR3::init(), shark::benchmarks::IHR4::init(), shark::benchmarks::IHR6::init(), shark::benchmarks::MultiObjectiveBenchmark< Objectives >::init(), shark::ErrorFunction< SearchPointType >::init(), shark::EvaluationArchive< PointType, ResultT >::init(), shark::AbstractObjectiveFunction< PointType, ResultT >::proposeStartingPoint(), shark::benchmarks::CIGTAB1::proposeStartingPoint(), shark::benchmarks::CIGTAB2::proposeStartingPoint(), shark::benchmarks::ELLI1::proposeStartingPoint(), shark::benchmarks::ELLI2::proposeStartingPoint(), shark::benchmarks::MultiObjectiveBenchmark< Objectives >::proposeStartingPoint(), and shark::AbstractObjectiveFunction< PointType, ResultT >::setRng().