dignea  1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
TSPDomain.h
Go to the documentation of this file.
1 
14 #ifndef DIGNEA_ITSPPROBLEM_H
15 #define DIGNEA_ITSPPROBLEM_H
16 
19 #include <dignea/problems/TSP.h>
20 #include <dignea/types/SolutionTypes.h>
21 
27 class TSPDomain : public AbstractDomain<TSP, TSPInstance> {
28  public:
30  TSPDomain();
31 
40  explicit TSPDomain(const int &numberOfVars, const int &numberOfObjs = 1);
41 
45  TSPDomain(const TSPDomain *prob);
46 
47  virtual ~TSPDomain() = default;
48 
51  TSPDomain(const string &pathToInstance) = delete;
52 
60  TSPDomain(const int &numberOfVars, const int &numberOfObjs,
61  const float &maxL, const float &minL, const float e = 5.0,
62  const int minN = 2);
63 
68  shared_ptr<TSP> genOptProblem(const TSPInstance &instance) const override;
69 
72  void evaluate(TSPInstance &solution) const override { return; };
73 
77  vector<TSPInstance> createSolutions(
78  const int &maxSolutions) const override;
79 
83  void beforeEvaluation(vector<TSPInstance> &) override { return; };
84 
91  void afterEvaluation(vector<TSPInstance> &) override;
92 
95  TSPInstance createSolution() const override;
96 
100  TSPInstance createSolution(ParallelPRNG &engine) const override;
101 
105  bool evaluateConstraints(TSPInstance &solution) const override {
106  return true;
107  }
112  int getOptimizationDirection(const int i) const override;
113 
116  string getName() const override { return "TSPDomain"; }
117 
121  float getUpperLimit(const int i) const override;
122 
126  float getLowerLimit(const int i) const override;
127 
130  void setUpperLimit(const float &l) { this->upperLimit = l; }
131 
134  void setLowerLimit(const float &l) { this->lowerLimit = l; }
135 
138  void setEPS(const float e) { eps = e; }
139 
142  float getEPS() const { return eps; }
143 
147  void setMinNeighbors(const int m) { minNeighbors = m; }
148 
152  int getMinNeighbors() const { return minNeighbors; }
153 
156  void readData(const string &path) override{};
157 
158  private:
159  coords computeCentroid(const vector<coords> &points);
160 
161  float instanceRadius(const vector<coords> &points, const coords &centroid);
162 
163  float distinctDistances(const vector<vector<float>> &distances);
164 
165  private:
166  float upperLimit;
167  float lowerLimit;
168  float eps;
169  int minNeighbors;
170 };
171 
172 #endif
Evolutionary TSP Solution. Class which represents the solution for the Instance Generation TSP Proble...
EIG Instance Generation Problem. Abstract Problem for the EIG. This problem will be used as a supercl...
Definition: AbstractDomain.h:28
int numberOfVars
Definition: Problem.h:155
int numberOfObjs
Definition: Problem.h:159
Instance Generator TSP Problem. Problem for the EIG to generate TSP Instances.
Definition: TSPDomain.h:27
TSPInstance createSolution() const override
Creates a single solution (TSP instance)
Definition: TSPDomain.cpp:88
void setLowerLimit(const float &l)
Set the lower limit for the ith dimension.
Definition: TSPDomain.h:134
bool evaluateConstraints(TSPInstance &solution) const override
Not implemented here.
Definition: TSPDomain.h:105
TSPDomain()
Creates a default TSPDomain.
Definition: TSPDomain.cpp:21
float getLowerLimit(const int i) const override
Get the lower limit of the ith dimension (default = 0)
Definition: TSPDomain.cpp:121
int getOptimizationDirection(const int i) const override
Returns the optimization direction for each dimension. Minimize in each case.
Definition: TSPDomain.cpp:147
float getEPS() const
Get the epsilon parameter of the DBSCAN algorithm.
Definition: TSPDomain.h:142
shared_ptr< TSP > genOptProblem(const TSPInstance &instance) const override
Generates a TSP problem with the information in the TSPInstance to be solved in the EIG by the algori...
Definition: TSPDomain.cpp:134
float getUpperLimit(const int i) const override
Get the upper limit of the ith dimension (default = 1000)
Definition: TSPDomain.cpp:112
TSPDomain(const string &pathToInstance)=delete
Not allowed here.
string getName() const override
Get the problem name.
Definition: TSPDomain.h:116
void setMinNeighbors(const int m)
Set the minimum number of neighbors to consider a cluster in the DBSCAN algorithm.
Definition: TSPDomain.h:147
void readData(const string &path) override
Not implemented here.
Definition: TSPDomain.h:156
vector< TSPInstance > createSolutions(const int &maxSolutions) const override
Creates a vector of initial instances (ITSPSolutions) for the EIG.
Definition: TSPDomain.cpp:70
int getMinNeighbors() const
Get the minimum number of neighbors to consider a cluster in the DBSCAN algorithm.
Definition: TSPDomain.h:152
void beforeEvaluation(vector< TSPInstance > &) override
Performs problem dependent operations before evaluating the instances in the EIG.
Definition: TSPDomain.h:83
void evaluate(TSPInstance &solution) const override
Not implemented.
Definition: TSPDomain.h:72
void setEPS(const float e)
Set the epsilon parameter for the DBSCAN algorithm.
Definition: TSPDomain.h:138
void setUpperLimit(const float &l)
Set the upper limit for the ith dimension.
Definition: TSPDomain.h:130
void afterEvaluation(vector< TSPInstance > &) override
Performs problem dependent operatiions after evaluating the instances in the EIG. Computes the featur...
Definition: TSPDomain.cpp:227
Instance Traveling Salesman Problem Solution. Class which represents the solution for the Instance Tr...
Definition: TSPInstance.h:33