-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexperiment_flow_compute.py
51 lines (31 loc) · 1 KB
/
experiment_flow_compute.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
#!/usr/bin/python2
DIR = "plots/"
import mcrep
from matplotlib import pyplot as plt
import numpy as np
import matplotlib
import datetime
import pickle
import random
import os.path
adaptor = mcrep.adaptor.Adaptor('multichain_exp.csv')
#adaptor = mcrep.adaptor.Adaptor('test.csv')
graph = adaptor.create_interaction_graph()
print("Graph contains: " + str(len(graph.nodes())) + " nodes")
ordered_graph = adaptor.create_ordered_interaction_graph()
nodes = graph.nodes()
num_agents = len(nodes)
count = 0
scores = {}
for node in nodes:
fname = 'results/flow_scores_' + str(node)
if (os.path.isfile(fname)):
continue
algo = mcrep.netflow.Netflow(graph, identity=node, alpha=1.)
algo.compute()
count += 1
print "Computed " + str(count) + " out of " + str(num_agents*len(alphas))
print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
score_graph = algo.graph
with open('results/flow_scores_' + str(node), 'w') as f:
pickle.dump(score_graph, f)