dignea  1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
CXFactory.h
1 //
2 // Created by amarrero on 21/6/21.
3 //
4 
5 #ifndef DIGNEA_CXFACTORY_H
6 #define DIGNEA_CXFACTORY_H
7 
8 #include <dignea/core/Crossover.h>
12 
18 template <class S>
19 class CXFactory {
20  private:
21  map<CXType, function<unique_ptr<Crossover<S>>()>> factories;
22 
23  public:
24  CXFactory() {
25  factories[CXType::Uniform] = [] {
26  return make_unique<UniformCrossover<S>>();
27  };
28  factories[CXType::Order] = [] {
29  return make_unique<OrderCrossover<S>>();
30  };
31  }
32 
39  unique_ptr<Crossover<S>> create(CXType type) { return factories[type](); }
40 };
41 
42 #endif // DIGNEA_CXFACTORY_H
CXType
Types of Crossover Operators implemented in dignea.
Definition: CrossoverTypes.h:23
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