15 #include <dignea/core/Problem.h>
16 #include <dignea/types/SolutionTypes.h>
17 #include <dignea/utilities/random/PseudoRandom.h>
27 using coords = std::pair<float, float>;
40 virtual ~
TSP() =
default;
50 explicit TSP(
const int &
numberOfVars,
const vector<coords> &coordinates);
80 string getName()
const override {
return "TSP"; };
114 void readData(
const string &path)
override;
Class to represent a Problem in the tool. It includes the basic information for a problem a few metho...
Definition: Problem.h:29
int numberOfVars
Definition: Problem.h:155
Class to represent a solution to the optimization problems in the tool.
Definition: Solution.h:25
Traveling Salesman Problem implemented in dignea. Uses a IntFloat representation where the solutions ...
Definition: TSP.h:35
bool evaluateConstraints(IntFloatSolution &solution) const override
Evaluates whether a solution is feasible of not regarding to the TSP formulation.
Definition: TSP.cpp:169
int getOptimizationDirection(const int i) const override
Get the optimization direction. Only for dimension = 0 and returns Minimize.
Definition: TSP.cpp:243
const vector< coords > & getPoints() const
Get the points of the instances as coordinates.
Definition: TSP.h:88
vector< coords > points
Definition: TSP.h:125
float getUpperLimit(int i) const override
Get the upper bound of the search space. In this case the upper bound is the number of variables minu...
Definition: TSP.cpp:139
void computeDistances()
Computes the distance from each point to the other in the instance.
Definition: TSP.cpp:256
TSP()
Creates a default TSP object.
Definition: TSP.cpp:26
string getName() const override
Get the name of the problem.
Definition: TSP.h:80
json to_json() const override
Creates and return the JSON representation of the TSP problem.
Definition: TSP.cpp:284
vector< vector< float > > distances
Definition: TSP.h:126
std::string pathToInstance
Definition: TSP.h:124
IntFloatSolution createSolution() const override
Creates and return a random solution for the TSP.
Definition: TSP.cpp:231
void evaluate(IntFloatSolution &solution) const override
Evaluates a solution to the TSP.
Definition: TSP.cpp:192
const vector< vector< float > > & getDistances() const
Get the matrix of distances between each city in the instance.
Definition: TSP.h:84
const std::string getPathToInstance() const
Get the path to the instance if used.
Definition: TSP.h:92
void readData(const string &path) override
Reads the instance information from the filesystem.
Definition: TSP.cpp:108
float getLowerLimit(int i) const override
Get the lower bound of the search space (1).
Definition: TSP.cpp:153