-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStreamingGreedy.cpp
37 lines (31 loc) · 1.1 KB
/
StreamingGreedy.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
#include "StreamingGreedy.h"
StreamingGreedy::StreamingGreedy(Network *g) : Framework(g), no_queries(0) {}
StreamingGreedy::~StreamingGreedy() {}
double StreamingGreedy::get_solution(bool is_ds) {
kseeds seeds;
int no_nodes = g->get_no_nodes();
for (int u = 0; u < no_nodes; ++u) {
if (seeds.size() < Constants::BUDGET) {
double r = ((double)(Kcommon::getInstance()->randomInThread(
omp_get_thread_num()) %
10000)) /
10000;
if (r <= ((double)Constants::BUDGET) / no_nodes) { // select this element
double max = 0.0, i = 0;
for (int ii = 0; ii < Constants::K; ++ii) {
vector<pair<uint, uint>> seeds_tmp = seeds;
seeds_tmp.push_back(pair<uint, uint>(u, ii));
double est_F = estimate_influence(seeds_tmp);
no_queries++;
if (max < est_F) {
max = est_F;
i = ii;
}
}
seeds.push_back(kpoint(u, i));
}
}
}
return estimate_influence(seeds);
}
int StreamingGreedy::get_no_queries() { return no_queries; }