-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLocalSearch.h
100 lines (65 loc) · 2.27 KB
/
LocalSearch.h
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#pragma once
#include <iostream>
#include <vector>
#include "Czas.h"
using namespace std;
class LocalSearch
{
public:
LocalSearch();
Czas timerSOL;
Czas timerSA;
vector<int> valueForTime;
int** tspMatrix;
int matrixSize;
int timeLimit;
int optimalMin;
double initAlpha;
void setSA(double c, int d);
void setTS(int time, int neig);
int calcCost(vector <unsigned> v);
void showRoute(vector <unsigned> v);
bool ifContinueT(Czas timer);
void setMatrix(int** tsp, int s);
int getInitGreedy();
int swapCalculator(int x, int y, vector <unsigned>currentRoute);
int insertCalculator(int x, int y, vector <unsigned> currentRoute);
int reverseCalculator(int x, int y, vector <unsigned> currentRoute);
void vSwap(int a, int b, vector <unsigned>& currentRoute);
void vReverse(int a, int b, vector <unsigned>& currentRoute);
void vInsert(int a, int b, vector <unsigned>& currentRoute);
//int getRandGreedy();
void startSA();
double initTemp;
double minTemp;
double cooling;
int iterations;
double temp;
int shufflePath(vector <unsigned>& shuffled);
bool moveOrNo(int currentOptimalMin, int currentCost, double temp);
double changeTemp(double temp);
int best;
void startTS();
vector< vector<unsigned> > tabuList;
int tabuCadence;
int currentTabuCadence;
int iterLimit;
int intensivity;
int neighborType;
bool wasAspirated;
int bestNeighbor(int& bestI, int& bestJ, vector <unsigned> currentRoute);
void correctTabuList();
void diversification(vector <unsigned>& currentRoute);
int bestSwapNeighbor(int& bestI, int& bestJ, vector <unsigned> currentRoute);
int bestInsertNeighbor(int& bestI, int& bestJ, vector <unsigned> currentRoute);
int bestReverseNeighbor(int& bestI, int& bestJ, vector <unsigned> currentRoute);
void calculateSwap(int i, int j, int& balance, vector <unsigned> currentRoute);
void calculateInsert(int i, int j, int& balance, vector <unsigned> currentRoute);
void calculateReverse(int i, int j, int& balance, vector <unsigned> currentRoute);
int currentCost;
int currentOptimalMin;
vector <unsigned> routeTab;
vector <unsigned> currentRoute;
void saveToFileTabu(string name);
void saveToFileSA(string name);
};