-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplexity.py
More file actions
88 lines (79 loc) · 2.89 KB
/
Copy pathcomplexity.py
File metadata and controls
88 lines (79 loc) · 2.89 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# -*- coding: utf-8 -*-
"""
@author: okarim
"""
import mi_rbn
import time
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
from tqdm import tqdm
from scipy import stats
if __name__ == '__main__':
__spec__ = "ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>)"
start_time = time.time()
N=100
p=0.5
T=1000
P = 5
Q = 4
number_of_iterations=1000
plt.title("Complexity")
plt.ylabel("Complexity")
plt.xlabel("K")
colors=['b', 'orange', 'g', 'brown', 'purple', 'olive', 'gray', 'pink', ]
i=0
rango=np.arange(1.1, 10.1, 0.2) #Por probar dK=0.5 y dK=1.0
for (netType, mode, period, dist) in [
# ("DGARBN", "Random"),
# ("Random", "outdegree"), ("Random", "ceil"),
## ("CRBN", "Complex", "", "Poisson"),
## ("CRBN", "Complex", "", "Exponential"),
# ("CRBN", "Complex", "", "Zipf"),
#("Complex", "ceil"),
#("Complex", ""),
# --------------------
# ("DGARBN", "Random", "", "Poisson"),
# ("DGARBN", "Complex", "", "Zipf"),
# ("DGARBN", "Complex", "", "Exponential"),
# --------------------
## ("DGARBN", "Complex", "outdegree", "Poisson"),
# ("DGARBN", "Complex", "outdegree", "Zipf"),
("DGARBN", "Complex", "outdegree", "Exponential")
]:
g1=[]
yerr=[]
for K in tqdm(rango):
print(netType, mode, dist)
print(K)
C=[]
for x in range(number_of_iterations):
red=mi_rbn.RBN(N, float(K), p)
param = ""
if dist == "Exponential":
param = float(K)
elif dist == "Zipf":
param = 2.0
if netType == "CRBN":
# red.CreateNetCRBN(mode)
red.CreateNetCRBN(mode, distribution=dist, parameter=param)
else:
red.CreateNetDGARBN(mode, P, Q, period, distribution=dist, parameter=param)
if netType == "CRBN":
State=red.RunNetCRBN(2*T)
else:
State=red.RunNetDGARBN(2*T)
C.append(np.mean(red.complexity(State[-T:])))
g1.append(np.mean(C))
yerr.append(C)
plt.errorbar(rango, g1, label=""+netType+" "+period + " - " + dist, yerr=stats.sem(yerr,1), ecolor='r', color=colors[i])
# plt.plot(rango, g1, label=""+netType+" "+dist)
i+=1
# plt.title("Average Complexity")
plt.ylim(top=1)
np.savez("/home/amahury/SI10_10.npz", g1)
plt.legend(prop={'size': 6}, loc='upper right')
plt.savefig("/home/amahury/SI10_10.png")
# plt.show()
print("--- %s seconds ---" % (time.time() - start_time))