-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolver.h
87 lines (61 loc) · 1.75 KB
/
solver.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
const int max_node = 1100;
const int max_nb_route = 100;
const int max_nb_node = 200;
#include "solution.h"
#include "extension.h"
struct Solver{
string path;
/**
* Parameter
**/
int capacity;
int distanceNode[max_node][max_node];
int nbNode;
Request * requests;
Solution sol; //Current solution
Solution bestSol; //best solution for ILS
Solution lastSol; //Best solution for MS-ILS
void readInput();
void constructor();
void swap(int &);
void relocate(int &);
void threeMove(int &);
void decreaseVehicle(int &);
void perubation();
void ILS();
void MS_ILS();
void runILS(){
clock_t start_time;
clock_t end_time;
float long_time;
start_time = clock();
readInput();
ILS();
bestSol.displayRoute();
end_time = clock();
long_time = float(end_time - start_time) / CLOCKS_PER_SEC;
ofstream file;
file.open("result.csv", ios::app);
printf("Last Objective %d - %fs\n", bestSol.objective, long_time);
file << path << "," << bestSol.objective << "," << long_time << endl;
file.close();
}
void runMSILS(){
clock_t start_time;
clock_t end_time;
float long_time;
start_time = clock();
readInput();
MS_ILS();
lastSol.displayRoute();
end_time = clock();
long_time = float(end_time - start_time) / CLOCKS_PER_SEC;
ofstream file;
file.open("result.csv", ios::app);
cout << "Last Objective: " << lastSol.objective << endl;
file << path << "," << lastSol.objective << "," << long_time << endl;
file.close();
}
};
#include "readInput.h"
#include "ILS.h"