|
Developer Documentation |
|
Centre for Vision, Speech & Signal Processing |
Comments:
Genetic algorithm base class. Uses internal class GeneC to represent
individual genes which consist conceptually of a number of chromosomes.
All chromosomes have the same number of bits but the number of
chromosomes can vary between a specified upper and lower limit.
The function EvaluateFitness must be overloaded in a derived class to
provide actual functionality for the algorithm. This algorithm should be
applicable in a variety of domains such as feature selection, numerical
optimisation and combinatorial optimisation. For an example of its use for
numerical optimisation see NumOptimiseGeneticC.
Derived Classes:
Child Classes:
Variables:
- SArray1dC _pool;
-
- UIntT _chromosomeSize;
-
- UIntT _minChromosomes;
-
- UIntT _maxChromosomes;
-
- RealT _probMutation;
-
- RealT _probCrossover;
-
Methods:
- GeneticAlgorithmC(UIntT chromosomeSize,UIntT minChromosomes,UIntT maxChromosomes,UIntT poolSize = 21,RealT probMutation = 0.05,RealT probCrossover = 0.6)
-
Usual constructor
| chromosomeSize | number of bits per chromosome |
| minChromosomes | minimum number of chromosomes in gene |
| maxChromosomes | maximum number of chromosomes in gene |
| poolSize | number of genes to store during each generation |
| probMutation | chance per gene of mutation occuring |
| probCrossover | chance per gene pair of crossover occuring |
|
- GeneticAlgorithmC(istream & in)
-
Constructs from stream
- GeneticAlgorithmC(const GeneticAlgorithmC & oth)
-
Copy constructor
- ~GeneticAlgorithmC()
-
Virtual destructor because EvaluateFitness virtual
- void SetChromosomes(UIntT chromosomeSize,UIntT minChromosomes,UIntT maxChromosomes)
-
Sets chromosome characteristics as in constructor
- void RandomPool(const IntSArray1dC & initialGene)
-
Generates a random pool of genes.
| initialGene | starting point or elite gene from previous generation |
|
Generates a pool containing random genes inserts the initialGene into the
pool to ensure its survival.
- void Generation()
-
Performs one generation of evolution
This involves evaluation, selection, mutation and crossover.
- const IntSArray1dC GetBestGene() const
-
Returns the best gene as a bit string
- void Save(ostream & out) const
-
Writes object to stream, cna be loaded using constructor
- RealT EvaluateFitness(const IntSArray1dC & gene)
-
Determine fitness of the given gene bitstring
Must be overloaded in derived class to calculated fitness given a
gene string
- void Evaluation()
-
Performs evaluation of the gene pool
- void Selection()
-
Creates next generation gene pool using selection process
- void Mutation()
-
Performs mutation of the genes
- void Crossover()
-
Performs crossover of the genes
- void Crossover(GeneC & mum,GeneC & dad)
-
Performs crossover of a pair of genes
|
Programmer:Robert Crida, Documentation by CxxDoc: Tue Mar 20 10:49:27 2001
|