-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
71 lines (66 loc) · 2.39 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
#include <iostream>
#include "rhombicToricLattice.h"
#include "code.h"
#include "decoder.h"
#include <chrono>
#include <string>
#include <sstream>
int main(int argc, char *argv[])
{
if (argc < 11)
{
std::cout << "Fewer than eleven arguments" << std::endl;
for (int i = 0; i < argc; ++i)
{
std::cout << "Argument " << i << " = " << argv[i] << std::endl;
}
return 1;
}
int l = std::atoi(argv[1]);
double p = std::atof(argv[2]);
double q = std::atof(argv[3]);
// std::string sweepDir(argv[4]);
int rounds = std::atoi(argv[4]);
std::string latticeType(argv[5]);
int sweepLimit = std::atoi(argv[6]);
std::string sweepSchedule(argv[7]);
int timeout = std::atoi(argv[8]);
bool greedy;
std::stringstream ssg(argv[9]);
if (!(ssg >> std::boolalpha >> greedy))
{
std::cerr << "Incorrect argument provided (boolean)." << std::endl;
return 1;
}
bool correlatedErrors;
std::stringstream ssc(argv[10]);
if (!(ssc >> std::boolalpha >> correlatedErrors))
{
std::cerr << "Incorrect argument provided (boolean)." << std::endl;
return 1;
}
std::vector<bool> succ;
int sweepRate = std::atoi(argv[11]);
auto start = std::chrono::high_resolution_clock::now();
// if (latticeType == "rhombic_toric")
// {
// succ = runToric(l, rounds, p, q, sweepDir, timeout, greedy, correlatedErrors);
// }
// else if (latticeType == "rhombic_boundaries" || latticeType == "cubic_boundaries")
if (latticeType == "rhombic_boundaries" || latticeType == "cubic_boundaries" || latticeType == "rhombic_toric" || latticeType == "cubic_toric")
{
// succ = runBoundaries(l, rounds, p, q, sweepLimit, sweepSchedule, timeout, latticeType, greedy, correlatedErrors);
succ = oneRun(l, rounds, p, q, sweepLimit, sweepSchedule, timeout, latticeType, greedy, correlatedErrors, sweepRate);
}
else
{
throw std::invalid_argument("Invalid lattice type.");
}
auto finish = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish - start;
std::cout << succ[0] << ", " // Decoding succeeded
<< succ[1] << ", " // Clean syndrome
<< elapsed.count() // "s" <<
<< std::endl;
return 0;
}