-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
220 lines (209 loc) · 5.71 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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#include <ilcplex/ilocplex.h>
#include "Algorithms.hpp"
#include "test_alg.hpp"
#include <functional>
#include <vector>
#include <numeric>
#include <ctime>
int main(int argc, const char** argv) {
/*
Usage: LexAlg file_name, output_file_name, algorithm_choices (one of {cplex, bisection, greedy, rounding, packing})
Example: LexAlg instance.mps output.txt cplex
*/
if (argc < 3) {
std::cout << "Please speficify the input parameters" << std::endl;
std::cout << "Parameters: file_name, output_file_name, algorithm_type" << std::endl;
return 0;
}
_Algorithm_Choice choice;
/*
if (string(argv[1]) == "_STAB_" && argc == 4) {
int num_of_nodes_arr[1] = {150};
double prob_arr[6] = { 5, 30, 35, 40, 45, 50 };
//int seed_arr[100]
const char* output_file = argv[2];
string _type = string(argv[3]);
if (_type == "CPLEX") {
choice = cplex;
return 0;
}
else if (_type == "Bisection") {
choice = bisection;
}
else if (_type == "Greedy") {
choice = greedy;
}
else if (_type == "Rounding") {
choice = rounding;
}
else if (_type == "Packing") {
choice = packing;
}
else if (_type == "ProbRounding") {
choice = prob_rounding;
}
else if (_type == "ProbPacking") {
choice = prob_packing;
}
for (IloInt i = 0; i < 1; ++i) {
IloInt num_of_nodes = num_of_nodes_arr[i];
for (IloInt j = 0; j < 6; ++j) {
IloInt edge_prob = prob_arr[j];
for (IloInt k = 1; k <= 100; ++k) {
//IloInt rand_seed = seed_arr[k];
IloInt rand_seed = k;
test_stab(output_file, choice, _type, num_of_nodes, edge_prob, rand_seed);
}
}
}
return 0;
}
*/
if (string(argv[1]) == "_QCP_" && argc == 10) {
std::cout << "start QCP test" << std::endl;
const char* output_file = argv[2];
string _type = string(argv[3]);
IloInt seed = atoi(argv[4]);
IloBool binary_QCP = atoi(argv[5]);
IloInt sparsity = atoi(argv[6]);
IloInt num_qc = atoi(argv[7]);
IloInt num_linear = atoi(argv[8]);
IloInt num_var = atoi(argv[9]);
if (_type == "CPLEX") {
choice = cplex;
}
else if (_type == "Bisection") {
choice = bisection;
}
else if (_type == "Greedy") {
choice = greedy;
}
else if (_type == "Rounding") {
choice = rounding;
}
else if (_type == "Packing") {
choice = packing;
}
else if (_type == "ProbRounding") {
choice = prob_rounding;
}
else if (_type == "ProbPacking") {
choice = prob_packing;
}
test_QCP(output_file, choice, _type, seed, binary_QCP, sparsity, num_qc, num_linear, num_var);
return 0;
}
if (argc == 3) {
const char* file_address = argv[1];
const char* output_file = argv[2];
cout << "TRY ALL METHODS" << endl;
choice = cplex;
test(file_address, output_file, choice, string("CPLEX"), 3);
//choice = bisection;
//test(file_address, output_file, choice, string("Bisection"), 3);
//choice = greedy;
//test(file_address, output_file, choice, string("Greedy"), 3);
choice = rounding;
test(file_address, output_file, choice, string("Rounding"), 5);
choice = packing;
test(file_address, output_file, choice, string("Packing"), 5);
choice = roundingend;
test(file_address, output_file, choice, string("RoundingEnd"), 10);
choice = roundingendint;
test(file_address, output_file, choice, string("RoundingEndInt"), 10);
//choice = prob_rounding;
//test(file_address, output_file, choice, string("ProbRounding"), 3);
//choice = prob_packing;
//test(file_address, output_file, choice, string("ProbPacking"), 3);
choice = roundinglast;
test(file_address, output_file, choice, string("RoundingLast"), 10);
choice = packinglast;
test(file_address, output_file, choice, string("PackingLast"), 10);
}
if (argc == 4) {
const char* file_address = argv[1];
const char* output_file = argv[2];
//IloInt freq = atoi(argv[4]);
string _type = string(argv[3]);
if (_type == "CPLEX") {
choice = cplex;
}
else if (_type == "Bisection") {
choice = bisection;
}
else if (_type == "Greedy") {
choice = greedy;
}
else if (_type == "Rounding") {
choice = rounding;
}
else if (_type == "Packing") {
choice = packing;
}
else if (_type == "ProbRounding") {
choice = prob_rounding;
}
else if (_type == "ProbPacking") {
choice = prob_packing;
}
else if (_type == "RoundingLast") {
choice = roundinglast;
}
else if (_type == "PackingLast") {
choice = packinglast;
}
else if (_type == "RoundingEnd") {
choice = roundingend;
}
else if (_type == "RoundingEndInt") {
choice = roundingendint;
}
if (choice != cplex) {
test(file_address, output_file, choice, _type, 5);
}
else {
test(file_address, output_file, choice, _type, 1);
}
}
if (argc == 5) {
const char* file_address = argv[1];
const char* output_file = argv[2];
string _type = string(argv[3]);
IloInt freq = atoi(argv[4]);
if (_type == "CPLEX") {
choice = cplex;
}
else if (_type == "Bisection") {
choice = bisection;
}
else if (_type == "Greedy") {
choice = greedy;
}
else if (_type == "Rounding") {
choice = rounding;
}
else if (_type == "Packing") {
choice = packing;
}
else if (_type == "ProbRounding") {
choice = prob_rounding;
}
else if (_type == "ProbPacking") {
choice = prob_packing;
}
else if (_type == "RoundingLast") {
choice = roundinglast;
}
else if (_type == "PackingLast") {
choice = packinglast;
}
else if (_type == "RoundingEnd") {
choice = roundingend;
}
else if (_type == "RoundingEndInt") {
choice = roundingendint;
}
test(file_address, output_file, choice, _type, freq);
}
return 0;
}