Genetic Algorithm Common Interface. More...

Public Member Functions | |
GeneticAlgo () | |
Constructor. | |
virtual | ~GeneticAlgo () |
Destructor. | |
void | addObserver (GeneticAlgoObserver *observer) |
add the observer to the list of current observers | |
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. | |
GeneticAlgoIODelegate * | getIODelegate () const |
Return the current GeneticAlgoIODelegate. | |
ParameterSettableUI * | getUIManager () |
return the UI Manager for accessing to the viewers of GeneticAlgo | |
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 | removeObserver (GeneticAlgoObserver *observer) |
remove the observer from the list of current observers | |
void | setGeneration (unsigned int gen) |
Set the generation number. | |
void | setGenome (Genome *gen) |
Set the Genome to use as current population. | |
void | setIODelegate (GeneticAlgoIODelegate *iodelegate) |
Set the GeneticAlgoIODelegate to use. | |
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) |
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 |
Protected Member Functions | |
void | notifyEndGeneration () |
notify that a generation has been done | |
void | updateStats () |
Update statistical data of current generation and Genome (Mean, Variance, Standard Deviation) | |
![]() | |
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 | |
GeneticAlgoIODelegate * | iodelegate |
the IODelegate | |
QVector< double > | meanHdists |
Statistical Data: report the mean of all hamming distance between genotypes for each generation. | |
unsigned int | numGens |
number of generations | |
QList< GeneticAlgoObserver * > | observers |
the List of Observers | |
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 78 of file geneticalgo.h.
Constructor & Destructor Documentation
GeneticAlgo | ( | ) |
Constructor.
Definition at line 28 of file geneticalgo.cpp.
|
virtual |
Member Function Documentation
void addObserver | ( | GeneticAlgoObserver * | observer | ) |
add the observer to the list of current observers
Definition at line 52 of file geneticalgo.cpp.
References GeneticAlgo::observers.
Referenced by GeneticAlgoUI::GeneticAlgoUI().
QVector< QVector< double > > averageFits | ( | ) | const |
Return the Average objective values over generation done.
Definition at line 120 of file geneticalgo.cpp.
References GeneticAlgo::avgfits.
Referenced by GeneticAlgoUI::onEndGeneration().
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 116 of file geneticalgo.cpp.
References GeneticAlgo::bestfits.
Referenced by GeneticAlgoUI::onEndGeneration().
|
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 61 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 68 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 104 of file geneticalgo.cpp.
References GeneticAlgo::generationv.
Referenced by StefanoSteadyStateGA::gaStep(), NSGA2::gaStep(), SimpleGA::gaStep(), ParallelGA::gaStep(), LaralGA::gaStep(), StefanoSteadyStateGA::initialize(), NSGA2::initialize(), ParallelGA::initialize(), LaralGA::initialize(), Mutation::mutationRate(), Mutation::setMutationRate(), SimpleGA::skipEvaluation(), NSGA2::skipEvaluation(), ParallelGA::skipEvaluation(), and LaralGA::skipEvaluation().
Genome * genome | ( | ) |
Return the current Genome.
Definition at line 86 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 90 of file geneticalgo.cpp.
References GeneticAlgo::genomev.
GeneticAlgoIODelegate * getIODelegate | ( | ) | const |
Return the current GeneticAlgoIODelegate.
Definition at line 143 of file geneticalgo.cpp.
References GeneticAlgo::iodelegate.
Referenced by StefanoSteadyStateGA::gaStep(), NSGA2::gaStep(), SimpleGA::gaStep(), ParallelGA::gaStep(), LaralGA::gaStep(), StefanoSteadyStateGA::initialize(), SimpleGA::initialize(), NSGA2::initialize(), ParallelGA::initialize(), and LaralGA::initialize().
|
virtual |
return the UI Manager for accessing to the viewers of GeneticAlgo
Reimplemented from ParameterSettableWithConfigureFunction.
Definition at line 48 of file geneticalgo.cpp.
|
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 78 of file geneticalgo.cpp.
References GeneticAlgo::evaluationDone.
bool isEvolutionEnded | ( | ) |
returns true if the evolution process has reached the end
Definition at line 74 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 124 of file geneticalgo.cpp.
References GeneticAlgo::meanHdists.
|
protected |
notify that a generation has been done
Definition at line 200 of file geneticalgo.cpp.
References GeneticAlgo::observers, and GeneticAlgoObserver::onEndGeneration().
Referenced by StefanoSteadyStateGA::gaStep(), SimpleGA::gaStep(), NSGA2::gaStep(), ParallelGA::gaStep(), and LaralGA::gaStep().
int numGenerations | ( | ) |
Return the number of Generations.
Definition at line 112 of file geneticalgo.cpp.
References GeneticAlgo::numGens.
Referenced by StefanoSteadyStateGA::save(), SimpleGA::save(), NSGA2::save(), ParallelGA::save(), and LaralGA::save().
void removeObserver | ( | GeneticAlgoObserver * | observer | ) |
remove the observer from the list of current observers
Definition at line 57 of file geneticalgo.cpp.
References GeneticAlgo::observers.
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 94 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 82 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 setIODelegate | ( | GeneticAlgoIODelegate * | iodelegate | ) |
Set the GeneticAlgoIODelegate to use.
- Warning
- it will not take the owership, so it will be no destroyed by the GeneticAlgo object
Definition at line 139 of file geneticalgo.cpp.
References GeneticAlgo::iodelegate.
void setNumGenerations | ( | int | g | ) |
Set the number of Generations to do.
Definition at line 108 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 132 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 147 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 128 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 206 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 204 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 191 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 182 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 199 of file geneticalgo.h.
Referenced by GeneticAlgo::evolve(), GeneticAlgo::generation(), GeneticAlgo::setGeneration(), and GeneticAlgo::updateStats().
|
protected |
current genome
Definition at line 197 of file geneticalgo.h.
Referenced by GeneticAlgo::genome(), GeneticAlgo::setGenome(), LaralGA::setReproduceParams(), GeneticAlgo::updateStats(), and GeneticAlgo::~GeneticAlgo().
|
protected |
the IODelegate
Definition at line 215 of file geneticalgo.h.
Referenced by GeneticAlgo::getIODelegate(), and GeneticAlgo::setIODelegate().
|
protected |
Statistical Data: report the mean of all hamming distance between genotypes for each generation.
Definition at line 208 of file geneticalgo.h.
Referenced by GeneticAlgo::meanHammingDist(), and GeneticAlgo::updateStats().
|
protected |
number of generations
Definition at line 201 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 |
the List of Observers
Definition at line 217 of file geneticalgo.h.
Referenced by GeneticAlgo::addObserver(), GeneticAlgo::notifyEndGeneration(), and GeneticAlgo::removeObserver().
|
protected |
Statistical Data: report the standard variation of all hamming distance between genotypes for each generation.
Definition at line 212 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 210 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