dignea  1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
NSFactory.h
Go to the documentation of this file.
1 
11 #ifndef DIGNEA_NSFACTORY_H
12 #define DIGNEA_NSFACTORY_H
13 
14 #include <dignea/searches/NSFeatures.h>
15 #include <dignea/searches/NSPerformance.h>
16 #include <dignea/searches/NoveltySearch.h>
17 #include <dignea/types/NSTypes.h>
18 
19 #include <string>
20 
21 using namespace std;
22 
28 template <class S>
29 class NSFactory {
30  private:
31  map<NSType, function<unique_ptr<NoveltySearch<S>>(
32  unique_ptr<Distance<float>> dist, const float& thres,
33  const float& finalThresh, const int k, bool warmUp)>>
34  factories;
35 
36  public:
37  NSFactory() {
38  factories[NSType::Standard] =
39  [](unique_ptr<Distance<float>> dist, const float& thres,
40  const float& finalThresh, const int k, bool warmUp) {
41  return make_unique<NoveltySearch<S>>(move(dist), thres,
42  finalThresh, k);
43  };
44  factories[NSType::Features] =
45  [](unique_ptr<Distance<float>> dist, const float& thres,
46  const float& finalThresh, const int k, bool warmUp) {
47  return make_unique<NSFeatures<S>>(move(dist), thres,
48  finalThresh, k, warmUp);
49  };
50  factories[NSType::Performance] =
51  [](unique_ptr<Distance<float>> dist, const float& thres,
52  const float& finalThresh, const int k, bool warmUp) {
53  return make_unique<NSPerformance<S>>(move(dist), thres,
54  finalThresh, k);
55  };
56  }
57 
64  unique_ptr<NoveltySearch<S>> create(NSType type,
65  unique_ptr<Distance<float>> dist,
66  const float& thres,
67  const float& finalThresh, const int k,
68  bool warmUp) {
69  return factories[type](move(dist), thres, finalThresh, k, warmUp);
70  }
71 };
72 
73 #endif
NSType
Type of Novelty Search algorithms available in dignea at the moment.
Definition: NSTypes.h:23
Novelty Search factory which allows the user to create Novelty Search algorithms on the go.
Definition: NSFactory.h:29
unique_ptr< NoveltySearch< S > > create(NSType type, unique_ptr< Distance< float >> dist, const float &thres, const float &finalThresh, const int k, bool warmUp)
Creates a unique pointer to a Novelty Search algorithm of given type. Variants are available at NSTyp...
Definition: NSFactory.h:64