-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathonepass-complete.py
126 lines (83 loc) · 2.87 KB
/
onepass-complete.py
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# testing different values of epsion - range [0.01 - 0.05, 0.1 - 0.15 ... 0.5]
def run_one_(biglst):
(graphname, network_data, S_size, partition_S, option, alpha, factor) = biglst
if partition_S == "ER":
n_groups = len(network_data.mapping_groups)
print(S_size, partition_S)
ki = int(S_size/n_groups)
output_partition = {cat: ki for cat in network_data.groups}
if partition_S == "PR":
output_partition = {cat:
int(S_size*network_data.proportions[cat])
for cat in network_data.groups}
k = S_size
print(output_partition)
path_ = "out/onepass/" + graphname + "/" + "new-strategy" + "/"
try:
os.makedirs(path_)
except:
pass
alpha = round(alpha,2)
beta = alpha
#filenames
config_onepass = [
"k" + str(k),"mode" + partition_S,"alpha" + str(alpha), "beta" + str(beta), "opt", option, "factor"+ str(factor)
]
filename = path_ + "-".join(config_onepass) + ".tsv"
check_files = glob.glob(path_ + "*")
if filename not in check_files:
print(filename)
onePass = Algorithms(network_data, filename)
onePass.output_partition = output_partition
onePass.k = k
onePass.fairOnepass(network_data, get_neighbors, delta_neighbors, alpha, beta, option, factor)
from multiprocessing import Process
from multiprocessing import Pool
from src.algorithms import Algorithms
from src.data import Data
from src.submodular import *
from src.config1 import *
import sys
import time
import os
import glob
import numpy as np
pokec1 = True
pokec2 = False
options = ["buffer-size"]
#option = options[int(sys.argv[1])]
# input
if pokec1:
# properties
directed=True
attribute = "gender"
datatype = "network"
graphname = "pokec-gender"
filename_nodes = "data/pokec/soc-pokec-profiles-filtered.txt"
filename_edgelist = "data/pokec/soc-pokec-relationships-filtered.txt"
# input
if pokec2:
# properties
directed=True
attribute = "age"
datatype = "network"
graphname = "pokec-age"
# input
filename_nodes = "data/pokec/age-nodes.txt"
filename_edgelist = "data/pokec/age-edges.txt"
# process input-data
network_data = Data()
network_data.directed = directed
network_data.threshold = None
network_data.datatype = datatype
network_data.initialize_profiles(filename_nodes, attribute)
network_data.mapping_neighbors(filename_edgelist)
N = len(network_data.mapping_id_to_attributes)
list_S_size = [x*10 for x in list_S_size]
#args = []
option = "buffer-size"
for S_size in list_S_size:
for partition_S in ["ER", "PR"]:
for factor in [2,4]:
one_arg = [graphname, network_data, S_size, partition_S, option, alpha, factor]
run_one_(one_arg)