LaralGA Class Reference
Common FARSA setup of GA. More...

Classes | |
class | evaluationThread |
Public Member Functions | |
LaralGA () | |
Constructor. | |
virtual | ~LaralGA () |
Destructor. | |
virtual void | configure (ConfigurationParameters ¶ms, QString prefix) |
Configure the object using the ConfigurationParameters specified. | |
virtual QVector< Evaluation * > | evaluationPool () |
Return the Evaluation Pool containing the Evaluations used. | |
virtual Evaluation * | evaluationPrototype () |
Returns the Evaluation object used as prototype to eventually generate other evaluators. | |
virtual void | finalize () |
Finalize the Genetic Algorithm Process. | |
MultiTrials * | fitnessFunction () |
Return the fitness function. | |
virtual void | gaStep () |
Execute a single minor step and return. | |
virtual void | initialize () |
Initialize the Genetic Algorithm Process:
| |
bool | isElitismEnabled () |
Return true if elitism is enabled. | |
Mutation * | mutation () |
Return the Mutation operator. | |
int | numElitism () |
Return the number of elited Genotypes. | |
int | numOffspring () |
Return the number of offspring for each selected Genotype. | |
int | numReproducing () |
Return the number of selected Genotypes. | |
int | numThreads () |
Return the number of thread currently used. | |
virtual void | save (ConfigurationParameters ¶ms, QString prefix) |
Save the actual status of parameters into the ConfigurationParameters object passed. | |
void | setFitnessFunction (MultiTrials *fitfunc) |
Set the fitness function to use. | |
void | setMutation (Mutation *mutate) |
Set the Mutation operator to use. | |
void | setNumThreads (int numThreads) |
Set the number of thread to use; or in other words the number of parallel evaluation of Genotypes. | |
void | setReproduceParams (int nreproducing, bool useElitism=false, int nelitism=0) |
Set Reproducing parameters | |
virtual void | skipEvaluation () |
Skip the evaluation phase and put the algorithm in the state just after the evaluation. | |
Static Public Member Functions | |
static void | describe (QString type) |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups. | |
Protected Types | |
enum | GAPhases { initEvaluation, evaluating, nextGeneration_pass1, nextGeneration_pass2, endEvolution } |
used for manage GA cycle More... | |
Protected Attributes | |
unsigned int | currGenotype |
current Genotype in evaluation | |
GAPhases | currPhase |
current Phase | |
bool | elitismEnabled |
true is elitism is enabled | |
MultiTrials * | fitfunc |
fitness function | |
bool | isFinalized |
True if LaralGA is finalized. | |
bool | isInitialized |
True if LaralGA is initialized. | |
Mutation * | muta |
mutation operator | |
int | nelitism |
number of elited genotypes | |
int | noffspring |
number of offspring | |
int | nreproducing |
number of selected genotypes |
Detailed Description
Common FARSA setup of GA.
- Description
- This GA implements the common characteristics of FARSA setup:
- Rank Selection with Truncation
- Use MultiTrials mechanism for Evaluating the Fitness of a Genotype
- Possibility to set one of Mutations availables (or a custom one)
- No Crossover
- Warnings
Member Enumeration Documentation
Constructor & Destructor Documentation
LaralGA | ( | ) |
Constructor.
Definition at line 31 of file laralga.cpp.
References LaralGA::currGenotype, LaralGA::currPhase, LaralGA::elitismEnabled, LaralGA::fitfunc, LaralGA::isFinalized, LaralGA::isInitialized, LaralGA::muta, LaralGA::nelitism, LaralGA::noffspring, LaralGA::nreproducing, and GeneticAlgo::numGens.
~LaralGA | ( | ) | [virtual] |
Destructor.
Definition at line 47 of file laralga.cpp.
Member Function Documentation
void configure | ( | ConfigurationParameters & | params, |
QString | prefix | ||
) | [virtual] |
Configure the object using the ConfigurationParameters specified.
- Parameters:
-
params the object with configuration parameters prefix the group in which parameters are expected to be (this is terminated by a separator character). We expect to receive as prefix the group which contains all GA parameters
Implements ParameterSettableWithConfigureFunction.
Definition at line 51 of file laralga.cpp.
References LaralGA::fitfunc, GeneticAlgo::genome(), ConfigurationParameters::getObjectFromGroup(), ConfigurationParameters::getValue(), ConfigurationParameters::GroupSeparator(), LaralGA::nelitism, GeneticAlgo::numGenerations(), LaralGA::setFitnessFunction(), Evaluation::setGenome(), GeneticAlgo::setGenome(), LaralGA::setMutation(), GeneticAlgo::setNumGenerations(), LaralGA::setNumThreads(), and LaralGA::setReproduceParams().
void describe | ( | QString | type | ) | [static] |
Add to Factory::typeDescriptions() the descriptions of all parameters and subgroups.
Reimplemented from ParameterSettable.
Definition at line 84 of file laralga.cpp.
References ParameterSettable::addTypeDescription(), ParameterSettable::BoolDescriptor::def(), ParameterSettable::IntDescriptor::def(), ParameterSettable::SubgroupDescriptor::describeBool(), ParameterSettable::SubgroupDescriptor::describeInt(), ParameterSettable::Descriptor::describeInt(), ParameterSettable::SubgroupDescriptor::describeSubgroup(), ParameterSettable::Descriptor::describeSubgroup(), ParameterSettable::BoolDescriptor::help(), ParameterSettable::SubgroupDescriptor::help(), ParameterSettable::IntDescriptor::help(), ParameterSettable::IsMandatory, ParameterSettable::IntDescriptor::limits(), ParameterSettable::SubgroupDescriptor::props(), ParameterSettable::IntDescriptor::props(), and ParameterSettable::SubgroupDescriptor::type().
QVector< Evaluation * > evaluationPool | ( | ) | [virtual] |
Return the Evaluation Pool containing the Evaluations used.
Implements GeneticAlgo.
Definition at line 125 of file laralga.cpp.
Evaluation * evaluationPrototype | ( | ) | [virtual] |
Returns the Evaluation object used as prototype to eventually generate other evaluators.
This object could be or could be not used to compute the fitness of genotypes (depending on the specific genetic algorithm)
Implements GeneticAlgo.
Definition at line 120 of file laralga.cpp.
References LaralGA::fitfunc.
void finalize | ( | ) | [virtual] |
Finalize the Genetic Algorithm Process.
Implements GeneticAlgo.
Definition at line 277 of file laralga.cpp.
References GeneticAlgo::evolutionEnd, LaralGA::isFinalized, and LaralGA::isInitialized.
Referenced by LaralGA::gaStep().
MultiTrials * fitnessFunction | ( | ) |
Return the fitness function.
Definition at line 133 of file laralga.cpp.
References LaralGA::fitfunc.
Referenced by LaralGA::save().
void gaStep | ( | ) | [virtual] |
Execute a single minor step and return.
Implements GeneticAlgo.
Definition at line 206 of file laralga.cpp.
References LaralGA::currPhase, GeneticAlgo::evaluationDone, LaralGA::finalize(), GeneticAlgo::generation(), GeneticAlgo::genome(), GeneticAlgo::numGens, Genotype::rankGreaterThanComparator(), GeneticAlgo::setGeneration(), Genome::size(), and GeneticAlgo::updateStats().
void initialize | ( | ) | [virtual] |
Initialize the Genetic Algorithm Process:
- set current replication to zero
- set current generation to zero.
Implements GeneticAlgo.
Definition at line 178 of file laralga.cpp.
References LaralGA::currGenotype, LaralGA::currPhase, GeneticAlgo::evaluationDone, GeneticAlgo::evolutionEnd, LaralGA::fitfunc, LaralGA::isFinalized, LaralGA::isInitialized, LaralGA::muta, and GeneticAlgo::setGeneration().
bool isElitismEnabled | ( | ) |
Return true if elitism is enabled.
Definition at line 174 of file laralga.cpp.
References LaralGA::elitismEnabled.
Referenced by LaralGA::save().
Mutation * mutation | ( | ) |
Return the Mutation operator.
Definition at line 142 of file laralga.cpp.
References LaralGA::muta.
Referenced by LaralGA::save().
int numElitism | ( | ) |
Return the number of elited Genotypes.
Definition at line 170 of file laralga.cpp.
References LaralGA::nelitism.
Referenced by LaralGA::save().
int numOffspring | ( | ) |
Return the number of offspring for each selected Genotype.
Definition at line 166 of file laralga.cpp.
References LaralGA::noffspring.
int numReproducing | ( | ) |
Return the number of selected Genotypes.
Definition at line 162 of file laralga.cpp.
References LaralGA::nreproducing.
Referenced by LaralGA::save().
int numThreads | ( | ) |
Return the number of thread currently used.
Definition at line 111 of file laralga.cpp.
Referenced by LaralGA::save(), and LaralGA::setNumThreads().
void save | ( | ConfigurationParameters & | params, |
QString | prefix | ||
) | [virtual] |
Save the actual status of parameters into the ConfigurationParameters object passed.
- Parameters:
-
params the configuration parameters object on which save actual parameters prefix the prefix to use to access the object configuration parameters.
Implements ParameterSettable.
Definition at line 68 of file laralga.cpp.
References ConfigurationParameters::createParameter(), ConfigurationParameters::createSubGroup(), LaralGA::fitnessFunction(), GeneticAlgo::genome(), LaralGA::isElitismEnabled(), LaralGA::mutation(), LaralGA::numElitism(), GeneticAlgo::numGenerations(), LaralGA::numReproducing(), LaralGA::numThreads(), Genome::save(), Mutation::save(), and MultiTrials::save().
void setFitnessFunction | ( | MultiTrials * | fitfunc | ) |
Set the fitness function to use.
Definition at line 115 of file laralga.cpp.
References LaralGA::fitfunc, and Evaluation::setGA().
Referenced by LaralGA::configure().
void setMutation | ( | Mutation * | mutate | ) |
Set the Mutation operator to use.
Definition at line 137 of file laralga.cpp.
References LaralGA::muta, and Mutation::setGA().
Referenced by LaralGA::configure().
void setNumThreads | ( | int | numThreads | ) |
Set the number of thread to use; or in other words the number of parallel evaluation of Genotypes.
Definition at line 97 of file laralga.cpp.
References LaralGA::fitfunc, LaralGA::isFinalized, LaralGA::isInitialized, and LaralGA::numThreads().
Referenced by LaralGA::configure().
void setReproduceParams | ( | int | nreproducing, |
bool | useElitism = false , |
||
int | nelitism = 0 |
||
) |
Set Reproducing parameters
- Note:
- The number of offsprings are automatically calculated dividing nreproducinb by Genome::size()
- Parameters:
-
nreproducing is the number of Genotypes to select useElitism if true use elitism, othersiwe not nelitism is the number of Genotypes selected to copy unthouched to next generation
Definition at line 146 of file laralga.cpp.
References LaralGA::elitismEnabled, GeneticAlgo::genomev, LaralGA::nelitism, LaralGA::noffspring, LaralGA::nreproducing, and Genome::size().
Referenced by LaralGA::configure().
void skipEvaluation | ( | ) | [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.
Implements GeneticAlgo.
Definition at line 267 of file laralga.cpp.
References LaralGA::currPhase, GeneticAlgo::evaluationDone, GeneticAlgo::generation(), and GeneticAlgo::numGens.
Member Data Documentation
unsigned int currGenotype [protected] |
current Genotype in evaluation
Definition at line 126 of file laralga.h.
Referenced by LaralGA::initialize(), and LaralGA::LaralGA().
current Phase
Definition at line 138 of file laralga.h.
Referenced by LaralGA::gaStep(), LaralGA::initialize(), LaralGA::LaralGA(), and LaralGA::skipEvaluation().
bool elitismEnabled [protected] |
true is elitism is enabled
Definition at line 134 of file laralga.h.
Referenced by LaralGA::isElitismEnabled(), LaralGA::LaralGA(), and LaralGA::setReproduceParams().
MultiTrials* fitfunc [protected] |
fitness function
Definition at line 122 of file laralga.h.
Referenced by LaralGA::configure(), LaralGA::evaluationPrototype(), LaralGA::fitnessFunction(), LaralGA::initialize(), LaralGA::LaralGA(), LaralGA::setFitnessFunction(), and LaralGA::setNumThreads().
bool isFinalized [protected] |
True if LaralGA is finalized.
Definition at line 142 of file laralga.h.
Referenced by LaralGA::finalize(), LaralGA::initialize(), LaralGA::LaralGA(), and LaralGA::setNumThreads().
bool isInitialized [protected] |
True if LaralGA is initialized.
Definition at line 140 of file laralga.h.
Referenced by LaralGA::finalize(), LaralGA::initialize(), LaralGA::LaralGA(), and LaralGA::setNumThreads().
mutation operator
Definition at line 124 of file laralga.h.
Referenced by LaralGA::initialize(), LaralGA::LaralGA(), LaralGA::mutation(), and LaralGA::setMutation().
int nelitism [protected] |
number of elited genotypes
Definition at line 132 of file laralga.h.
Referenced by LaralGA::configure(), LaralGA::LaralGA(), LaralGA::numElitism(), and LaralGA::setReproduceParams().
int noffspring [protected] |
number of offspring
Definition at line 130 of file laralga.h.
Referenced by LaralGA::LaralGA(), LaralGA::numOffspring(), and LaralGA::setReproduceParams().
int nreproducing [protected] |
number of selected genotypes
Definition at line 128 of file laralga.h.
Referenced by LaralGA::LaralGA(), LaralGA::numReproducing(), and LaralGA::setReproduceParams().
The documentation for this class was generated from the following files:
- ga/include/gas/laralga.h
- ga/src/gas/laralga.cpp