-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSA.h
65 lines (44 loc) · 1.39 KB
/
SA.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
#include "Solution.h"
#include <algorithm>
#include <cstring>
#include <climits>
class Smallest {
public:
double* value;
int* index;
int quantity;
Smallest(int _value, int _quantity) {
quantity = _quantity;
value = new double[quantity];
index = new int[quantity];
for (int i = 0; i < quantity; i++) {
value[i] = _value;
index[i] = i;
}
}
int getTheSmallest();
void increaseAValue(int _index, int _value);
void resetAll(int _value);
};
class SA : public Solution{
private:
int scaleOfViolationScore;
std::vector<std::vector<int>> bestSolution;
static bool isFirstTime;
std::vector<std::vector<bool>> modifiedRequiredMatrix;
void tweakSolutionByInsertion(std::vector<std::vector<int>>& solutionListOfEachDay);
void tweakSolutionBySwap(std::vector<std::vector<int>>& solutionListOfEachDay);
void tweakSolutionByReversion(std::vector<std::vector<int>>& solutionListOfEachDay);
void tweakSolutionRandomly(std::vector<std::vector<int>>& solutionListOfEachDay);
public:
double Ts;
double Te;
int numberOfIterations;
double Alpha;
SA(double _Ts, double _Te, int _numberOfIterations, double _alpha, double _FACTOR_OF_VIOLATION) : Ts(_Ts), Te(_Te), numberOfIterations(_numberOfIterations), Alpha(_alpha) {
FACTOR_OF_VIOLATION = _FACTOR_OF_VIOLATION;
};
void solve();
double getTheBestScore();
bool checkIfTheBestSolutionIsValid();
};