forked from Gullesnuffs/MaxCutInapproximability
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
50 lines (36 loc) · 1.48 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
#include <boost/multiprecision/cpp_int.hpp>
using int_type = boost::multiprecision::cpp_int;
#include <iostream>
#include <vector>
#include "structured.h"
#include "config.h"
#include "gadget.h"
#include "optimizer.h"
#include "orbit.h"
#include "rational.h"
int main() {
std::cout << "Analyzing orbits of the symmetry group..." << std::endl;
OrbitInfo orbitInfo;
std::cout << "Finding all structured sets" << std::endl;
std::vector<bool> structuredSets = getAllStructuredSets();
long long i = 0;
for (long long ind = 0; ind < n_nodes; ++ind)
i += structuredSets[ind];
std::cout << "Found " << i << " nodes to consider" << std::endl;
EdgeOrbitInfo edgeOrbitInfo(orbitInfo, structuredSets);
Optimizer<int_type> optimizer;
Evaluator<int_type> evaluator(orbitInfo, edgeOrbitInfo);
std::cout << "Optimizing gadget..." << std::endl;
auto gadget = optimizer.gadgetSearch(orbitInfo, edgeOrbitInfo);
std::cout << "Finished optimizing gadget" << std::endl;
std::cout << gadget;
auto randomCost = evaluator.relaxedRandomCost(gadget);
int_type totalWeight = 0;
for (auto edgeOrbit : edgeOrbitInfo.edgeOrbits)
totalWeight += edgeOrbit.size() * gadget.getWeight(edgeOrbit[0]);
auto dictCost = Rational<int_type>(totalWeight, dimension);
auto inapproximabilityFactor = randomCost / dictCost;
std::cout << "The found gadget has inapproximability factor "
<< inapproximabilityFactor.a << "/" << inapproximabilityFactor.b
<< std::endl;
}