5 #ifndef DIGNEA_PARGABuilder_H
6 #define DIGNEA_PARGABuilder_H
8 #include <dignea/algorithms/singleobjective/ParallelGeneticAlgorithm.h>
9 #include <dignea/core/Problem.h>
10 #include <dignea/core/Solution.h>
11 #include <dignea/factories/CXFactory.h>
12 #include <dignea/factories/MutFactory.h>
32 operator unique_ptr<ParallelGeneticAlgorithm<S>>();
63 void newCompSet() { compSet++; }
66 unique_ptr<ParallelGeneticAlgorithm<S>> ga;
69 static const int MAX_COMPONENTS;
77 this->ga = make_unique<ParallelGeneticAlgorithm<S>>();
101 this->ga->setNumberOfCores(cores);
115 if (!this->problemSet) {
116 std::cerr <<
"Algorithm created but no problem set. "
117 "Remember to set a problem before calling run"
121 return move(this->ga);
124 "No all the components are set. ParGA requires: problem, "
125 "mutation operator, crossover operator, selection operator, "
126 "mutation rate, crossover rate, population size, "
127 "max evaluation and number of cores");
141 this->ga->setProblem(move(problem));
143 this->problemSet =
true;
158 auto crossover = factory.
create(cx);
159 this->ga->setCrossover(move(crossover));
174 this->ga->setCrossover(move(cx));
188 this->ga->setCrossRate(crossRate);
204 auto mut = factory.
create(mutation);
205 this->ga->setMutation(move(mut));
219 this->ga->setMutationRate(mutRate);
235 auto sel = factory.
create(selType);
236 this->ga->setSelection(move(sel));
251 this->ga->setPopulationSize(popsize);
265 this->ga->setMaxEvaluations(maxEvals);
CXType
Types of Crossover Operators implemented in dignea.
Definition: CrossoverTypes.h:23
MutType
Type of Mutation Operators implemented in dignea.
Definition: MutationTypes.h:22
SelType
Types of Selection Operators implemented in dignea.
Definition: SelectionTypes.h:19
Crossover factory which allows the user to create Crossover operators easily.
Definition: CXFactory.h:19
unique_ptr< Crossover< S > > create(CXType type)
Creates a unique pointer to a Crossover Operator of the given type. Variants are available at CXType.
Definition: CXFactory.h:39
Abstract Crossover interface.
Definition: Crossover.h:19
Mutation factory which allows the user to create Mutation Operators easily.
Definition: MutFactory.h:23
unique_ptr< Mutation< S > > create(MutType type)
Creates a unique pointer to a Mutation Operator of type.
Definition: MutFactory.h:45
Parallel Genetic Algorithm Builder. This class creates a unique_ptr to a Parallel Genetic Algorithm.
Definition: ParGABuilder.h:24
ParGABuilder< S > & mutation(MutType mutation)
Defines the mutation operator type to use with this Genetic Algorithm. Variants are available at MutT...
Definition: ParGABuilder.h:202
ParGABuilder< S > & with()
This method only returns *this and it is used to make the building process more natural....
Definition: ParGABuilder.h:44
static ParGABuilder< S > create()
Creates a ParGABuilder object.
Definition: ParGABuilder.h:87
ParGABuilder< S > & crossover(CXType cxType)
Defines the crossover operator type to use with this Genetic Algorithm. Variants are available at CXT...
Definition: ParGABuilder.h:156
ParGABuilder< S > & withMutRate(const float &mutRate)
Defines the mutation rate to apply in the mutation operator.
Definition: ParGABuilder.h:218
ParGABuilder< S > & runDuring(const int &maxEvals)
Sets the number of evaluations to perform.
Definition: ParGABuilder.h:264
ParGABuilder< S > & toSolve(unique_ptr< Problem< S >> problem)
Defines the problem to solve with the Genetic Algorithm. Receives a unique_ptr and takes the ownershi...
Definition: ParGABuilder.h:140
ParGABuilder< S > & usingCores(const int &cores)
Defines the number of cores that the Parallel Genetic Algorithm will be using.
Definition: ParGABuilder.h:100
ParGABuilder< S > & populationOf(const int &popsize)
Defines the number of individuals in the population of the Genetic Algorithm.
Definition: ParGABuilder.h:250
ParGABuilder< S > & withCrossRate(const float &crossRate)
Defines the crossover rate to apply the crossover operator.
Definition: ParGABuilder.h:187
ParGABuilder< S > & selection(SelType selType)
Defines the selection operator to use with this Genetic Algorithm. Variants are available at SelType.
Definition: ParGABuilder.h:233
Class to represent a Problem in the tool. It includes the basic information for a problem a few metho...
Definition: Problem.h:29
Selection factory which allows the user to create Selection Operators easily.
Definition: SelFactory.h:25
unique_ptr< Selection< S > > create(SelType type)
Creates a unique pointer to a Selection Operator of type.
Definition: SelFactory.h:41