#include <Chromosome.h>
Inheritance diagram for gal::Chromosome< T >:
Public Member Functions | |
Chromosome () | |
Constructs an empty Chromosome. | |
Chromosome (int length) | |
Constructs a Chromosome, initialised with a random bitstring. | |
int | length () |
Returns the length of the bitstring. | |
bool | isElite () |
Returns whether this Chromosome has the elite-status, which is needed in the Population evolution. | |
void | setElite (bool isElite=true) |
Sets the elite status of this chromosome. | |
void | setLength (int length) |
Sets the number of bits in this Chromosome's bitstring. | |
virtual void | setBits (char *c) |
Sets the bitstring of this chromosome, from begin to end. | |
virtual std::list< char > const | getInterpretedBitstring () |
Returns the actual interpretation of a bit string. | |
virtual T const | getValue () |
Returns the represented value of this Chromosome. | |
virtual std::string const | getValueText () |
Returns the represented value of this Chromosome as a string. | |
virtual std::string const | getBitstringText () |
Returns a string representation of the raw bitstring. | |
virtual std::string const | getInterpretedBitstringText () |
Returns a string representation of the interpreted bitstring. | |
virtual void | mutate (double prob) |
Perform mutation, i.e. | |
virtual void | crossover (int pos, Chromosome< T > *g) |
Perform crossover with another Chromosome, i.e. | |
virtual void | crossover (Chromosome< T > *g) |
Perform crossover with an other Chromosome at a random position. | |
Protected Attributes | |
std::list< char > | _bits |
The bitstring as a list of chars. |
Examples of type T are: int for one variable, vector<double> for a point in n-dimensional space.
One always needs to use a subclass of this class, where all virtual functions are defined.
|
Constructs an empty Chromosome.
|
|
Constructs a Chromosome, initialised with a random bitstring.
|
|
Perform crossover with an other Chromosome at a random position.
|
|
Perform crossover with another Chromosome, i.e. split both this and the other chromosome at the same position in their bitstring, and exchange one of their halves. chromosome 1: AAAABBB --> AAAADDD chromosome 2: CCCCDDD --> CCCCBBB ^pos = 4 (i.e. start at 0)
|
|
Returns a string representation of the raw bitstring.
|
|
Returns the actual interpretation of a bit string. By default, this is just the same bit string, but an alternative would be the Gray-decoded value of the raw bit string.
Reimplemented in gal::GrayCodeChromosome< T >, and gal::GrayCodeChromosome< int >. |
|
Returns a string representation of the interpreted bitstring.
|
|
Returns the represented value of this Chromosome. This method should always be defined in a derived class. Reimplemented in gal::IntChromosome, and gal::IntGCChromosome. |
|
Returns the represented value of this Chromosome as a string. This method should always be defined in a derived class. Reimplemented in gal::IntChromosome, and gal::IntGCChromosome. |
|
Returns whether this Chromosome has the elite-status, which is needed in the Population evolution.
|
|
Returns the length of the bitstring.
|
|
Perform mutation, i.e. flip each bit with specified probability.
|
|
Sets the bitstring of this chromosome, from begin to end.
|
|
Sets the elite status of this chromosome.
|
|
Sets the number of bits in this Chromosome's bitstring.
|