-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsampler_f.cpp
More file actions
69 lines (65 loc) · 1.32 KB
/
sampler_f.cpp
File metadata and controls
69 lines (65 loc) · 1.32 KB
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
#include "sampler_f.h"
#include <fstream>
#include <sstream>
#include <iostream>
sampler_f::sampler_f()
{
n = 0;
}
sampler_f::~sampler_f()
{
}
void sampler_f::readF(char* infile)
{
ifstream fi(infile);
string s;
double x;
while (getline(fi,s))
{
stringstream ss(s);
f.push_back(vector<double>(0));
while (ss >> x)
f[n].push_back(x);
m = f[n].size();
++n;
}
cerr << n << " " << m << endl;
fi.close();
}
void sampler_f::init_seed(int32_t p_init, vector <uint64_t> &s_init)
{
rand_gen.init_seed(p_init,s_init);
}
vector <int> sampler_f::feature_polling(int32_t &n_fails, int &zcover, vector<bool> & seedMark, vector<bool> & cSeedMark)\
{
int s,t;
s = rand_gen.get_max(n);
while(1)
{
t = rand_gen.get_max(n);
if (s != t) break;
}
vector <int> res;
for (int i = 0; i <m; ++i)
if (rand_gen.get_real() <= f[s][i] && rand_gen.get_real() <= f[t][i])
// if (f[s][i] == 1)
res.push_back(i+1);
n_fails = 0;
zcover = 0;
bool t1 = false, t2 = false;
for (int i : res){
if (seedMark[i]){
zcover = zcover | 2;
t1 = true;
if (t2)
break;
}
if (cSeedMark[i]){
zcover = zcover | 1;
t2 = true;
if (t1)
break;
}
}
return res;
}