Genetic Algorithm Common Interface. More...

Inheritance diagram for GeneticAlgo:

List of all members.

Public Member Functions

 GeneticAlgo ()
 Constructor.
virtual ~GeneticAlgo ()
 Destructor.
QVector< QVector< double > > averageFits () const
 Return the Average objective values over generation done.
QVector< QVector< double > > bestFits () const
 Return the Best objective values over generation done.
virtual QVector< Evaluation * > evaluationPool ()=0
 Return the Evaluation Pool containing the Evaluations effectively used during evolution.
virtual EvaluationevaluationPrototype ()=0
 Returns the Evaluation object used as prototype to eventually generate other evaluators.
void evolve (unsigned int generationToReach)
 Evolve Genome until reach the generation specified.
void evolve ()
 Evolve Genome until condition isEvolutionEnded has been reached.
virtual void finalize ()=0
 Finalize the Genetic Algorithm Process.
virtual void gaStep ()=0
 Execute a single minor step and return.
unsigned int generation () const
 Return the current generation number.
Genomegenome ()
 Return the current Genome.
const Genomegenome () const
 Return the current Genome.
virtual void initialize ()=0
 Initialize the Genetic Algorithm Process.
bool isEvaluationDone ()
 returns true if we have evaluated genomes for the current generation
bool isEvolutionEnded ()
 returns true if the evolution process has reached the end
QVector< double > meanHammingDist () const
 Return the Mean of Hamming distance over generation done.
int numGenerations ()
 Return the number of Generations.
void setGeneration (unsigned int gen)
 Set the generation number.
void setGenome (Genome *gen)
 Set the Genome to use as current population.
void setNumGenerations (int g)
 Set the number of Generations to do.
virtual void skipEvaluation ()=0
 Skip the evaluation phase and put the algorithm in the state just after the evaluation.
QVector< double > standardDeviationHammingDist () const
 Return the Standard Deviation of Hamming distance over generation done.
QVector< double > varianceHammingDist () const
 Return the Variance of Hamming distance over generation done.

Protected Member Functions

void updateStats ()
 Update statistical data of current generation and Genome (Mean, Variance, Standard Deviation)

Protected Attributes

QVector< QVector< double > > avgfits
 Statistical Data: report the Average value for each objective for each generation.
QVector< QVector< double > > bestfits
 Statistical Data: report the Best value for each objective for each generation.
bool evaluationDone
 setted by implementors to signal that genomes have been evaluated
when true means that the genomes of the current generation have been evaluated (we are at the end of the end of the generation, next step will be reproduction and start of a new generation), when false means that genomes haven't still not been evaluated (we are at the beginning of a generation, next step will be evaluation of genomes)
bool evolutionEnd
 setted by implementors to signal the finish of evolution process
when true means that evolution is ended
unsigned int generationv
 current generation
Genomegenomev
 current genome
QVector< double > meanHdists
 Statistical Data: report the mean of all hamming distance between genotypes for each generation.
unsigned int numGens
 number of generations
QVector< double > stdHdists
 Statistical Data: report the standard variation of all hamming distance between genotypes for each generation.
QVector< double > varHdists
 Statistical Data: report the variance of all hamming distance between genotypes for each generation.

Detailed Description

Genetic Algorithm Common Interface.

Description
Interface of the Genetic Algorithm Process
This class is highly abstract and there is no methods here for setting Selection, Crossover, Mutation and Reproduction processes in order to allow to each sub-class to choose which subset of operator to use.
Hence, it would be possible to create a GA which allow to specify only Mutation and fix the other in some pre-determined ways.
Warnings

Definition at line 46 of file geneticalgo.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 27 of file geneticalgo.cpp.

~GeneticAlgo ( ) [virtual]

Destructor.

Definition at line 41 of file geneticalgo.cpp.

References GeneticAlgo::genomev.


Member Function Documentation

QVector< QVector< double > > averageFits ( ) const

Return the Average objective values over generation done.

Definition at line 104 of file geneticalgo.cpp.

References GeneticAlgo::avgfits.

QVector< QVector< double > > bestFits ( ) const

Return the Best objective values over generation done.

Warning:
each entry of the vector contains a vector of max values for each objective, but it does not means that exists a genotype scoring all values for all objectives

Definition at line 100 of file geneticalgo.cpp.

References GeneticAlgo::bestfits.

virtual QVector<Evaluation*> evaluationPool ( ) [pure virtual]

Return the Evaluation Pool containing the Evaluations effectively used during evolution.

Implemented in LaralGA, NSGA2, ParallelGA, SimpleGA, and StefanoSteadyStateGA.

virtual Evaluation* evaluationPrototype ( ) [pure virtual]

Returns the Evaluation object used as prototype to eventually generate other evaluators.

This object could or could not be used to compute the fitness of genotypes (depending on the specific genetic algorithm)

Implemented in LaralGA, NSGA2, ParallelGA, SimpleGA, and StefanoSteadyStateGA.

void evolve ( unsigned int  generationToReach)

Evolve Genome until reach the generation specified.

This function exists after haveing evaluated individuals of the generationToReach generation

Warning:
this method is Blocking

Definition at line 45 of file geneticalgo.cpp.

References GeneticAlgo::evaluationDone, GeneticAlgo::gaStep(), GeneticAlgo::generationv, and GeneticAlgo::isEvolutionEnded().

void evolve ( )

Evolve Genome until condition isEvolutionEnded has been reached.

Warning:
this method is Blocking

Definition at line 52 of file geneticalgo.cpp.

References GeneticAlgo::gaStep(), and GeneticAlgo::isEvolutionEnded().

virtual void finalize ( ) [pure virtual]

Finalize the Genetic Algorithm Process.

In order to create specific Algorithms, re-implement this method

Implemented in LaralGA, NSGA2, ParallelGA, SimpleGA, and StefanoSteadyStateGA.

virtual void gaStep ( ) [pure virtual]

Execute a single minor step and return.

In order to create specific Algorithms, re-implement this method

Implemented in LaralGA, NSGA2, ParallelGA, SimpleGA, and StefanoSteadyStateGA.

Referenced by GeneticAlgo::evolve().

const Genome * genome ( ) const

Return the current Genome.

Definition at line 74 of file geneticalgo.cpp.

References GeneticAlgo::genomev.

virtual void initialize ( ) [pure virtual]

Initialize the Genetic Algorithm Process.

In order to create specific Algorithms, re-implement this method

Implemented in LaralGA, NSGA2, ParallelGA, SimpleGA, and StefanoSteadyStateGA.

bool isEvaluationDone ( )

returns true if we have evaluated genomes for the current generation

Definition at line 62 of file geneticalgo.cpp.

References GeneticAlgo::evaluationDone.

bool isEvolutionEnded ( )

returns true if the evolution process has reached the end

Definition at line 58 of file geneticalgo.cpp.

References GeneticAlgo::evolutionEnd.

Referenced by GeneticAlgo::evolve().

QVector< double > meanHammingDist ( ) const

Return the Mean of Hamming distance over generation done.

Definition at line 108 of file geneticalgo.cpp.

References GeneticAlgo::meanHdists.

void setGeneration ( unsigned int  gen)

Set the generation number.

Warning:
be careful on when you use this function. If you set the generation when isEvaluationDone() is true, the next generation to be evaluated will be gen + 1

Definition at line 78 of file geneticalgo.cpp.

References GeneticAlgo::generationv.

Referenced by StefanoSteadyStateGA::gaStep(), SimpleGA::gaStep(), ParallelGA::gaStep(), NSGA2::gaStep(), LaralGA::gaStep(), StefanoSteadyStateGA::initialize(), SimpleGA::initialize(), ParallelGA::initialize(), NSGA2::initialize(), and LaralGA::initialize().

void setNumGenerations ( int  g)

Set the number of Generations to do.

Definition at line 92 of file geneticalgo.cpp.

References GeneticAlgo::numGens.

Referenced by StefanoSteadyStateGA::configure(), SimpleGA::configure(), ParallelGA::configure(), NSGA2::configure(), and LaralGA::configure().

virtual void skipEvaluation ( ) [pure virtual]

Skip the evaluation phase and put the algorithm in the state just after the evaluation.

This can be used after restarting an interrupted evolution to prevent re-evaluation of the genome that was loaded from file.

Implemented in LaralGA, NSGA2, ParallelGA, SimpleGA, and StefanoSteadyStateGA.

QVector< double > standardDeviationHammingDist ( ) const

Return the Standard Deviation of Hamming distance over generation done.

Definition at line 116 of file geneticalgo.cpp.

References GeneticAlgo::stdHdists.

void updateStats ( ) [protected]

Update statistical data of current generation and Genome (Mean, Variance, Standard Deviation)

This method should be called by the user when it re-implement GeneticAlgo just afert the evaluation of all Genotypes in the Genome

Warning:
remember to call it at the right moment, otherwise you will have wrong statistic data

Definition at line 120 of file geneticalgo.cpp.

References Genome::at(), GeneticAlgo::avgfits, GeneticAlgo::bestfits, GeneticAlgo::generationv, GeneticAlgo::genomev, GeneticAlgo::meanHdists, Genotype::numOfObjectives(), Genotype::objective(), Genome::size(), GeneticAlgo::stdHdists, and GeneticAlgo::varHdists.

Referenced by StefanoSteadyStateGA::gaStep(), SimpleGA::gaStep(), ParallelGA::gaStep(), NSGA2::gaStep(), and LaralGA::gaStep().

QVector< double > varianceHammingDist ( ) const

Return the Variance of Hamming distance over generation done.

Definition at line 112 of file geneticalgo.cpp.

References GeneticAlgo::varHdists.


Member Data Documentation

QVector< QVector<double> > avgfits [protected]

Statistical Data: report the Average value for each objective for each generation.

Definition at line 159 of file geneticalgo.h.

Referenced by GeneticAlgo::averageFits(), and GeneticAlgo::updateStats().

QVector< QVector<double> > bestfits [protected]

Statistical Data: report the Best value for each objective for each generation.

Definition at line 157 of file geneticalgo.h.

Referenced by GeneticAlgo::bestFits(), and GeneticAlgo::updateStats().

bool evaluationDone [protected]

setted by implementors to signal that genomes have been evaluated
when true means that the genomes of the current generation have been evaluated (we are at the end of the end of the generation, next step will be reproduction and start of a new generation), when false means that genomes haven't still not been evaluated (we are at the beginning of a generation, next step will be evaluation of genomes)

Definition at line 147 of file geneticalgo.h.

Referenced by GeneticAlgo::evolve(), StefanoSteadyStateGA::gaStep(), SimpleGA::gaStep(), ParallelGA::gaStep(), NSGA2::gaStep(), LaralGA::gaStep(), StefanoSteadyStateGA::initialize(), SimpleGA::initialize(), ParallelGA::initialize(), NSGA2::initialize(), LaralGA::initialize(), GeneticAlgo::isEvaluationDone(), StefanoSteadyStateGA::skipEvaluation(), SimpleGA::skipEvaluation(), ParallelGA::skipEvaluation(), NSGA2::skipEvaluation(), and LaralGA::skipEvaluation().

bool evolutionEnd [protected]
unsigned int generationv [protected]
QVector<double> meanHdists [protected]

Statistical Data: report the mean of all hamming distance between genotypes for each generation.

Definition at line 161 of file geneticalgo.h.

Referenced by GeneticAlgo::meanHammingDist(), and GeneticAlgo::updateStats().

QVector<double> stdHdists [protected]

Statistical Data: report the standard variation of all hamming distance between genotypes for each generation.

Definition at line 165 of file geneticalgo.h.

Referenced by GeneticAlgo::standardDeviationHammingDist(), and GeneticAlgo::updateStats().

QVector<double> varHdists [protected]

Statistical Data: report the variance of all hamming distance between genotypes for each generation.

Definition at line 163 of file geneticalgo.h.

Referenced by GeneticAlgo::updateStats(), and GeneticAlgo::varianceHammingDist().


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