Chromosome::GaScaledChromosome Class Reference

This class wraps chromosome class and represents it in population. To reduce memory usage and improve performance same chromosome can be placed in multiple populations, but some chromosome's values has different values for separate populations. All values which are specific to the population are extracted from chromosome class to this class. Same object of GaScaledChromosome cannot be located in multiple populations. More...

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

List of all members.

Public Member Functions

 GaScaledChromosome (GaChromosomePtr chromosome, GaPopulation *population, int index)
 This constructor fully initializes binding object (chromosome, population and index).
 GaScaledChromosome (GaPopulation *population)
 This constructor only specifies binding population.
GaChromosomePtr GACALL GetChromosome () const
 This method is not thread-safe.
void GACALL SetChromosome (GaChromosomePtr chromosome)
 SetChromosome sets pointer to bound chromosome.
float GACALL GetScaledFitness () const
 This method is not thread-safe.
void GACALL SetScaledFitness (float fitness)
 SetScaledFitness method sets scaled (transformed) value of bound chromosome.
GAL_API float GACALL GetFitnessForComparison () const
 This method is not thread-safe.
GAL_API void GACALL Rescale ()
 Rescale method recalculates scaled (transformed) fitness value of chromosome.
int GACALL CompareFitnesses (const GaScaledChromosome &c) const
 This method compares fitness values of two chromosomes (this and c). Which fitness value (scaled or original) is going to be used depends on flag set in population to which chromosomes are bound. NOTE: Comparison doesn't have to be arithmetical comparison.
GAL_API int GACALL CompareFitnesses (float c) const
 This method compares fitness values of two chromosomes (this and c). Which fitness value (scaled or original) is going to be used depends on flag set in population to which chromosomes are bound. NOTE: Comparison doesn't have to be arithmetical comparison.
void GACALL ClearGroupFlags (GaSortedGroupType groups)
 ClearGroupFlag method clears chromosome's membership flag for specified sorted group of population.
void GACALL SetGroupFlags (GaSortedGroupType groups)
 SetGroupFlag method sets chromosome's membership flag for specified sorted group of population.
bool GACALL GetGroupFlag (GaSortedGroupType groups, bool all=false)
 Method returns state of desired membership flag(s).
void GACALL SetGroups (GaSortedGroupType groups)
 SetGroups sets all flags of sorted group membership.
GaSortedGroupType GACALL GetGroups () const
 This method is not thread-safe.
GAL_API void GACALL SetIndex (int index)
 SetIndex method sets index of bound chromosome in population.
int GACALL GetIndex () const
 This method is not thread-safe.
GaPopulation &GACALL GetPopulation () const
 This method is not thread-safe.
GACALL operator GaChromosomePtr () const
 This operator is not thread-safe.
GACALL operator float () const
 This operator is not thread-safe.

Private Attributes

float _scaledFitness
 Scaled (transformed) fitness value of the chromosome.
GaPopulation_population
 Pointer to population in which the chromosome is located.
GaChromosomePtr _chromosome
 Smart pointer to chromosome which is bound to population with this object.
GaSortedGroupType _groups
 Flags od memberships in sorted groups of population.
int _index
 Index of chromosome in population.


Detailed Description

This class wraps chromosome class and represents it in population. To reduce memory usage and improve performance same chromosome can be placed in multiple populations, but some chromosome's values has different values for separate populations. All values which are specific to the population are extracted from chromosome class to this class. Same object of GaScaledChromosome cannot be located in multiple populations.

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::GaScaledChromosome::GaScaledChromosome ( GaChromosomePtr  chromosome,
GaPopulation population,
int  index 
)

This constructor fully initializes binding object (chromosome, population and index).

Parameters:
chromosome smart pointer to bound chromosome.
population pointer to population to which chromosome is bound.
index index of chromosome in population.

Chromosome::GaScaledChromosome::GaScaledChromosome ( GaPopulation population  ) 

This constructor only specifies binding population.

Parameters:
population pointer to population to which chromosome is bound.


Member Function Documentation

GaChromosomePtr GACALL Chromosome::GaScaledChromosome::GetChromosome (  )  const [inline]

This method is not thread-safe.

Returns:
Method returns smart pointer to bound chromosome. Or NULL pointer if object doesn't bind chromosome.

void GACALL Chromosome::GaScaledChromosome::SetChromosome ( GaChromosomePtr  chromosome  )  [inline]

SetChromosome sets pointer to bound chromosome.

This method is not thread-safe.

Parameters:
chromosome smart pointer to bound chromosome.

float GACALL Chromosome::GaScaledChromosome::GetScaledFitness (  )  const [inline]

This method is not thread-safe.

Returns:
Method returns scaled (transformed) fitness value of bound chromosome.

void GACALL Chromosome::GaScaledChromosome::SetScaledFitness ( float  fitness  )  [inline]

SetScaledFitness method sets scaled (transformed) value of bound chromosome.

This method is not thread-safe.

Parameters:
fitness new fitness value.

float Chromosome::GaScaledChromosome::GetFitnessForComparison (  )  const

This method is not thread-safe.

Returns:
Method returns fitness value (scaled or original value) which is used for sorting and comparison of chromosomes in population.

void GACALL Chromosome::GaScaledChromosome::Rescale (  ) 

Rescale method recalculates scaled (transformed) fitness value of chromosome.

int GACALL Chromosome::GaScaledChromosome::CompareFitnesses ( const GaScaledChromosome c  )  const [inline]

This method compares fitness values of two chromosomes (this and c). Which fitness value (scaled or original) is going to be used depends on flag set in population to which chromosomes are bound. NOTE: Comparison doesn't have to be arithmetical comparison.

This method is not thread-safe.

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

int Chromosome::GaScaledChromosome::CompareFitnesses ( float  c  )  const

This method compares fitness values of two chromosomes (this and c). Which fitness value (scaled or original) is going to be used depends on flag set in population to which chromosomes are bound. NOTE: Comparison doesn't have to be arithmetical comparison.

This method is not thread-safe.

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

void GACALL Chromosome::GaScaledChromosome::ClearGroupFlags ( GaSortedGroupType  groups  )  [inline]

ClearGroupFlag method clears chromosome's membership flag for specified sorted group of population.

Parameters:
groups flags of sorted groups that will be set.

void GACALL Chromosome::GaScaledChromosome::SetGroupFlags ( GaSortedGroupType  groups  )  [inline]

SetGroupFlag method sets chromosome's membership flag for specified sorted group of population.

This method is not thread-safe.

Parameters:
groups flags of sorted groups that will be set.

bool GACALL Chromosome::GaScaledChromosome::GetGroupFlag ( GaSortedGroupType  groups,
bool  all = false 
) [inline]

Method returns state of desired membership flag(s).

This method is not thread-safe.

Parameters:
groups desired flags of sorted groups which state is queried. Flags are cmbined with operator |.
all parameter tells method how the states of flag are combined into result. It this parameter is set to true, method returns true only if all flags is set, otherwise if this parameter is set to false, method returns true if any of flags is set.
Returns:
It returns true if any of desired flags is set and all parameter is set to false. If all parameter is set to true, method returns true only if all desired flags are set.

void GACALL Chromosome::GaScaledChromosome::SetGroups ( GaSortedGroupType  groups  )  [inline]

SetGroups sets all flags of sorted group membership.

This method is not thread-safe.

Parameters:
groups new values of flags of sorted groups membership.

GaSortedGroupType GACALL Chromosome::GaScaledChromosome::GetGroups (  )  const [inline]

This method is not thread-safe.

Returns:
Method returns all values of flags of sorted group membership.

void Chromosome::GaScaledChromosome::SetIndex ( int  index  ) 

SetIndex method sets index of bound chromosome in population.

Parameters:
index new index of bound chromosome.

int GACALL Chromosome::GaScaledChromosome::GetIndex (  )  const [inline]

This method is not thread-safe.

Returns:
Method returns index of bound chromosome in population.

GaPopulation& GACALL Chromosome::GaScaledChromosome::GetPopulation (  )  const [inline]

This method is not thread-safe.

Returns:
Method returns reference to a population to which chromosome is bound.

GACALL Chromosome::GaScaledChromosome::operator GaChromosomePtr (  )  const [inline]

This operator is not thread-safe.

Returns:
Operator returns smart pointer to bound chromosome. Or NULL pointer if object isn't bound to chromosome.

GACALL Chromosome::GaScaledChromosome::operator float (  )  const [inline]

This operator is not thread-safe.

Returns:
Operator returns index of bound chromosome in population.


Member Data Documentation

Scaled (transformed) fitness value of the chromosome.

Pointer to population in which the chromosome is located.

Smart pointer to chromosome which is bound to population with this object.

Flags od memberships in sorted groups of population.

Index of chromosome in population.


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

Genetic Algorithm Library
Coolsoft Software Development