|
dignea
1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
|
Class to represents a Parallel Genetic Algorithm (ParGA). This algorithm runs the evolution in numberOfCores different cores to speedup the evaluation. Inherits from AbstractGA. More...
#include <ParallelGeneticAlgorithm.h>
Public Member Functions | |
| ParallelGeneticAlgorithm () | |
| Creates a default ParallelGeneticAlgorithm. Use the ParGABuilder class instead. More... | |
| virtual string | getName () const override |
| Get the Name. More... | |
| virtual void | run () override |
| Run the parallel Algorithm. More... | |
| int | getNumberOfCores () const |
| Get the number of cores used. More... | |
| void | setNumberOfCores (int nCores) |
| Set the number of cores to use. More... | |
| void | setProblem (shared_ptr< Problem< S >> prob) override |
| Sets the problem to solve. Receives a share_ptr. More... | |
| const Problem< S > * | getProblem () const |
| Get a raw pointer to the problem to solve. More... | |
| json | to_json () const override |
| Generates and returns a JSON representation of the ParallelGeneticAlgorithm. More... | |
Public Member Functions inherited from AbstractGA< S > | |
| AbstractGA () | |
| Creates a new AbstractGA which initialises all parameter to default. The operators will be set to null. More... | |
| json | to_json () const override |
| Creates and returns JSON object with the GA information. More... | |
| virtual Front< S > | getResults () const |
| Returns a front with the feasible non repeated individuals in the last population of the Genetic Algorithm. This is the final solution of the algorithm to the problem at hand. More... | |
| void | run () override |
| Runs the evolutionary process. This is the main EA method. This methods is in charge of: More... | |
| void | setProblem (shared_ptr< Problem< S >> prob) override |
| Uptades the problem to solve using a share_ptr. The problem must be single-objective. More... | |
| void | setProblem (Problem< S > *prob) override |
| Uptades the problem to solve using a raw pointer. The problem must be single-objective. More... | |
| double | getMutationRate () const |
| Gets the mutation rate. More... | |
| void | setMutationRate (double mutationRate) |
| Updates the mutation rate. More... | |
| double | getCrossRate () const |
| Gets the crossover rate. More... | |
| void | setCrossRate (double crossRate) |
| Updates the crossover rate. More... | |
| const Mutation< S > * | getMutation () const |
| Gets a pointer to the mutation operator. More... | |
| void | setMutation (unique_ptr< Mutation< S >> mutation) |
| Updates the mutation operator. Takes a unique_ptr pointing to the new Mutation operator and takes the ownership. More... | |
| const Crossover< S > * | getCrossover () const |
| Returns a raw pointer to the crossover operator. More... | |
| void | setCrossover (unique_ptr< Crossover< S >> crossover) |
| Updates the crossover operator. Takes a unique_ptr pointing to the new Crossover operator and takes the ownership. More... | |
| const Selection< S > * | getSelection () const |
| Returns a raw pointer of the selection operator. More... | |
| void | setSelection (unique_ptr< Selection< S >> selectionOperator) |
| Updates the selection operator. Takes a unique_ptr pointing to the new Selection operator and takes the ownership. More... | |
Public Member Functions inherited from AbstractEA< S > | |
| AbstractEA () | |
| Construct a new Abstract EA object with default parameter values. More... | |
| AbstractEA (const int &maxEvals, const int &popsize) | |
| AbstractEA constructor which initialises the parameters maxEvalautions and populationSize. More... | |
| AbstractEA (unique_ptr< PopulationEvaluator< S >>, const int &maxEvals, const int &popsize) | |
| AbstractEA constructor which initialises the parameters maxEvalautions, the populationSize and the evaluator approach. More... | |
| int | getPopulationSize () const |
| Get the population size. More... | |
| void | setPopulationSize (int pSize) |
| Setter to update the population size. More... | |
| double | getElapsedTime () const |
| Get the elapsed time of the evolutionary process. More... | |
| const vector< S > & | getPopulation () const |
| Gets a reference of the population. More... | |
| int | getMaxEvaluations () const |
| Get the maximum number of evaluations to perform. More... | |
| void | setMaxEvaluations (int maxEval) |
| Set a new maximum number of evaluations to perform. More... | |
| const Problem< S > * | getProblem () const |
| Gets a pointer to the problem which is being solved. More... | |
| PopulationEvaluator< S > * | getEvaluator () const |
| Gets a pointer to the population evaluator system. More... | |
| void | setEvaluator (unique_ptr< PopulationEvaluator< S >> eval) |
| Updates the population evaluator system with the unique_ptr. The method takes the ownership of the object behind. More... | |
| int | getPerformedEvaluations () const |
| Get the performed evaluations. More... | |
| void | setPerformedEvaluations (int pEvals) |
| Set the Performed Evaluations. Useful for the updateProgress method. More... | |
| void | setPopulation (const vector< S > &pop) |
| Set the Population. More... | |
| virtual Evolution< S > | getEvolution () const |
| Get the Evolution data. More... | |
| int | getPrintingInterval () const |
| Get the interval of checkpoints. More... | |
Protected Member Functions | |
| virtual void | initProgress () |
| Starts the progress of the parallel algorithm Sets the performedEvaluations to the number of individuals in the population. More... | |
| virtual void | updateProgress () |
| Method which updates the evolutionary progress. This method must be implemented in the subclasses and it should perform thinks like updating the number of performed evaluations, etc. | |
| void | runEvolution () |
| Main method of the ParallelGeneticAlgorithm. Runs the evolution of the algorithm. More... | |
| virtual void | createInitialPopulation () |
| Creates the initial population using parallel cores. More... | |
| virtual void | reproduction (S &, S &) |
| Applies the genetic operators to the given individuals. More... | |
| virtual void | replacement (vector< S > &offsp) |
| string | getID () const override |
| Returns the identificator of the algorithm, this is used in the to_json method. Must be implemented in the subclasses. It should return the acronym of useful id for a particular configuration. More... | |
| S | parallelSelection (const int &init, const int &end) |
| Parallel selection operator. This methods performs a binary tournament selection in the range [int, end] of the population. Used for speedup the parallel executions. More... | |
| void | configureEnv () |
| Configures the parallel environment. More... | |
Protected Member Functions inherited from AbstractGA< S > | |
| virtual void | finishProgress () |
| Finishes the evolutionary process by computing the elapsed time. More... | |
| virtual bool | isStoppingConditionReached () |
| Checks whether the evolutionary process has reached the maximum limit. More... | |
| virtual void | evaluatePopulation (vector< S > &pop) |
| Evaluates the entire population of individuals using the problem evaluation function. More... | |
| virtual vector< S > | createMating () |
| Generates the mating population of individuals to be evaluated. The individuals are selected and after that the genetic operators are applied here. More... | |
Protected Member Functions inherited from AbstractEA< S > | |
| virtual void | updateEvolution (vector< S > &pop) |
| virtual void | updateEvolution (const int &checkpoint, vector< S > &) |
Protected Attributes | |
| int | numberOfCores |
| int | chunks |
| ParallelPRNG | prng |
| vector< S > | individuals |
| shared_ptr< Problem< S > > | problem |
| vector< float > | bestEvolution |
Protected Attributes inherited from AbstractGA< S > | |
| double | mutationRate |
| double | crossRate |
| unique_ptr< Mutation< S > > | mutation |
| unique_ptr< Crossover< S > > | crossover |
| unique_ptr< Selection< S > > | selection |
| unique_ptr< Replacement< S > > | replacement |
Protected Attributes inherited from AbstractEA< S > | |
| int | maxEvaluations |
| int | performedEvaluations |
| int | populationSize |
| vector< S > | population |
| shared_ptr< Problem< S > > | problem |
| unique_ptr< PopulationEvaluator< S > > | evaluator |
| Evolution< S > | evolution |
| AvgEvolution< S > | avgEvolution |
| std::chrono::system_clock::time_point | startTime |
| std::chrono::system_clock::time_point | endTime |
| double | elapsedTime |
| int | nextCheckpoint |
| int | evolutionInterval |
Additional Inherited Members | |
Static Public Attributes inherited from AbstractGA< S > | |
| static double | DEFAULT_MUTATION_RATE = 0.05 |
| Default mutation rate for GAs set to 0.05. More... | |
| static double | DEFAULT_CROSSOVER_RATE = 0.8 |
| Default crossover rate to GAs set to 0.8. More... | |
| static int | DEFAULT_POPULATION_SIZE = 32 |
| Default population size to GAs set to 32 individuals. More... | |
Static Public Attributes inherited from AbstractEA< S > | |
| static const int | DEFAULT_POPULATION_SIZE = 100 |
| Default population size equal to 100 individuals. More... | |
| static const int | DEFAULT_EVALUATIONS_LIMIT = 100000 |
| Default evaluation limit equal to 100000 evaluations. More... | |
| static const std::string | NAME = "Algorithm" |
| static const std::string | MAX_EVALUATIONS = "Max Evaluations" |
| static const std::string | POP_SIZE = "Population Size" |
| static const std::string | ELAPSED_TIME = "Elapsed Time" |
| static const std::string | EVALUATOR = "Evaluator" |
| static const int | EVOLUTION_SIZE = 10 |
Class to represents a Parallel Genetic Algorithm (ParGA). This algorithm runs the evolution in numberOfCores different cores to speedup the evaluation. Inherits from AbstractGA.
| S | Type of individual in the population |
| ParallelGeneticAlgorithm< S >::ParallelGeneticAlgorithm |
Creates a default ParallelGeneticAlgorithm. Use the ParGABuilder class instead.
| Problem | |
| S |
|
protected |
Configures the parallel environment.
| S |
|
protectedvirtual |
Creates the initial population using parallel cores.
| V | |
| O |
Reimplemented from AbstractGA< S >.
|
inlineoverrideprotectedvirtual |
Returns the identificator of the algorithm, this is used in the to_json method. Must be implemented in the subclasses. It should return the acronym of useful id for a particular configuration.
Implements AbstractEA< S >.
|
inlineoverridevirtual |
|
inline |
Get the number of cores used.
|
inline |
Get a raw pointer to the problem to solve.
|
protectedvirtual |
Starts the progress of the parallel algorithm Sets the performedEvaluations to the number of individuals in the population.
| Problem | |
| S |
Reimplemented from AbstractGA< S >.
|
protected |
Parallel selection operator. This methods performs a binary tournament selection in the range [int, end] of the population. Used for speedup the parallel executions.
| Problem | |
| S |
| init | |
| end |
|
protectedvirtual |
Applies the genetic operators to the given individuals.
| Problem | |
| S |
Reimplemented from AbstractGA< S >.
|
overridevirtual |
Run the parallel Algorithm.
| Problem | |
| S |
Implements AbstractEA< S >.
|
protected |
Main method of the ParallelGeneticAlgorithm. Runs the evolution of the algorithm.
| Problem | |
| S |
|
inline |
Set the number of cores to use.
| nCores |
|
overridevirtual |
Sets the problem to solve. Receives a share_ptr.
| S |
| prob |
Reimplemented from AbstractEA< S >.
|
overridevirtual |
Generates and returns a JSON representation of the ParallelGeneticAlgorithm.
| S |
Reimplemented from AbstractEA< S >.
|
protected |
Chunks of population for each core
|
protected |
Number of cores to run in parallel
|
protected |
Random number generator