GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
Loading...
Searching...
No Matches
FitnessFunction.h
Go to the documentation of this file.
1#ifndef FITNESS_FUNCTION_H
2#define FITNESS_FUNCTION_H
3
4#pragma once
5
6#include <string>
7#include <vector>
8#include <cstddef>
9
10namespace galib {
11
20 template <typename GeneType = double>
22 public:
23 virtual ~FitnessFunction() = default;
24
33 virtual double evaluate(const std::vector<GeneType>& phenotype) const = 0;
34
39 [[nodiscard]] virtual std::size_t size() const = 0;
40
50 [[nodiscard]] virtual std::string name() const { return ""; }
51
57 virtual GeneType getLowerBound(std::size_t dimension) const = 0;
58
63 GeneType getLowerBound() const {
64 return getLowerBound(0);
65 }
66
72 virtual GeneType getUpperBound(std::size_t dimension) const = 0;
73
78 GeneType getUpperBound() const {
79 return getUpperBound(0);
80 }
81 };
82}
83
84#endif // FITNESS_FUNCTION_H
Abstract base class for objective functions to be minimized.
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 std::string name() const
Short identifier used to select a GPU evaluation kernel.
GeneType getUpperBound() const
Convenience method to get the upper bound of the first dimension.
virtual ~FitnessFunction()=default
virtual GeneType getUpperBound(std::size_t dimension) const =0
Gets the upper bound for a specific dimension.
virtual std::size_t size() const =0
Returns the dimensionality of the optimization problem.
virtual double evaluate(const std::vector< GeneType > &phenotype) const =0
Evaluates the fitness of a candidate solution.