GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
Loading...
Searching...
No Matches
Public Member Functions | List of all members
galib::FitnessFunction< GeneType > Class Template Referenceabstract

Abstract base class for objective functions to be minimized. More...

#include <FitnessFunction.h>

Inheritance diagram for galib::FitnessFunction< GeneType >:
[legend]

Public Member Functions

virtual ~FitnessFunction ()=default
 
virtual double evaluate (const std::vector< GeneType > &phenotype) const =0
 Evaluates the fitness of a candidate solution.
 
virtual std::size_t size () const =0
 Returns the dimensionality of the optimization problem.
 
virtual std::string name () const
 Short identifier used to select a GPU evaluation kernel.
 
virtual GeneType getLowerBound (std::size_t dimension) const =0
 Gets the lower bound for a specific dimension.
 
GeneType getLowerBound () const
 Convenience method to get the lower bound of the first dimension.
 
virtual GeneType getUpperBound (std::size_t dimension) const =0
 Gets the upper bound for a specific dimension.
 
GeneType getUpperBound () const
 Convenience method to get the upper bound of the first dimension.
 

Detailed Description

template<typename GeneType = double>
class galib::FitnessFunction< GeneType >

Abstract base class for objective functions to be minimized.

Users should inherit from this class to define their own optimization problems, or use FunctionalFitness to wrap a lambda.

Template Parameters
GeneTypeThe numeric type of the genes (default: double).

Definition at line 21 of file FitnessFunction.h.

Constructor & Destructor Documentation

◆ ~FitnessFunction()

template<typename GeneType = double>
virtual galib::FitnessFunction< GeneType >::~FitnessFunction ( )
virtualdefault

Member Function Documentation

◆ evaluate()

template<typename GeneType = double>
virtual double galib::FitnessFunction< GeneType >::evaluate ( const std::vector< GeneType > &  phenotype) const
pure virtual

Evaluates the fitness of a candidate solution.

Lower return values indicate better fitness (minimization convention).

Parameters
phenotypeGene values of the individual to evaluate.
Returns
Fitness score.

Implemented in galib::benchmark::RastriginFunction< GeneType >, galib::benchmark::DeJongF5Function< GeneType >, galib::benchmark::HeavyTrigFunction< GeneType >, galib::benchmark::HimmelblauFitness< GeneType >, galib::benchmark::SphereFunction< GeneType >, and galib::FunctionalFitness< GeneType >.

Referenced by galib::DifferentialEvolutionGA< GeneType >::run().

◆ getLowerBound() [1/2]

template<typename GeneType = double>
GeneType galib::FitnessFunction< GeneType >::getLowerBound ( ) const
inline

Convenience method to get the lower bound of the first dimension.

Returns
Lower bound of dimension 0.

Definition at line 63 of file FitnessFunction.h.

References galib::FitnessFunction< GeneType >::getLowerBound().

Referenced by galib::FitnessFunction< GeneType >::getLowerBound().

◆ getLowerBound() [2/2]

template<typename GeneType = double>
virtual GeneType galib::FitnessFunction< GeneType >::getLowerBound ( std::size_t  dimension) const
pure virtual

◆ getUpperBound() [1/2]

template<typename GeneType = double>
GeneType galib::FitnessFunction< GeneType >::getUpperBound ( ) const
inline

Convenience method to get the upper bound of the first dimension.

Returns
Upper bound of dimension 0.

Definition at line 78 of file FitnessFunction.h.

References galib::FitnessFunction< GeneType >::getUpperBound().

Referenced by galib::FitnessFunction< GeneType >::getUpperBound().

◆ getUpperBound() [2/2]

template<typename GeneType = double>
virtual GeneType galib::FitnessFunction< GeneType >::getUpperBound ( std::size_t  dimension) const
pure virtual

◆ name()

template<typename GeneType = double>
virtual std::string galib::FitnessFunction< GeneType >::name ( ) const
inlinevirtual

Short identifier used to select a GPU evaluation kernel.

Override in benchmark subclasses to enable GPU-side evaluation ("Sphere", "Rastrigin", "HeavyTrig"). Return empty string (default) to use the CPU callback path.

Returns
Problem name string, or "" for custom functions.

Reimplemented in galib::benchmark::HeavyTrigFunction< GeneType >, galib::benchmark::RastriginFunction< GeneType >, and galib::benchmark::SphereFunction< GeneType >.

Definition at line 50 of file FitnessFunction.h.

◆ size()

template<typename GeneType = double>
virtual std::size_t galib::FitnessFunction< GeneType >::size ( ) const
pure virtual

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