Candidates & Populations#
-
namespace gapp
class FitnessVector#
#include <population/candidate.hpp>
class FitnessMatrix#
#include <population/candidate.hpp>
class CVVector#
#include <population/candidate.hpp>
-
using gapp::CVVector = small_vector<double, 2>#
The class used to represent the constraint violations of a candidate. It contains the degree of constraint violation for each constraint separately. Higher values mean greater degrees of constraint violation, while 0 or lower values mean no constraint violation for a given constraint.
The size of a constraint violation vector is equal to the number of constraints.
class Chromosome#
#include <population/candidate.hpp>
class Candidate#
#include <population/candidate.hpp>
-
struct CandidateInfo#
The base class used for the representation of candidate solutions in all of the GAs. This class contains the parts of the candidates that are independent of the encoding type. The derived Candidate class contains the encoding dependent parts in addition to these.
- Template Parameters:
T – The gene type used in the candidate’s chromosome.
Subclassed by gapp::Candidate< RealGene >, gapp::Candidate< IntegerGene >, gapp::Candidate< PermutationGene >, gapp::Candidate< BinaryGene >, gapp::Candidate< T >
Public Functions
-
inline size_t num_objectives() const noexcept#
- Returns:
The number of objectives associated with the candidate. The return value will be 0 if called before the candidate has been evaluated. Equivalent to calling fitness.size().
-
inline bool is_evaluated() const noexcept#
- Returns:
True if the candidate has a valid fitness vector associated with it. Equivalent to calling !fitness.empty().
-
inline size_t num_constraints() const noexcept#
- Returns:
The number of constraints associated with the candidate. The return value will be 0 if called before the constraints have been evaluated. Equivalent to calling constraint_violation.size().
-
inline bool has_constraint_violation() const noexcept#
- Returns:
True if the candidate violates any of its constraints. If there are no constraints associated with the candidate, it will also return false. Returns false if called before the constraints have been evaluated.
Public Members
-
FitnessVector fitness#
The solution’s fitness value for each objective.
-
std::any attributes#
Arbitrary data associated with the candidate.
-
template<typename T>
struct Candidate : public gapp::CandidateInfo, public gapp::detail::container_interface<Candidate<T>># The class that is used to represent candidate solutions in all of the algorithms.
Contains several helper methods to access the chromosome directly, such as iterator methods. The behaviour of all these helper functions is equivalent to calling the matching functions on the chromosome member.
- Template Parameters:
T – The gene type used in the candidate’s chromosome.
Public Functions
-
inline explicit Candidate(size_t chrom_len)#
Create a candidate with an empty fitness vector and specific chromosome size. The genes of the chromosome will be default constructed.
- Parameters:
chrom_len – The length of the chromosome.
-
inline Candidate(size_t chrom_len, Gene gene)#
Create a candidate with an empty fitness vector and specific chromosome size. The genes of the chromosome will be equal to
gene
.- Parameters:
chrom_len – The length of the chromosome.
gene – The value of the genes in the chromosome.
-
inline explicit Candidate(const Chromosome<T> &chrom)#
Create a candidate with an empty fitness vector and a given chromosome.
- Parameters:
chrom – The chromosome of the candidate.
-
inline explicit Candidate(Chromosome<T> &&chrom) noexcept#
Create a candidate with an empty fitness vector and a given chromosome.
- Parameters:
chrom – The chromosome of the candidate.
-
inline Candidate(std::initializer_list<T> chrom)#
Create a candidate with an empty fitness vector from a list of genes.
- Parameters:
chrom – A list of genes for the chromosome.
-
inline auto begin() noexcept#
- Returns:
An iterator to the beginning of the candidate’s chromosome.
-
inline auto end() noexcept#
- Returns:
An iterator to the end of the candidate’s chromosome.
-
inline size_t chrom_len() const noexcept#
- Returns:
The length of the chromosome. Equivalent to calling chromosome.size().
Public Members
-
Chromosome<T> chromosome#
The chromosome encoding the solution.
-
template<typename T>
struct CandidatePair# A pair of candidates.
class Candidates#
#include <population/population.hpp>
class CandidatePtrVec#
#include <population/population.hpp>
-
using gapp::CandidatePtrVec = std::vector<const CandidateInfo*>#
A vector of pointers to candidates.
class Population#
#include <population/population.hpp>
class PopulationView#
#include <population/population.hpp>
-
using gapp::PopulationView = detail::base_view<const CandidateInfo>#
A view of a population without the encoding specific parts (i.e. without the chromosomes).
class Bounds#
#include <population/candidate.hpp>
-
template<typename T>
class Bounds# The class used to represent the lower and upper bounds of a gene.
- Template Parameters:
T – The gene type. The lower and upper bounds will also be this type.