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

Implementation of the Rastrigin function. More...

#include <RastriginFunction.h>

Inheritance diagram for galib::benchmark::RastriginFunction< GeneType >:
[legend]

Public Member Functions

 RastriginFunction (std::size_t dimensions, GeneType lower_bound, GeneType upper_bound)
 Constructs the Rastrigin function with given dimensions and bounds.
 
double evaluate (const std::vector< GeneType > &genotype) const override
 Evaluates the N-dimensional Rastrigin function.
 
std::size_t size () const override
 Returns the dimensionality of the optimization problem.
 
std::string name () const override
 Short identifier used to select a GPU evaluation kernel.
 
GeneType getLowerBound (std::size_t) const override
 Gets the lower bound for a specific dimension.
 
GeneType getUpperBound (std::size_t) const override
 Gets the upper bound for a specific dimension.
 
- Public Member Functions inherited from galib::FitnessFunction< GeneType >
virtual ~FitnessFunction ()=default
 
GeneType getLowerBound () const
 Convenience method to get the lower bound of the first dimension.
 
GeneType getUpperBound () const
 Convenience method to get the upper bound of the first dimension.
 

Detailed Description

template<typename GeneType = double>
class galib::benchmark::RastriginFunction< GeneType >

Implementation of the Rastrigin function.

A highly multi-modal function with many local minima. Global minimum: f(0, ..., 0) = 0.

Template Parameters
GeneTypeThe numeric type of the genes.

Definition at line 33 of file RastriginFunction.h.

Constructor & Destructor Documentation

◆ RastriginFunction()

template<typename GeneType = double>
galib::benchmark::RastriginFunction< GeneType >::RastriginFunction ( std::size_t  dimensions,
GeneType  lower_bound,
GeneType  upper_bound 
)
inlineexplicit

Constructs the Rastrigin function with given dimensions and bounds.

Parameters
dimensionsProblem dimensionality.
lower_boundUniform lower bound.
upper_boundUniform upper bound.

Definition at line 47 of file RastriginFunction.h.

Member Function Documentation

◆ evaluate()

template<typename GeneType = double>
double galib::benchmark::RastriginFunction< GeneType >::evaluate ( const std::vector< GeneType > &  genotype) const
inlineoverridevirtual

Evaluates the N-dimensional Rastrigin function.

Parameters
genotypeInput vector.
Returns
Fitness value.

Implements galib::FitnessFunction< GeneType >.

Definition at line 55 of file RastriginFunction.h.

◆ getLowerBound()

template<typename GeneType = double>
GeneType galib::benchmark::RastriginFunction< GeneType >::getLowerBound ( std::size_t  dimension) const
inlineoverridevirtual

Gets the lower bound for a specific dimension.

Parameters
dimensionIndex of the dimension.
Returns
Lower bound value.

Implements galib::FitnessFunction< GeneType >.

Definition at line 69 of file RastriginFunction.h.

◆ getUpperBound()

template<typename GeneType = double>
GeneType galib::benchmark::RastriginFunction< GeneType >::getUpperBound ( std::size_t  dimension) const
inlineoverridevirtual

Gets the upper bound for a specific dimension.

Parameters
dimensionIndex of the dimension.
Returns
Upper bound value.

Implements galib::FitnessFunction< GeneType >.

Definition at line 73 of file RastriginFunction.h.

◆ name()

template<typename GeneType = double>
std::string galib::benchmark::RastriginFunction< GeneType >::name ( ) const
inlineoverridevirtual

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 from galib::FitnessFunction< GeneType >.

Definition at line 67 of file RastriginFunction.h.

◆ size()

template<typename GeneType = double>
std::size_t galib::benchmark::RastriginFunction< GeneType >::size ( ) const
inlineoverridevirtual

Returns the dimensionality of the optimization problem.

Returns
Number of dimensions.

Implements galib::FitnessFunction< GeneType >.

Definition at line 66 of file RastriginFunction.h.


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