Chromosome::GaDefaultChromosome Class Reference

GaDefaultChromosome class implements some basic feature of chromosome such as management of fitness value, CCB and probability of crossover and mutation operations. More...

#include <D:/Temp/vs/gal/source/Chromosome.h>

Inherits Chromosome::GaChromosome.

Inherited by Chromosome::GaDynamicOperationChromosome.

List of all members.

Public Member Functions

 GaDefaultChromosome (GaChromosomeParamsBlock *configBlock)
 This constructor initializes chromsome with CCB.
 GaDefaultChromosome (const GaDefaultChromosome &c, bool setupOnly)
 Copy constructor.
virtual GAL_API void GACALL Mutation ()
 This method handles probability of mutation and provides framework for improving-only mutations. It decides if mutation is going to be preformed and if it is going to be accepted. If improving-only flag is set, the method calls PreapareForMutation method, then PerformeMutation is called, after the mutation is performed it checks (only if improving-only flag is set) if the mutation produced chromosome with better fitness, if that is the case AcceptMutation is called, otherwise RejectMutation is called.
virtual GAL_API
GaChromosomePtr GACALL 
Crossover (GaChromosomePtr secondParent) const
 This method handles probability of crossover. It decides if crossover is going to be preformed. If crossover is going to be performed this method calls PerformeCrossover.
virtual float GACALL GetFitness () const
 This method is not-thread safe.
virtual int GACALL CompareFitnesses (GaChromosomePtr c) const
 This method only extracts fitness value from c, and delegate responsibility to ComapreFitnesses(float) method. More details are given in specification of GaChromosome::CompareFitnesses of interface.
virtual int GACALL CompareFitnesses (float c) const =0
 More details are given in specification of GaChromosome::CompareFitnesses of interface.
virtual void GACALL RefreshFitness ()
 RefreshFitness method recalculates fitness value of the chromosome and stores it.
virtual const
GaChromosomeParams &GACALL 
GetParameters () const
 This method is not thread-safe.
virtual void GACALL SetParameters (GaChromosomeParams *p)
 SetParameters method sets pointer to new parameters of chromosome.
virtual const
GaChromosomeParamsBlock
&GACALL 
GetConfigBlock () const
 This method is not thread-safe.
virtual void GACALL SetConfigBlock (GaChromosomeParamsBlock *block)
 SetConfigBlock method sets pointer to new CCB.
virtual GaChromosome &GACALL operator= (const GaChromosome &rhs)
 operator = copies setup and chromosome's code from rhs.

Protected Member Functions

virtual void GACALL PerformMutation ()=0
 It is called when mutation should be performed over chromosome.
virtual GaChromosomePtr GACALL PerformCrossover (GaChromosomePtr secondParent) const =0
 . It is called when crossover should be performed over two chromosomes to produce offspring.
virtual void GACALL PreapareForMutation ()=0
 This method called before performing mutation if improving-only mutation flag is set. It should save chromosome's code so it can be restored if mutation produce chromosome with lower fitness value.
virtual void GACALL AcceptMutation ()=0
 This method is called after mutation is performed if improving-only mutation flag is set and mutation improved fitness value. The method can delete backed up chromosome's code which was made by PreapareForMutation method.
virtual void GACALL RejectMutation ()=0
 This method is called after mutation is performed if improving-only mutation flag is set and mutation degraded fitness value. The method restores old chromosome's code which was backed up with PreapareForMutation method.

Protected Attributes

float _fitness
 Fitness value of the chromosome.
GaChromosomeParamsBlock_configBlock
 Pointer to CCB.


Detailed Description

GaDefaultChromosome class implements some basic feature of chromosome such as management of fitness value, CCB and probability of crossover and mutation operations.

This class has no built-in synchronizator, so LOCK_OBJECT and LOCK_THIS_OBJECT macros cannot be used with instances of this class. No public or private methods are thread-safe.


Constructor & Destructor Documentation

Chromosome::GaDefaultChromosome::GaDefaultChromosome ( GaChromosomeParamsBlock configBlock  )  [inline]

This constructor initializes chromsome with CCB.

Parameters:
configBlock pointer to CCB.

Chromosome::GaDefaultChromosome::GaDefaultChromosome ( const GaDefaultChromosome c,
bool  setupOnly 
) [inline]

Copy constructor.

Parameters:
c reference to chromosome which is copied.
setupOnly if this parameter is true, only pointer to CCB is copied. If this parameter is false, chromosome's data and CCB is copied.


Member Function Documentation

void Chromosome::GaDefaultChromosome::Mutation (  )  [virtual]

This method handles probability of mutation and provides framework for improving-only mutations. It decides if mutation is going to be preformed and if it is going to be accepted. If improving-only flag is set, the method calls PreapareForMutation method, then PerformeMutation is called, after the mutation is performed it checks (only if improving-only flag is set) if the mutation produced chromosome with better fitness, if that is the case AcceptMutation is called, otherwise RejectMutation is called.

This method is not thread-safe.

Implements Chromosome::GaChromosome.

GaChromosomePtr Chromosome::GaDefaultChromosome::Crossover ( GaChromosomePtr  secondParent  )  const [virtual]

This method handles probability of crossover. It decides if crossover is going to be preformed. If crossover is going to be performed this method calls PerformeCrossover.

This method is not thread-safe.

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

Implements Chromosome::GaChromosome.

virtual float GACALL Chromosome::GaDefaultChromosome::GetFitness (  )  const [inline, virtual]

This method is not-thread safe.

Returns:
Method returns fitness value of chromosome.

Implements Chromosome::GaChromosome.

virtual int GACALL Chromosome::GaDefaultChromosome::CompareFitnesses ( GaChromosomePtr  c  )  const [inline, virtual]

This method only extracts fitness value from c, and delegate responsibility to ComapreFitnesses(float) method. More details are given in specification of GaChromosome::CompareFitnesses of interface.

This method is not thread-safe.

Implements Chromosome::GaChromosome.

virtual int GACALL Chromosome::GaDefaultChromosome::CompareFitnesses ( float  c  )  const [pure virtual]

More details are given in specification of GaChromosome::CompareFitnesses of interface.

This method is not thread-safe.

Implements Chromosome::GaChromosome.

Implemented in Chromosome::GaDynamicOperationChromosome.

virtual void GACALL Chromosome::GaDefaultChromosome::RefreshFitness (  )  [inline, virtual]

RefreshFitness method recalculates fitness value of the chromosome and stores it.

This method is not thread safe.

Implements Chromosome::GaChromosome.

virtual const GaChromosomeParams& GACALL Chromosome::GaDefaultChromosome::GetParameters (  )  const [inline, virtual]

This method is not thread-safe.

Returns:
Method returns reference of chromosome's parameters.

Implements Chromosome::GaChromosome.

virtual void GACALL Chromosome::GaDefaultChromosome::SetParameters ( GaChromosomeParams p  )  [inline, virtual]

SetParameters method sets pointer to new parameters of chromosome.

This method is not thread-safe.

Parameters:
p pointer to new parameters.

Implements Chromosome::GaChromosome.

virtual const GaChromosomeParamsBlock& GACALL Chromosome::GaDefaultChromosome::GetConfigBlock (  )  const [inline, virtual]

This method is not thread-safe.

Returns:
This method returns reference to CCB.

virtual void GACALL Chromosome::GaDefaultChromosome::SetConfigBlock ( GaChromosomeParamsBlock block  )  [inline, virtual]

SetConfigBlock method sets pointer to new CCB.

This method is not thread-safe.

Parameters:
block pointer to new CCB.

virtual GaChromosome& GACALL Chromosome::GaDefaultChromosome::operator= ( const GaChromosome rhs  )  [inline, virtual]

operator = copies setup and chromosome's code from rhs.

This operator is not thread-safe.

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

Implements Chromosome::GaChromosome.

Reimplemented in Chromosome::Representation::GaBinaryChromosome, Chromosome::Representation::GaMultiValueChromosome< TYPE >, and Chromosome::Representation::GaSingleValueChromosome< TYPE >.

virtual void GACALL Chromosome::GaDefaultChromosome::PerformMutation (  )  [protected, pure virtual]

It is called when mutation should be performed over chromosome.

Implemented in Chromosome::GaDynamicOperationChromosome.

virtual GaChromosomePtr GACALL Chromosome::GaDefaultChromosome::PerformCrossover ( GaChromosomePtr  secondParent  )  const [protected, pure virtual]

. It is called when crossover should be performed over two chromosomes to produce offspring.

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

Implemented in Chromosome::GaDynamicOperationChromosome.

virtual void GACALL Chromosome::GaDefaultChromosome::PreapareForMutation (  )  [protected, pure virtual]

This method called before performing mutation if improving-only mutation flag is set. It should save chromosome's code so it can be restored if mutation produce chromosome with lower fitness value.

Implemented in Chromosome::Representation::GaBinaryChromosome, Chromosome::Representation::GaMultiValueChromosome< TYPE >, and Chromosome::Representation::GaSingleValueChromosome< TYPE >.

virtual void GACALL Chromosome::GaDefaultChromosome::AcceptMutation (  )  [protected, pure virtual]

This method is called after mutation is performed if improving-only mutation flag is set and mutation improved fitness value. The method can delete backed up chromosome's code which was made by PreapareForMutation method.

Implemented in Chromosome::Representation::GaBinaryChromosome, Chromosome::Representation::GaMultiValueChromosome< TYPE >, and Chromosome::Representation::GaSingleValueChromosome< TYPE >.

virtual void GACALL Chromosome::GaDefaultChromosome::RejectMutation (  )  [protected, pure virtual]

This method is called after mutation is performed if improving-only mutation flag is set and mutation degraded fitness value. The method restores old chromosome's code which was backed up with PreapareForMutation method.

Implemented in Chromosome::Representation::GaBinaryChromosome, Chromosome::Representation::GaMultiValueChromosome< TYPE >, and Chromosome::Representation::GaSingleValueChromosome< TYPE >.


Member Data Documentation

Fitness value of the chromosome.

Pointer to CCB.


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

Genetic Algorithm Library
Coolsoft Software Development