-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_polynomial_emgenpa.cpp
93 lines (74 loc) · 2.88 KB
/
main_polynomial_emgenpa.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
#include <tlx/cmdline_parser.hpp>
#include <skewedpa/utils/Polynomial.hpp>
#include <skewedpa/decisiontrees/DTreeDeque.hpp>
#include <skewedpa/decisiontrees/DTreeFixedLeaves.hpp>
#include <skewedpa/decisiontrees/DTreeSplit.hpp>
#include <skewedpa/algorithms/externalmemory/GeneralizedPATFP.hpp>
#include <skewedpa/ScopedTimer.hpp>
template <typename ValueType>
struct Identity {
using value_type = ValueType;
using distribution_type = std::uniform_int_distribution<value_type>;
value_type operator() (value_type v) const {
return v;
}
static value_type dist_max(value_type weight) {
return weight - 1;
}
};
struct EdgeOutMock {
size_t count = 0;
public:
EdgeOutMock() {}
void push(edge_t e) {
++count;
tlx::unused(e);
}
size_t size() const {
return count;
}
};
int main(int argc, const char** argv) {
tlx::CmdlineParser cp;
cp.set_description("Benchmark for EM-GenPA");
size_t ell = 10;
cp.add_size_t("ell", ell, "Number of incoming edges per node");
size_t ldexp = 36;
cp.add_size_t("ldexp", ldexp, "Double of lower exponent");
size_t udexp = 56;
cp.add_size_t("udexp", udexp, "Double of upper exponent");
size_t repeats = 3;
cp.add_size_t("repeats", repeats, "Repeats");
double alpha = 1.;
cp.add_double("alpha", alpha, "Polynomial exponent");
if (!cp.process(argc, argv)) {
return -1;
}
NetworKit::Graph g(2 * ell);
g.addEdge(0, 2 * ell - 1);
for (size_t c = 1; c < 2 * ell; ++c) {
g.addEdge(c - 1, c);
}
using DTreeFixedLeavesType = skewedpa::DTreeFixedLeaves<node_t, Polynomial>;
using DTreeDequeType = skewedpa::DTreeDeque<node_t, Polynomial>;
using DTreeSplitType = skewedpa::DTreeSplit<node_t, Polynomial, DTreeFixedLeavesType, DTreeDequeType>;
using AlgoType = skewedpa::GeneralizedPATFP<DTreeSplitType, EdgeOutMock, 16 * sizeof(node_t)>;
std::random_device rd;
Polynomial p(alpha);
for (size_t exp = ldexp; exp <= udexp; ++exp) {
for (size_t j = 0; j < repeats; ++j) {
double halfexp = exp / 2.;
const auto n = static_cast<node_t>(std::pow(2, halfexp));
EdgeOutMock out_mock;
AlgoType skewedpatfp(g, n, ell, p, out_mock);
size_t algoseed = rd();
std::cout << algoseed << std::endl;
incpwl::ScopedTimer timer("[seq?: " + std::to_string(false) + ", n: " + std::to_string(n) + ", d: " + std::to_string(ell) + "]\n");
std::mt19937_64 gen(algoseed);
skewedpatfp.run(gen);
std::cout << "Edges produced: " << out_mock.size() << std::endl;
std::cout << "EM-GenPA, " << alpha << ", " << n << ", " << (n * ell) << ", " << timer.elapsedSeconds() << std::endl;
}
}
return 0;
}