-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExactTSPSolver.hpp
More file actions
48 lines (36 loc) · 1.05 KB
/
ExactTSPSolver.hpp
File metadata and controls
48 lines (36 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef EXACTTSPSOLEVER_HPP
#define EXACTTSPSOLEVER_HPP
#include <vector>
#include <limits>
#include <queue>
#include <algorithm>
#include "Graphe.hpp"
#include "Noeud.hpp"
#include "Edge.hpp"
using namespace std;
class ExactTSPSolver {
private:
Graphe& g;
vector<int> bestTour;
double bestDistance;
vector<bool> visited;
int startNode;
int numNodes;
public:
ExactTSPSolver(Graphe& graph, int start) :
g(graph),
startNode(start),
numNodes(graph.noeuds.size()),
visited(graph.noeuds.size(), false),
bestDistance(numeric_limits<double>::max()) {
}
vector<int> solve();
private:
void dfsSearch(vector<int>& currentPath, int visitedCount, double currentDistance);
vector<int> findShortestPath(int start, int end);
double calculatePathDistance(const vector<int>& path);
};
vector<int> findExactTSPSolution(Graphe& g, int startNode);
vector<int> findExactTSPSolutionFromTour(Graphe& g, vector<int>& initialTour);
double pathCost(Graphe g, vector<int> path);
#endif