panga
Public Member Functions | List of all members
panga::Individual Class Reference

#include <Individual.h>

Inheritance diagram for panga::Individual:
Inheritance graph
[legend]
Collaboration diagram for panga::Individual:
Collaboration graph
[legend]

Public Member Functions

 Individual (const Genome &genome)
 
 Individual (const Genome &genome, const BitVector &chromosome)
 
 Individual (const Individual &rhs)=delete
 
 Individual (Individual &&rhs)=default
 
Individualoperator= (const Individual &rhs)
 
bool operator< (const Individual &rhs) const
 
double GetScore () const
 
void SetScore (double score)
 
double GetFitness () const
 
void SetFitness (double fitness)
 
- Public Member Functions inherited from panga::Chromosome
 Chromosome (const Genome &genome)
 
 Chromosome (const Chromosome &rhs)=delete
 
 Chromosome (Chromosome &&rhs)=default
 
Chromosomeoperator= (const Chromosome &rhs)=delete
 
const GenomeGetGenome () const
 
void Randomize (RandomWrapper *random)
 
template<typename IntegerType = uint64_t, bool use_gray_encoding = true>
IntegerType DecodeIntegerGene (size_t gene_index, IntegerType min=0, IntegerType max=std::numeric_limits< IntegerType >::max()) const
 
template<typename IntegerType = uint64_t, bool use_gray_encoding = true>
void EncodeIntegerGene (size_t gene_index, IntegerType value)
 
template<typename FloatType = double, bool use_gray_encoding = true>
FloatType DecodeFloatGene (size_t gene_index, FloatType min, FloatType max) const
 
template<typename FloatType = double, bool use_gray_encoding = true>
void EncodeFloatGene (size_t gene_index, FloatType value, FloatType min, FloatType max)
 
bool DecodeBooleanGene (size_t gene_index) const
 
void EncodeBooleanGene (size_t gene_index, bool value)
 
std::byte * GetRawGene (size_t gene_index, size_t *gene_bit_width)
 
- Public Member Functions inherited from panga::BitVector
 BitVector (size_t bit_count=0)
 
 BitVector (const BitVector &source)
 
BitVectoroperator= (const BitVector &rhs)
 
bool Equals (const BitVector &rhs, size_t bits_to_compare) const
 
bool Equals (const BitVector &rhs) const
 
void SetBitCount (size_t bit_count)
 
size_t GetBitCount () const
 
void Clip (size_t bit_count)
 
void Clear ()
 
void Set (size_t index)
 
void Unset (size_t index)
 
bool Get (size_t index) const
 
void Flip (size_t index)
 
template<typename IntegerType = uint64_t>
IntegerType GetInt (size_t bit_index, size_t bit_width) const
 
template<typename IntegerType = uint64_t>
void SetInt (IntegerType value, size_t bit_index, size_t bit_width)
 
void SubVector (BitVector *destination, size_t destination_start_bit_offset, size_t source_start_bit_offset, size_t bits_to_copy) const
 
size_t HammingDistance (const BitVector &rhs) const
 
size_t ToString (char *buffer, size_t buffer_length) const
 
void FromString (const char *buffer, size_t buffer_length)
 
size_t ToStringHex (char *buffer, size_t buffer_length) const
 
void FromStringHex (const char *buffer, size_t buffer_length)
 

Additional Inherited Members

- Static Public Member Functions inherited from panga::Chromosome
template<typename IntegerType = uint64_t>
static IntegerType DecodeGray (IntegerType gray_value)
 
template<typename IntegerType = uint64_t>
static IntegerType EncodeGray (IntegerType binary_value)
 
template<typename FloatType = double, typename IntegerType = uint64_t>
static FloatType DecodeFloat (IntegerType int_value, size_t bit_width, FloatType min, FloatType max)
 
template<typename FloatType = double, typename IntegerType = uint64_t>
static IntegerType EncodeFloat (FloatType float_value, size_t bit_width, FloatType min, FloatType max)
 
static void UniformCrossover (const Chromosome &parent1, const Chromosome &parent2, Chromosome *offspring, RandomWrapper *random, bool ignore_gene_boundaries=true)
 
static void KPointCrossover (size_t k, const Chromosome &parent1, const Chromosome &parent2, Chromosome *offspring, RandomWrapper *random, bool ignore_gene_boundaries=true)
 
static void FlipMutator (Chromosome *chromosome, double mutation_percentage, RandomWrapper *random)
 
- Static Public Attributes inherited from panga::BitVector
static HexFormat_t HexFormat
 
- Protected Member Functions inherited from panga::BitVector
const std::vector< std::byte > & GetBytes () const
 
std::vector< std::byte > & GetBytesWritable ()
 
void Resize (size_t bit_count)
 
void WriteToStream (std::ostream &out) const
 
void WriteToStreamHex (std::ostream &out) const
 
- Static Protected Member Functions inherited from panga::BitVector
template<typename IntegerType = uint64_t>
static void WriteInt (std::byte *bytes, size_t start_bit_index, size_t bits_to_copy, IntegerType value)
 
template<typename IntegerType = uint64_t>
static IntegerType ReadInt (const std::byte *bytes, size_t start_bit_index, size_t bits_to_copy)
 
static void WriteBytes (const std::byte *source, size_t source_start_bit_offset, std::byte *destination, size_t destination_start_bit_offset, size_t bits_to_copy)
 
static bool Compare (const std::byte *left, const std::byte *right, size_t bits_to_compare)
 

Detailed Description

An Individual is a Chromosome with a fitness score.

Member Function Documentation

◆ GetFitness()

double panga::Individual::GetFitness ( ) const

Get the proportional fitness score calculated after we've scored all Individuals in the population with this one.
A higher proportional fitness score indicates a more fit Individual.

◆ GetScore()

double panga::Individual::GetScore ( ) const

Get the score value returned from the fitness function when we called it with this Individual.
A lower raw score indicates a more fit Individual.

◆ operator<()

bool panga::Individual::operator< ( const Individual rhs) const

Less than operator, return negative if this score is less than rhs.score.

◆ operator=()

Individual & panga::Individual::operator= ( const Individual rhs)

Copy |rhs| into this Individual.


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