shark::CombinedObjectiveFunction< SearchSpaceType, ResultT > Class Template Reference

Linear combination of objective functions. More...

#include <shark/ObjectiveFunctions/CombinedObjectiveFunction.h>

+ Inheritance diagram for shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >:

Public Types

typedef AbstractObjectiveFunction< SearchSpaceType, ResultT > super
 
typedef AbstractObjectiveFunction< SearchSpaceType, ResultT > element
 
- Public Types inherited from shark::AbstractObjectiveFunction< SearchSpaceType, ResultT >
enum  Feature
 List of features that are supported by an implementation. More...
 
typedef SearchSpaceType 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. More...
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 

Public Member Functions

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

Protected Attributes

std::vector< double > m_weight
 list of weights More...
 
std::vector< element * > m_elements
 list of "base" objective functions More...
 
- Protected Attributes inherited from shark::AbstractObjectiveFunction< SearchSpaceType, ResultT >
Features m_features
 
std::size_t m_evaluationCounter
 Evaluation counter, default value: 0. More...
 
AbstractConstraintHandler< SearchPointType > const * m_constraintHandler
 
random::rng_type * mep_rng
 

Additional Inherited Members

- Protected Member Functions inherited from shark::AbstractObjectiveFunction< SearchSpaceType, ResultT >
void announceConstraintHandler (AbstractConstraintHandler< SearchPointType > const *handler)
 helper function which is called to announce the presence of an constraint handler. More...
 

Detailed Description

template<typename SearchSpaceType, typename ResultT>
class shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >

Linear combination of objective functions.

The CombinedObjectiveFunction is a linear combination of objective functions. It assumed that the result type is capable of forming linear combinations with real coefficients.

Definition at line 52 of file CombinedObjectiveFunction.h.

Member Typedef Documentation

◆ element

template<typename SearchSpaceType , typename ResultT >
typedef AbstractObjectiveFunction<SearchSpaceType, ResultT> shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >::element

Definition at line 57 of file CombinedObjectiveFunction.h.

◆ super

template<typename SearchSpaceType , typename ResultT >
typedef AbstractObjectiveFunction<SearchSpaceType, ResultT> shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >::super

Definition at line 56 of file CombinedObjectiveFunction.h.

Constructor & Destructor Documentation

◆ CombinedObjectiveFunction()

Member Function Documentation

◆ add() [1/2]

template<typename SearchSpaceType , typename ResultT >
void shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >::add ( element e)
inline

Adds a new objective function with a weight of one to the linear combination.

Definition at line 72 of file CombinedObjectiveFunction.h.

◆ add() [2/2]

◆ eval()

template<typename SearchSpaceType , typename ResultT >
super::ResultType shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >::eval ( const typename super::SearchPointType input) const
inline

◆ evalDerivative() [1/2]

◆ evalDerivative() [2/2]

template<typename SearchSpaceType , typename ResultT >
super::ResultType shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >::evalDerivative ( const typename super::SearchPointType input,
typename super::SecondOrderDerivative &  derivative 
) const
inline

◆ init()

template<typename SearchSpaceType , typename ResultT >
void shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >::init ( )
inlinevirtual

◆ isFeasible()

template<typename SearchSpaceType , typename ResultT >
bool shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >::isFeasible ( const typename super::SearchPointType input) const
inline

Tests whether a point in SearchSpace is feasible, e.g., whether the constraints are fulfilled.

Definition at line 92 of file CombinedObjectiveFunction.h.

References shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >::m_elements.

◆ name()

template<typename SearchSpaceType , typename ResultT >
std::string shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 66 of file CombinedObjectiveFunction.h.

◆ numberOfVariables()

template<typename SearchSpaceType , typename ResultT >
std::size_t shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >::numberOfVariables ( ) const
inlinevirtual

Member Data Documentation

◆ m_elements

◆ m_weight

template<typename SearchSpaceType , typename ResultT >
std::vector<double> shark::CombinedObjectiveFunction< SearchSpaceType, ResultT >::m_weight
protected

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