-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgreedy.cpp
More file actions
118 lines (105 loc) · 2.78 KB
/
Copy pathgreedy.cpp
File metadata and controls
118 lines (105 loc) · 2.78 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
TSP Ruin and Recreate greedy implementation with random+sequential+radial ruins:
https://www.semanticscholar.org/paper/Record-Breaking-Optimization-Results-Using-the-Ruin-Schrimpf-Schneider/4f80e70e51e368858c3df0787f05c3aa2b9650b4
make greedy
make ezxdisp
make cpplint2
make cppcheck2
for tour display
- make ezxdisp
- after "make install" of ezxdisp repo first:
https://github.com/Hermann-SW/ezxdisp?tab=readme-ov-file#support-for-c--use-in-ide
(left mouse click continues to next accepted mutation and updates display; repeat)
*/
#include <unistd.h>
#include <sstream>
#include <iostream>
#include "./loader.h"
#include "./random_access_list.h"
#include "./tsp_tour.h"
#ifdef ezxdisp
#include "./disp_utils.h"
#endif
#include "./RR_greedy.h"
int seed = time(NULL);
int radc = -1;
int rsiz = -1;
bool force_irr = false;
void help(const char *argv0) {
std::cout << argv0
<< " [-d] [-c] [-i tour_or_mode] [-h] [-m nmut] [-r]"\
" [-s seed] fname\n";
std::cout << " -d: single display\n";
std::cout << " -c: small city display\n";
std::cout << " -i: file.tour\n";
std::cout << " -h: this help\n";
std::cout << " -m: #mutations\n";
std::cout << " -r: rotate 270°\n";
std::cout << " -s: seed\n";
std::cout << " -R: center (for initial radial ruin)\n";
std::cout << " -S: size (for initial ruin)\n";
std::cout << " -N: file.nxt (read or write rad_nxt[])\n";
std::cout << " -F: for optimization inside initial radial ruin only\n";
exit(EXIT_FAILURE);
}
int main(int argc, char *argv[]) {
int opt;
#ifdef ezxdisp
const char *opts = "dci:hm:rs:R:S:N:F:z:";
#else
const char *opts = "i:hm:s:R:S:N:F";
#endif
while ((opt = getopt(argc, argv, opts)) != -1) {
switch (opt) {
#ifdef ezxdisp
case 'c':
small_city = true;
break;
case 'd':
single_display = true;
break;
#endif
case 'h':
help(argv[0]);
break;
case 'i':
src = new std::string(optarg);
break;
case 'm':
nmutations = atoi(optarg);
break;
#ifdef ezxdisp
case 'r':
rot270 = true;
break;
case 'z':
rzoom = atof(optarg);
break;
#endif
case 's':
seed = atoi(optarg);
break;
case 'R':
radc = atoi(optarg) - 1;
break;
case 'S':
rsiz = atoi(optarg);
break;
case 'N':
nxt = new std::string(optarg);
break;
case 'F':
force_irr = true;
break;
default:
help(argv[0]);
}
}
if (optind >= argc) {
std::cout << "Expected argument after options\n";
return EXIT_SUCCESS;
}
mtgen.seed(seed);
RR_greedy<random_access_list<int>, std::vector<int>>(argv[optind], seed);
return EXIT_SUCCESS;
}