-
Notifications
You must be signed in to change notification settings - Fork 0
/
pms.cpp
127 lines (117 loc) · 3.18 KB
/
pms.cpp
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
119
120
121
122
123
124
125
126
127
#include "basis_pms.h"
#include "pms.h"
#include <signal.h>
#include <unistd.h>
static Satlike s;
void interrupt(int sig)
{
s.print_best_solution();
s.free_memory();
exit(10);
}
int main(int argc, char* argv[])
{
cout<<"This is Satlike3.0 solver"<<endl<<flush;
signal(SIGTERM,interrupt);
int verbose_level = 0;
int max_time_to_run = 300;
bool originalCode = false;
int seed=1;
int t = -1;
float sp = -1.0;
int hinc = -1;
int eta = -1;
int max_search=-1;
bool verification_to_be_done = false;
bool print_final_var_assignment = false;
bool adaptive_search_extent = false;
int initial_search = 0;
RAND_GEN_TYPE rType = MINSTD;
// Shut GetOpt error messages down (return '?'):
opterr = 0;
int opt;
// Retrieve the options:
cout << "SELECTED-OPTIONS: ";
while ( (opt = getopt(argc, argv, "av:pcm:or:t:s:h:e:z:i:R:")) != -1 ) { // for each option...
switch ( opt ) {
case 'a':
adaptive_search_extent = true;
cout << " adaptive_search_extent";
break;
case 'v':
verbose_level = atoi(optarg);
cout << " verbose_level=" << verbose_level;
break;
case 'p':
print_final_var_assignment = true;
cout << " print_final_var_assignment";
break;
case 'c':
verification_to_be_done = true;
cout << " auto-verification-of-solution";
break;
case 'm':
max_time_to_run = atoi(optarg);
cout << " max_time_to_run=" << max_time_to_run;
break;
case 'o':
originalCode = true;
cout << " original-code";
break;
case 'r':
seed = atoi(optarg);
cout << " seed=" << seed;
break;
case 't':
t = atoi(optarg);
cout << " t=" << t;
break;
case 's':
sp = atof(optarg);
cout << " sp=" << sp;
break;
case 'h':
hinc = atoi(optarg);
cout << " hinc=" << hinc;
break;
case 'e':
eta = atoi(optarg);
cout << " eta=" << eta;
break;
case 'z':
max_search = atoi(optarg);
cout << " max_search=" << max_search;
break;
case 'i':
initial_search = atoi(optarg);
cout << " initial_search=" << initial_search;
break;
case 'R':
rType = (RAND_GEN_TYPE)(atoi(optarg));
cout << " rType=" << rType;
break;
case '?': // unknown option...
cerr << "Unknown option: '" << char(optopt) << "'!" << endl;
break;
default:break;//do nothing
}
}
cout<<endl<<flush;
assert(optind == (argc-1));
s.build_instance(argv[optind]);
if(initial_search > 0){
s.set_initial_max_flip(initial_search);
}
if(originalCode){
vector<int> init_solution;
s.local_search_with_decimation(seed, init_solution,argv[optind],
max_time_to_run, verbose_level, verification_to_be_done); //ORIGINAL
}else{
s.local_search_with_decimation_using_steps(seed, max_time_to_run,
t, sp, hinc, eta, max_search, adaptive_search_extent,
rType, verbose_level, verification_to_be_done);
}
s.print_best_solution(print_final_var_assignment);
s.free_memory();
return (0);
}