Inheritance diagram for Purple::GeneticAlgorithm:
Definition at line 30 of file GeneticAlgorithm.h.
Enumeration of the available training operators for fitness assignment.
Definition at line 39 of file GeneticAlgorithm.h.
Enumeration of the available training operators for selection.
Definition at line 43 of file GeneticAlgorithm.h.
Enumeration of the available training operators for recombination.
Definition at line 47 of file GeneticAlgorithm.h.
Enumeration of the available training operators for mutation.
Definition at line 51 of file GeneticAlgorithm.h.
Purple::GeneticAlgorithm::GeneticAlgorithm | ( | ObjectiveFunction * | newObjectiveFunction | ) |
General constructor. It creates a genetic training algorithm object associated to a performance functional object. It also initializes the class members to their default values:
Training operators:
Training parameters:
Stopping criteria:
User stuff:
newPerformanceFunctional,: | Pointer to a performance functional object. |
Definition at line 62 of file GeneticAlgorithm.cpp.
Purple::GeneticAlgorithm::GeneticAlgorithm | ( | void | ) |
Default constructor. It creates a genetic training algorithm object not associated to any performance functional object. It also initializes the class members to their default values:
Training operators:
Training parameters:
Stopping criteria:
User stuff:
Definition at line 175 of file GeneticAlgorithm.cpp.
Purple::GeneticAlgorithm::~GeneticAlgorithm | ( | void | ) | [virtual] |
int Purple::GeneticAlgorithm::getPopulationSize | ( | void | ) |
This method returns the number of individuals in the population.
Definition at line 231 of file GeneticAlgorithm.cpp.
Matrix< double > Purple::GeneticAlgorithm::getPopulation | ( | void | ) |
Vector< double > Purple::GeneticAlgorithm::getEvaluation | ( | void | ) |
This method returns the actual performance value of all individuals in the population.
Definition at line 419 of file GeneticAlgorithm.cpp.
Vector< double > Purple::GeneticAlgorithm::getFitness | ( | void | ) |
This method returns the actual fitness value of all individuals in the population.
Definition at line 432 of file GeneticAlgorithm.cpp.
Vector< bool > Purple::GeneticAlgorithm::getSelection | ( | void | ) |
This method returns the actual selection value of all individuals in the population.
Definition at line 445 of file GeneticAlgorithm.cpp.
double Purple::GeneticAlgorithm::getSelectivePressure | ( | void | ) |
This method returns the selective pressure value.
Definition at line 605 of file GeneticAlgorithm.cpp.
double Purple::GeneticAlgorithm::getRecombinationSize | ( | void | ) |
This method returns the recombination size value.
Definition at line 618 of file GeneticAlgorithm.cpp.
double Purple::GeneticAlgorithm::getMutationRate | ( | void | ) |
double Purple::GeneticAlgorithm::getMutationRange | ( | void | ) |
int Purple::GeneticAlgorithm::getMaximumNumberOfGenerations | ( | void | ) |
int Purple::GeneticAlgorithm::getShowPeriod | ( | void | ) |
Vector< double > Purple::GeneticAlgorithm::getMeanEvaluationHistory | ( | void | ) |
This method returns a history with the mean performance of the population during training.
getStandardDeviationOfPerformanceTrainingHistory(void).
Definition at line 294 of file GeneticAlgorithm.cpp.
Vector< double > Purple::GeneticAlgorithm::getStandardDeviationEvaluationHistory | ( | void | ) |
This method returns a history with the standard deviation of the population performance during training.
getMeanPerformanceTrainingHistory(void).
Definition at line 308 of file GeneticAlgorithm.cpp.
Vector< double > Purple::GeneticAlgorithm::getBestEvaluationHistory | ( | void | ) |
This method returns a history with the performance of the best individual ever during training.
getStandardDeviationOfPerformanceTrainingHistory(void).
Definition at line 321 of file GeneticAlgorithm.cpp.
GeneticAlgorithm::FitnessAssignmentMethod Purple::GeneticAlgorithm::getFitnessAssignmentMethod | ( | void | ) |
This method returns the fitness assignment method used for training.
performNonLinearRankingFitnessAssignment(void).
train(void).
Definition at line 659 of file GeneticAlgorithm.cpp.
GeneticAlgorithm::SelectionMethod Purple::GeneticAlgorithm::getSelectionMethod | ( | void | ) |
This method returns the selection method used for training.
performStochasticUniversalSamplingSelection(void).
train(void).
Definition at line 673 of file GeneticAlgorithm.cpp.
GeneticAlgorithm::RecombinationMethod Purple::GeneticAlgorithm::getRecombinationMethod | ( | void | ) |
This method returns the recombination method used for training.
performLineRecombination(void).
train(void).
Definition at line 687 of file GeneticAlgorithm.cpp.
GeneticAlgorithm::MutationMethod Purple::GeneticAlgorithm::getMutationMethod | ( | void | ) |
This method returns the mutation method used for training.
train(void).
Definition at line 701 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setPopulationSize | ( | int | newPopulationSize | ) |
This method sets a new population with a new number of individuals. The new population size must be an even number equal or greater than four.
newPopulationSize,: | Number of individuals in the population. This must be an even number equal or greater than four. |
Definition at line 335 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setPopulation | ( | Matrix< double > | newPopulation | ) |
This method sets a new population.
newPopulation,: | Population Matrix. |
Definition at line 457 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setEvaluation | ( | Vector< double > | newEvaluation | ) |
This method sets a new population performance Vector.
newPerformance,: | Population performance values. |
Definition at line 494 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setFitness | ( | Vector< double > | newFitness | ) |
This method sets a new population fitness Vector.
newFitness,: | Population fitness values. |
Definition at line 516 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setSelection | ( | Vector< bool > | newSelection | ) |
This method sets a new population selection Vector.
newSelection,: | Population selection values. |
Definition at line 539 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setSelectivePressure | ( | double | newSelectivePressure | ) |
This method sets a new value for the selective pressure parameter. Linear ranking allows values for the selective pressure between 1 and 2. Non linear ranking allows values for the selective pressure between 1 and [population size] - 2.
newSelectivePressure,: | Selective pressure value. This must be between 1 and 2 for linear ranking fitness assignment and between 1 1 and [population size] - 2 for non linear ranking fitness assignment. |
Definition at line 721 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setRecombinationSize | ( | double | newRecombinationSize | ) |
This method sets a new value for the recombination size parameter. The recombination size value must be equal or greater than 0.
newRecombinationSize,: | Recombination size value. This must be equal or greater than 0. |
Definition at line 775 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setMutationRate | ( | double | newMutationRate | ) |
This method sets a new value for the mutation rate parameter. The mutation rate value must be between 0 and 1.
newMutationRate,: | Mutation rate value. This must be equal or greater than 0 less or equal to 1. |
Definition at line 802 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setMutationRange | ( | double | newMutationRange | ) |
This method sets a new value for the mutation range parameter. The mutation range value must be 0 or a positive number.
newMutationRange,: | Mutation range value. This must be equal or greater than 0. |
Definition at line 828 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setFitnessAssignmentMethod | ( | GeneticAlgorithm::FitnessAssignmentMethod | newFitnessAssignmentMethod | ) |
This method sets a new fitness assignment method to be used for training.
newFitnessAssignmentMethod,: | Fitness assignment method chosen for training. |
Definition at line 854 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setSelectionMethod | ( | GeneticAlgorithm::SelectionMethod | newSelectionMethod | ) |
This method sets a new selection method to be used for training.
newSelectionMethod,: | Selection method chosen for training. |
Definition at line 870 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setRecombinationMethod | ( | GeneticAlgorithm::RecombinationMethod | newRecombinationMethod | ) |
This method sets a new recombination method to be used for training.
newRecombinationMethod,: | Recombination method chosen for training. |
Definition at line 886 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setMutationMethod | ( | GeneticAlgorithm::MutationMethod | newMutationMethod | ) |
This method sets a new mutation method to be used for training.
newMutationMethod,: | Mutation method chosen for training. |
Definition at line 903 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setMaximumNumberOfGenerations | ( | int | ) |
Definition at line 240 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setShowPeriod | ( | int | newShowPeriod | ) |
This method sets a new number of iterations between the optimization showing progress.
newIterationsBetweenShowingProgress,: | Number of iterations between the optimization showing progress. |
Definition at line 268 of file GeneticAlgorithm.cpp.
Vector< double > Purple::GeneticAlgorithm::getIndividual | ( | int | i | ) |
This method returns the Vector of free parameters corresponding to the individual i in the population.
i,: | Index of individual in the population. |
Definition at line 563 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::setIndividual | ( | int | i, | |
Vector< double > | individual | |||
) |
This method sets a new Vector of free parameters to the individual i in the population.
i,: | Index of individual in the population. | |
individual,: | Vector of free parameters to be assigned to individual i. |
Definition at line 585 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::initPopulationAtRandom | ( | void | ) |
This method initializes all the individuals in the population at random, with values comprised between -1 and 1.
Definition at line 918 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::initPopulationAtRandom | ( | double | minimumValue, | |
double | maximumValue | |||
) |
This method initializes all the individuals in the population at random, with values comprised between a minimum and a maximum value.
minimumValue,: | Minimum initialization value. | |
maximumValue,: | Maximum initialization value. |
Definition at line 953 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::initPopulationAtRandom | ( | Vector< double > | minimumValue, | |
Vector< double > | maximumValue | |||
) |
This method initializes the free parameters of all the individuals in the population at random, with values comprised between different minimum and maximum values for each variable.
minimumValue,: | Minimum initialization value. | |
maximumValue,: | Maximum initialization value. |
Definition at line 988 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::initPopulationAtRandom | ( | Matrix< double > | minimumAndMaximumValues | ) |
This method initializes the free parameters of all the individuals in the population at random, with values comprised between different minimum and maximum values for each variable and from a single Matrix.
minimumAndMaximumValues,: | Minimum and maximum initialization values. |
Definition at line 1036 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::evaluatePopulation | ( | void | ) |
This method evaluates the performance of all individuals in the population. Results are stored in the performance Vector.
Definition at line 1090 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::performLinearRankingFitnessAssignment | ( | void | ) |
This method ranks all individuals in the population by their performance, so that the least fit individual has rank 1 and the fittest individual has rank [population size]. It then assigns them a fitness value linearly proportional to their rank. Results are stored in the fitness Vector.
train(void).
Definition at line 1118 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::performNonLinearRankingFitnessAssignment | ( | void | ) |
This method ranks all individuals in the population by their performance, so that the least fit individual has rank 1 and the fittest individual has rank population size. Please, do not use this method. It is not yet implemented.
train(void).
Definition at line 1163 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::performRouletteWheelSelection | ( | void | ) |
This metod performs selection with roulette wheel selection. It selects half of the individuals from the population. Results are stored in the selection Vector.
train(void).
Definition at line 1226 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::performStochasticUniversalSamplingSelection | ( | void | ) |
This metod performs selection with stochastic universal sampling. It selects half of the individuals from the population. Results are stored in the selection vector.
train(void).
Definition at line 1310 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::performIntermediateRecombination | ( | void | ) |
This method performs intermediate recombination between pairs of selected individuals to generate a new population. Each selected individual is to be recombined with two other selected individuals chosen at random. Results are stored in the population matrix.
performLineRecombination(void).
train(void).
Definition at line 1401 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::performLineRecombination | ( | void | ) |
This method performs line recombination between pairs of selected individuals to generate a new population. Each selected individual is to be recombined with two other selected individuals chosen at random. Results are stored in the population matrix.
performIntermediateRecombination(void).
train(void).
Definition at line 1519 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::performNormalMutation | ( | void | ) |
This method performs normal mutation to all individuals in order to generate a new population. It uses the Box-Muller transformation to generate random numbers with normal distribution. Results are stored in the population matrix.
train(void).
Definition at line 1640 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::performUniformMutation | ( | void | ) |
This method performs uniform mutation to all individuals in order to generate a new population. Results are stored in the population matrix.
train(void).
Definition at line 1697 of file GeneticAlgorithm.cpp.
Vector< double > Purple::GeneticAlgorithm::getMinimalArgument | ( | void | ) | [virtual] |
This method trains a multilayer perceptron with an associated performance function according to the genetic algorithm. Training occurs according to the training operators and their related parameters.
Implements Purple::OptimizationAlgorithm.
Definition at line 1743 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::print | ( | void | ) |
This method prints to the screen the members of the genetic algorithm object.
Training operators:
Training parameters:
Stopping criteria:
User stuff:
Definition at line 2041 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::load | ( | char * | filename | ) |
This method loads a genetic algorithm object from a data file. Please mind about the file format, wich is specified in the User's Guide.
Training operators:
Training parameters:
Stopping criteria:
User stuff:
filename,: | Filename. |
Definition at line 2375 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::save | ( | char * | filename | ) |
This method saves the genetic algorithm object to a data file.
Training operators:
Training parameters:
Stopping criteria:
User stuff:
filename,: | Filename. |
Definition at line 2201 of file GeneticAlgorithm.cpp.
void Purple::GeneticAlgorithm::saveOptimizationHistory | ( | char * | filename | ) |
This method saves the training history to a data file:
filename,: | Filename. |
Definition at line 2594 of file GeneticAlgorithm.cpp.
int Purple::GeneticAlgorithm::populationSize [private] |
Matrix<double> Purple::GeneticAlgorithm::population [private] |
Vector<double> Purple::GeneticAlgorithm::evaluation [private] |
Vector<double> Purple::GeneticAlgorithm::fitness [private] |
Vector<bool> Purple::GeneticAlgorithm::selection [private] |
double Purple::GeneticAlgorithm::selectivePressure [private] |
Selective pressure. Linear ranking allows values for the selective pressure between 1 and 2. Non linear ranking allows values for the selective pressure between 1 and [population size] - 2.
Definition at line 85 of file GeneticAlgorithm.h.
double Purple::GeneticAlgorithm::recombinationSize [private] |
Recombination size. The recombination size value must be equal or greater than 0.
Definition at line 90 of file GeneticAlgorithm.h.
double Purple::GeneticAlgorithm::mutationRate [private] |
Mutation rate. The mutation rate value must be between 0 and 1.
Definition at line 95 of file GeneticAlgorithm.h.
double Purple::GeneticAlgorithm::mutationRange [private] |
Mutation range. The mutation range value must be 0 or a positive number.
Definition at line 100 of file GeneticAlgorithm.h.
int Purple::GeneticAlgorithm::maximumNumberOfGenerations [private] |
Definition at line 104 of file GeneticAlgorithm.h.
int Purple::GeneticAlgorithm::showPeriod [private] |
Definition at line 106 of file GeneticAlgorithm.h.
Vector<double> Purple::GeneticAlgorithm::meanEvaluationHistory [private] |
Vector<double> Purple::GeneticAlgorithm::standardDeviationEvaluationHistory [private] |
Standard deviation of performance training history.
Definition at line 114 of file GeneticAlgorithm.h.
Vector<double> Purple::GeneticAlgorithm::bestEvaluationHistory [private] |
Fitness assignment training operators enumeration.
Definition at line 123 of file GeneticAlgorithm.h.