GaChromosome
is interface for all chromosomes types in the library. Algorithms, populations and genetic operations assume that all chromosomes obey this interface. Genetic operations over chromosomes (crossover, mutation, fitness function) may require additional interfaces to be implemented, but all other built-in parts of the library don't have additional assumptions.
More...
#include <D:/Temp/vs/gal/source/Chromosome.h>
Inherited by Chromosome::GaDefaultChromosome.
Public Member Functions | |
virtual | ~GaChromosome () |
Because this is base class, virtual destructor must be defined in order to enable calling of right destructor (destructor of inheriting class). | |
virtual GaChromosomePtr GACALL | Crossover (GaChromosomePtr secondParent) const =0 |
This method performs crossover operation with two parents (this and secondParent ) and produce offspring. | |
virtual void GACALL | Mutation ()=0 |
This method performs mutation over this chromosome. | |
virtual GaChromosomePtr GACALL | MakeCopy (bool setupOnly) const =0 |
This method produces copy of chromosome. It can create exact copy or it can create chromosome with new code, but with exact setup (parameters, operations, etc). | |
virtual GaChromosomePtr GACALL | MakeNewFromPrototype () const =0 |
This method creates new chromosome with exact setup (parameters, operations, etc) of this chromosome. | |
virtual float GACALL | GetFitness () const =0 |
This method returns fitness value of chromosome. | |
virtual int GACALL | CompareFitnesses (GaChromosomePtr c) const =0 |
This method compares fitness values of two chromosomes (this and c ). NOTE: Comparison doesn't have to be arithmetical comparison. | |
virtual int GACALL | CompareFitnesses (float c) const =0 |
This method compares fitness values of two chromosomes (this and c ). NOTE: Comparison doesn't have to be arithmetical comparison. | |
virtual void GACALL | RefreshFitness ()=0 |
This method recalculates fitness value of the chromosome and stores it. | |
virtual const GaChromosomeParams &GACALL | GetParameters () const =0 |
This method returns reference of chromosome's parameters. | |
virtual void GACALL | SetParameters (GaChromosomeParams *p)=0 |
This method sets pointer to new parameters of chromosome. | |
virtual int GACALL | GetCodeSize () const =0 |
This method returns size of chromosome.s code. | |
virtual GaChromosome &GACALL | operator= (const GaChromosome &rhs)=0 |
This operator copies setup and chromosome's code from rhs . | |
virtual float GACALL | operator== (const GaChromosome &c) const =0 |
This operator compares chromosomes' codes. | |
Protected Member Functions | |
virtual float GACALL | CalculateFitness () const =0 |
This method calculates chromosome's fitness value, but it doesn't store it. |
GaChromosome
is interface for all chromosomes types in the library. Algorithms, populations and genetic operations assume that all chromosomes obey this interface. Genetic operations over chromosomes (crossover, mutation, fitness function) may require additional interfaces to be implemented, but all other built-in parts of the library don't have additional assumptions.
virtual Chromosome::GaChromosome::~GaChromosome | ( | ) | [inline, virtual] |
Because this is base class, virtual destructor must be defined in order to enable calling of right destructor (destructor of inheriting class).
virtual GaChromosomePtr GACALL Chromosome::GaChromosome::Crossover | ( | GaChromosomePtr | secondParent | ) | const [pure virtual] |
This method performs crossover operation with two parents (this
and secondParent
) and produce offspring.
secondParent | smart pointer to second parent. |
Implemented in Chromosome::GaDefaultChromosome.
virtual void GACALL Chromosome::GaChromosome::Mutation | ( | ) | [pure virtual] |
virtual GaChromosomePtr GACALL Chromosome::GaChromosome::MakeCopy | ( | bool | setupOnly | ) | const [pure virtual] |
This method produces copy of chromosome. It can create exact copy or it can create chromosome with new code, but with exact setup (parameters, operations, etc).
setupOnly | it this parameter is set to true only the setup of the chromosome is copied into new one, and new chromosome code is created, otherwise the whole chromosome is copied (code and setup). |
Implemented in Chromosome::Representation::GaBinaryChromosome, Chromosome::Representation::GaMultiValueChromosome< TYPE >, Chromosome::Representation::GaMVArithmeticChromosome< TYPE >, Chromosome::Representation::GaSingleValueChromosome< TYPE >, and Chromosome::Representation::GaSVArithmeticChromosome< TYPE >.
virtual GaChromosomePtr GACALL Chromosome::GaChromosome::MakeNewFromPrototype | ( | ) | const [pure virtual] |
This method creates new chromosome with exact setup (parameters, operations, etc) of this chromosome.
Implemented in Chromosome::Representation::GaBinaryChromosome, Chromosome::Representation::GaMultiValueChromosome< TYPE >, and Chromosome::Representation::GaSingleValueChromosome< TYPE >.
virtual float GACALL Chromosome::GaChromosome::GetFitness | ( | ) | const [pure virtual] |
This method returns fitness value of chromosome.
Implemented in Chromosome::GaDefaultChromosome.
virtual int GACALL Chromosome::GaChromosome::CompareFitnesses | ( | GaChromosomePtr | c | ) | const [pure virtual] |
This method compares fitness values of two chromosomes (this
and c
). NOTE: Comparison doesn't have to be arithmetical comparison.
c | the second chromosome for comparison with this . |
this
is lower then value of c
. this
is greater then value of c
. Implemented in Chromosome::GaDefaultChromosome.
virtual int GACALL Chromosome::GaChromosome::CompareFitnesses | ( | float | c | ) | const [pure virtual] |
This method compares fitness values of two chromosomes (this
and c
). NOTE: Comparison doesn't have to be arithmetical comparison.
c | the second chromosome for comparison with this . |
this
is lower then value of c
. this
is greater then value of c
. Implemented in Chromosome::GaDefaultChromosome, and Chromosome::GaDynamicOperationChromosome.
virtual void GACALL Chromosome::GaChromosome::RefreshFitness | ( | ) | [pure virtual] |
This method recalculates fitness value of the chromosome and stores it.
Implemented in Chromosome::GaDefaultChromosome.
virtual const GaChromosomeParams& GACALL Chromosome::GaChromosome::GetParameters | ( | ) | const [pure virtual] |
This method returns reference of chromosome's parameters.
Implemented in Chromosome::GaDefaultChromosome.
virtual void GACALL Chromosome::GaChromosome::SetParameters | ( | GaChromosomeParams * | p | ) | [pure virtual] |
This method sets pointer to new parameters of chromosome.
p | pointer to new parameters. |
Implemented in Chromosome::GaDefaultChromosome.
virtual int GACALL Chromosome::GaChromosome::GetCodeSize | ( | ) | const [pure virtual] |
This method returns size of chromosome.s code.
Implemented in Chromosome::Representation::GaBinaryChromosome, Chromosome::Representation::GaMultiValueChromosome< TYPE >, and Chromosome::Representation::GaSingleValueChromosome< TYPE >.
virtual GaChromosome& GACALL Chromosome::GaChromosome::operator= | ( | const GaChromosome & | rhs | ) | [pure virtual] |
This operator copies setup and chromosome's code from rhs
.
rhs | reference to chromosome which should be copied. |
Implemented in Chromosome::Representation::GaBinaryChromosome, Chromosome::GaDefaultChromosome, Chromosome::Representation::GaMultiValueChromosome< TYPE >, and Chromosome::Representation::GaSingleValueChromosome< TYPE >.
virtual float GACALL Chromosome::GaChromosome::operator== | ( | const GaChromosome & | c | ) | const [pure virtual] |
This operator compares chromosomes' codes.
c | reference to chromosome which is compared to this chromosome. |
Implemented in Chromosome::Representation::GaBinaryChromosome, Chromosome::Representation::GaMultiValueChromosome< TYPE >, and Chromosome::Representation::GaSingleValueChromosome< TYPE >.
virtual float GACALL Chromosome::GaChromosome::CalculateFitness | ( | ) | const [protected, pure virtual] |
This method calculates chromosome's fitness value, but it doesn't store it.
Implemented in Chromosome::GaDynamicOperationChromosome.