Chromosome::GaChromosome Class Reference

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.

List of all members.

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.


Detailed Description

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.


Constructor & Destructor Documentation

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).


Member Function Documentation

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.

Parameters:
secondParent smart pointer to second parent.
Returns:
Method returns smart pointer to newly created offspring.

Implemented in Chromosome::GaDefaultChromosome.

virtual void GACALL Chromosome::GaChromosome::Mutation (  )  [pure virtual]

This method performs mutation over this chromosome.

Implemented in Chromosome::GaDefaultChromosome.

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).

Parameters:
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).
Returns:
Method returns smart pointer to newly created chromosome.

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.

Returns:
Method returns smart pointer to newly created 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.

Returns:
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.

Parameters:
c the second chromosome for comparison with this.
Returns:
a) -1 if fitness value of this is lower then value of c.
b) 0 if fitness values of both chromosomes are equal.
c) 1 if fitness value of 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.

Parameters:
c the second chromosome for comparison with this.
Returns:
a) -1 if fitness value of this is lower then value of c.
b) 0 if fitness values of both chromosomes are equal.
c) 1 if fitness value of 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.

Returns:
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.

Parameters:
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.

Returns:
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.

Parameters:
rhs reference to chromosome which should be copied.
Returns:
Method returns reference to this.

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.

Parameters:
c reference to chromosome which is compared to this chromosome.
Returns:
Method returns percent of similarity

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.

Returns:
Method returns calculated fitness value.

Implemented in Chromosome::GaDynamicOperationChromosome.


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

Genetic Algorithm Library
Coolsoft Software Development