-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraph_space.py
75 lines (50 loc) · 1.99 KB
/
graph_space.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
#!/usr/bin/env python3
from __future__ import annotations
import functools
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from utils.graphing import savefig
plt.rcParams['text.usetex'] = True
plt.rcParams['font.size'] = 12
def graph_space(path_prefix: str):
fig = plt.figure()
ax = fig.gca()
def fn(v: int, c: int, t: int) -> int:
crypto = 160 * v
#trust = t * v + t * v * c
trust = t * v * c
reputation = v * trust
stereotype = t * v * c
return crypto + trust + reputation + stereotype
vcs = [
(10, 1),
(10, 2),
(20, 1),
(20, 2),
]
Xs = np.arange(1, 44, 1)
for (v, c) in vcs:
Ys = np.vectorize(functools.partial(fn, v, c))(Xs)
ax.plot(Xs, Ys, label=f"$|V|={v}$ $|C|={c}$")
ax.axhline(y=32*1024, label="Zolertia RE Mote total memory", color="red")
ax.axhline(y=(32 - 22)*1024, label="Zolertia RE Mote available memory", color="darkred")
#ax.axhline(y=256*1024, label="nRF52840 total memory", color="red")
#ax.axhline(y=(256 - 22)*1024, label="nRF52840 available memory", color="darkred")
ax.axvline(x=8, label="$T$ (BRS)", linestyle="--", color="tab:purple")
ax.axvline(x=40, label="$T$ (HMM with 2 states, 2 observations)", linestyle="--", color="tab:olive")
ax.set_xlabel('Trust model size (bytes)')
ax.set_ylabel('Total size (bytes)')
ax.set_ylim(top=(32+4)*1024)
ax.legend(bbox_to_anchor=(0.45, 1.325), loc="upper center", ncol=2)
savefig(fig, f"{path_prefix}space.pdf")
plt.close(fig)
def main(args):
graph_space(args.path_prefix)
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description='Analyse')
parser.add_argument('--path-prefix', type=str, default="",
help='The prefix to the location to output results')
args = parser.parse_args()
main(args)