-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
82 lines (66 loc) · 2.3 KB
/
main.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
#include <cstdlib>
#include <ctime>
#include "parse_cnf.h"
#include "sat_solver.h"
using namespace std;
using namespace SAT;
int main(int argc, char **argv)
{
string file_name;
clock_t t;
if(argc == 1) {
cout << "Usage: " << argv[0] << " " << "<file name>" << " " << "--enable_restarts" << " " << "<k value>(integer)" << " " << "<a value>(float)" << endl;
return 0;
} else if(argc == 2) {
file_name = argv[1];
enable_restarts = false;
} else if(argc == 3) {
file_name = argv[1];
if(static_cast<string>(argv[2]) != "--enable_restarts") {
cout << "Usage: " << argv[0] << " " << "<file name>" << " " << "--enable_restarts" << " " << "<k value>(integer)" << " " << "<a value>(float)" << endl;
return 0;
}
enable_restarts = true;
k = 100;
a = 1.5;
cout << "k: " << k << " " << "(default)" << endl;
cout << "a: " << a << " " << "(default)" << endl;
} else if(argc == 4) {
cout << "Usage: " << argv[0] << " " << "<file name>" << " " << "--enable_restarts" << " " << "<k value>(integer)" << " " << "<a value>(float)" << endl;
return 0;
} else if(argc == 5) {
file_name = argv[1];
if(static_cast<string>(argv[2]) != "--enable_restarts") {
cout << "Usage: " << argv[0] << " " << "<file name>" << " " << "--enable_restarts" << " " << "<k value>(integer)" << " " << "<a value>(float)" << endl;
return 0;
}
enable_restarts = true;
k = atoi(argv[3]);
a = strtof(argv[4], NULL);
cout << "k: " << k << endl;
cout << "a: " << a << endl;
} else {
cout << "Usage: " << argv[0] << " " << "<file name>" << " " << "--enable_restarts" << " " << "<k value>(integer)" << " " << "<a value>(float)" << endl;
return 0;
}
cout << endl;
t = clock();
if(parse_file(file_name) == -1) {
cout << "ERROR in parsing file. EXIT!" << endl;
return 0;
}
t = clock() - t;
cout << "Number of variables: " << vector_literals.size() << endl;
cout << "Number of clauses: " << vector_clauses.size() << endl;
cout << "Parsing time: " << static_cast<float>(t) / CLOCKS_PER_SEC << "s" << endl;
cout << endl;
t = clock();
dpll_algorithm();
t = clock() - t;
cout << "Number of conflicts: " << number_conflicts << endl;
if(enable_restarts) {
cout << "Number of restarts: " << number_restarts << endl;
}
cout << "Computation time: " << static_cast<float>(t) / CLOCKS_PER_SEC << "s" << endl;
return 0;
}