Genetic Algorithm Common Interface. More...

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 Evaluation * | evaluationPrototype ()=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. | |
Genome * | genome () |
Return the current Genome. | |
const Genome * | genome () 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. | |
![]() | |
void | addObserver (RuntimeParameterObserver *obs) |
virtual void | configure (ConfigurationParameters ¶ms, QString prefix)=0 |
T | getRuntimeParameter (QString paramName) |
virtual ParameterSettableUI * | getUIManager () |
ParameterSettable () | |
virtual void | postConfigureInitialization () |
void | removeObserver (RuntimeParameterObserver *obs) |
virtual void | save (ConfigurationParameters ¶ms, QString prefix)=0 |
void | setRuntimeParameter (QString paramName, T newvalue) |
QString | typeName () const |
![]() | |
void | addObserver (RuntimeParameterObserver *obs) |
T | getRuntimeParameter (QString paramName) |
void | removeObserver (RuntimeParameterObserver *obs) |
void | setRuntimeParameter (QString paramName, T newvalue) |
QString | typeName () const |
Protected Member Functions | |
void | updateStats () |
Update statistical data of current generation and Genome (Mean, Variance, Standard Deviation) | |
![]() | |
void | notifyChangesToParam (QString paramName) |
![]() | |
void | notifyChangesToParam (QString paramName) |
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 | |
Genome * | genomev |
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. | |
Additional Inherited Members | |
![]() | |
enum | Property |
![]() | |
static void | describe (QString type) |
static QString | fullParameterDescriptionPath (QString type, QString param) |
static QString | fullSubgroupDescriptionPath (QString type, QString sub) |
![]() | |
AllowMultiple | |
Default | |
IsList | |
IsMandatory | |
![]() | |
static const double | Infinity |
static const int | MaxInteger |
static const int | MinInteger |
![]() | |
static Descriptor | addTypeDescription (QString type, QString shortHelp, QString longHelp=QString("")) |
static void | setGraphicalEditor (QString type) |
Detailed Description
Genetic Algorithm Common Interface.
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.
Definition at line 44 of file geneticalgo.h.
Constructor & Destructor Documentation
GeneticAlgo | ( | ) |
Constructor.
Definition at line 27 of file geneticalgo.cpp.
|
virtual |
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.
|
pure virtual |
Return the Evaluation Pool containing the Evaluations effectively used during evolution.
Implemented in LaralGA, ParallelGA, NSGA2, SimpleGA, and StefanoSteadyStateGA.
|
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, ParallelGA, NSGA2, 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().
|
pure virtual |
Finalize the Genetic Algorithm Process.
In order to create specific Algorithms, re-implement this method
Implemented in LaralGA, ParallelGA, NSGA2, SimpleGA, and StefanoSteadyStateGA.
|
pure virtual |
Execute a single minor step and return.
In order to create specific Algorithms, re-implement this method
Implemented in LaralGA, ParallelGA, NSGA2, SimpleGA, and StefanoSteadyStateGA.
Referenced by GeneticAlgo::evolve().
unsigned int generation | ( | ) | const |
Return the current generation number.
Definition at line 88 of file geneticalgo.cpp.
References GeneticAlgo::generationv.
Referenced by StefanoSteadyStateGA::gaStep(), NSGA2::gaStep(), SimpleGA::gaStep(), ParallelGA::gaStep(), LaralGA::gaStep(), Mutation::mutationRate(), Mutation::setMutationRate(), SimpleGA::skipEvaluation(), NSGA2::skipEvaluation(), ParallelGA::skipEvaluation(), and LaralGA::skipEvaluation().
Genome * genome | ( | ) |
Return the current Genome.
Definition at line 70 of file geneticalgo.cpp.
References GeneticAlgo::genomev.
Referenced by StefanoSteadyStateGA::configure(), SimpleGA::configure(), NSGA2::configure(), ParallelGA::configure(), LaralGA::configure(), StefanoSteadyStateGA::finalize(), StefanoSteadyStateGA::gaStep(), SimpleGA::gaStep(), NSGA2::gaStep(), ParallelGA::gaStep(), LaralGA::gaStep(), StefanoSteadyStateGA::initialize(), StefanoSteadyStateGA::save(), SimpleGA::save(), NSGA2::save(), ParallelGA::save(), and LaralGA::save().
const Genome * genome | ( | ) | const |
Return the current Genome.
Definition at line 74 of file geneticalgo.cpp.
References GeneticAlgo::genomev.
|
pure virtual |
Initialize the Genetic Algorithm Process.
In order to create specific Algorithms, re-implement this method
Implemented in LaralGA, ParallelGA, NSGA2, 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.
int numGenerations | ( | ) |
Return the number of Generations.
Definition at line 96 of file geneticalgo.cpp.
References GeneticAlgo::numGens.
Referenced by StefanoSteadyStateGA::save(), SimpleGA::save(), NSGA2::save(), ParallelGA::save(), and LaralGA::save().
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(), NSGA2::gaStep(), SimpleGA::gaStep(), ParallelGA::gaStep(), LaralGA::gaStep(), StefanoSteadyStateGA::initialize(), SimpleGA::initialize(), NSGA2::initialize(), ParallelGA::initialize(), and LaralGA::initialize().
void setGenome | ( | Genome * | gen | ) |
Set the Genome to use as current population.
Definition at line 66 of file geneticalgo.cpp.
References GeneticAlgo::genomev.
Referenced by StefanoSteadyStateGA::configure(), NSGA2::configure(), SimpleGA::configure(), ParallelGA::configure(), LaralGA::configure(), NSGA2::gaStep(), SimpleGA::gaStep(), and ParallelGA::gaStep().
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(), NSGA2::configure(), ParallelGA::configure(), and LaralGA::configure().
|
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, ParallelGA, NSGA2, 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.
|
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(), NSGA2::gaStep(), ParallelGA::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
|
protected |
Statistical Data: report the Average value for each objective for each generation.
Definition at line 157 of file geneticalgo.h.
Referenced by GeneticAlgo::averageFits(), and GeneticAlgo::updateStats().
|
protected |
Statistical Data: report the Best value for each objective for each generation.
Definition at line 155 of file geneticalgo.h.
Referenced by GeneticAlgo::bestFits(), and GeneticAlgo::updateStats().
|
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 145 of file geneticalgo.h.
Referenced by GeneticAlgo::evolve(), StefanoSteadyStateGA::gaStep(), NSGA2::gaStep(), SimpleGA::gaStep(), ParallelGA::gaStep(), LaralGA::gaStep(), StefanoSteadyStateGA::initialize(), SimpleGA::initialize(), NSGA2::initialize(), ParallelGA::initialize(), LaralGA::initialize(), GeneticAlgo::isEvaluationDone(), StefanoSteadyStateGA::skipEvaluation(), SimpleGA::skipEvaluation(), NSGA2::skipEvaluation(), ParallelGA::skipEvaluation(), and LaralGA::skipEvaluation().
|
protected |
setted by implementors to signal the finish of evolution process
when true means that evolution is ended
Definition at line 136 of file geneticalgo.h.
Referenced by StefanoSteadyStateGA::finalize(), NSGA2::finalize(), SimpleGA::finalize(), ParallelGA::finalize(), LaralGA::finalize(), StefanoSteadyStateGA::initialize(), NSGA2::initialize(), SimpleGA::initialize(), ParallelGA::initialize(), LaralGA::initialize(), and GeneticAlgo::isEvolutionEnded().
|
protected |
current generation
Definition at line 150 of file geneticalgo.h.
Referenced by GeneticAlgo::evolve(), GeneticAlgo::generation(), GeneticAlgo::setGeneration(), and GeneticAlgo::updateStats().
|
protected |
current genome
Definition at line 148 of file geneticalgo.h.
Referenced by GeneticAlgo::genome(), GeneticAlgo::setGenome(), LaralGA::setReproduceParams(), GeneticAlgo::updateStats(), and GeneticAlgo::~GeneticAlgo().
|
protected |
Statistical Data: report the mean of all hamming distance between genotypes for each generation.
Definition at line 159 of file geneticalgo.h.
Referenced by GeneticAlgo::meanHammingDist(), and GeneticAlgo::updateStats().
|
protected |
number of generations
Definition at line 152 of file geneticalgo.h.
Referenced by StefanoSteadyStateGA::gaStep(), NSGA2::gaStep(), SimpleGA::gaStep(), ParallelGA::gaStep(), LaralGA::gaStep(), LaralGA::LaralGA(), NSGA2::NSGA2(), GeneticAlgo::numGenerations(), ParallelGA::ParallelGA(), GeneticAlgo::setNumGenerations(), SimpleGA::SimpleGA(), SimpleGA::skipEvaluation(), NSGA2::skipEvaluation(), ParallelGA::skipEvaluation(), and LaralGA::skipEvaluation().
|
protected |
Statistical Data: report the standard variation of all hamming distance between genotypes for each generation.
Definition at line 163 of file geneticalgo.h.
Referenced by GeneticAlgo::standardDeviationHammingDist(), and GeneticAlgo::updateStats().
|
protected |
Statistical Data: report the variance of all hamming distance between genotypes for each generation.
Definition at line 161 of file geneticalgo.h.
Referenced by GeneticAlgo::updateStats(), and GeneticAlgo::varianceHammingDist().
The documentation for this class was generated from the following files:
- ga/include/core/geneticalgo.h
- ga/src/core/geneticalgo.cpp