dignea  1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
MutFactory.h
1 //
2 // Created by amarrero on 21/6/21.
3 //
4 
5 #ifndef DIGNEA_MUTFACTORY_H
6 #define DIGNEA_MUTFACTORY_H
7 
8 #include <dignea/core/Mutation.h>
9 #include <dignea/core/Problem.h>
10 #include <dignea/core/Solution.h>
15 
22 template <class S>
23 class MutFactory {
24  private:
25  map<MutType, function<unique_ptr<Mutation<S>>()>> factories;
26 
27  public:
28  MutFactory() {
29  factories[MutType::UniformAll] = [] {
30  return make_unique<UniformAllMutation<S>>();
31  };
32  factories[MutType::UniformOne] = [] {
33  return make_unique<UniformOneMutation<S>>();
34  };
35  factories[MutType::SwapMutation] = [] {
36  return make_unique<SwapMutation<S>>();
37  };
38  }
39 
45  unique_ptr<Mutation<S>> create(MutType type) { return factories[type](); }
46 };
47 
48 #endif // DIGNEA_MUTFACTORY_H
MutType
Type of Mutation Operators implemented in dignea.
Definition: MutationTypes.h:22
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