-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
73 lines (54 loc) · 2.14 KB
/
main.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
from multihop.Network import *
import matplotlib.pyplot as plt
import random
import pandas as pd
import logging
from multihop.config import settings
import multihop.utils
random.seed(5555)
np.random.seed(19680801)
logging.getLogger().setLevel(logging.WARNING)
network = Network(shape="circles", size_x=100, size_y=100, n_x=3, n_y=20)
# network = Network(shape="funnel", size_x=100, size_y=0, levels=[1, 4, 2])
# network.nodes[6].position = Position(79, 38)
# network.nodes[7].position = Position(62, 66)
# network.update()
network.plot_network()
filename = "results/simulate_funnel_size_aggregation_timer.csv"
setting = "TX_AGGREGATION_TIMER_NOMINAL"
values = range(1*60, 2*60, 2*60)
sizes = range(1, 10, 1)
pdr = {}
plr = {}
aggregation_efficiency = {}
energy = {}
for value in values:
settings.update({setting: value})
for size in sizes:
network = Network(shape="funnel", size_x=100, size_y=0, levels=[1, 1, size])
network.plot_network()
network.run(60*30)
if value not in pdr:
pdr[value] = {}
plr[value] = {}
aggregation_efficiency[value] = {}
energy[value] = {}
pdr[value][size] = network.hops_statistic("pdr")
plr[value][size] = network.hops_statistic("plr")
aggregation_efficiency[value][size] = network.hops_statistic("aggregation_efficiency")
energy[value][size] = network.hops_statistic("energy")
df = pd.DataFrame(flatten_data(2,
[pdr, plr, aggregation_efficiency, energy],
[setting, "size", "hops", ["pdr", "plr", "aggregation_efficiency", "energy"]]))
# Only interested in the middle node
df = df[df.hops == 0]
df.to_csv(filename)
fig, ax = plt.subplots()
for key, grp in df.groupby([setting]):
data = grp.groupby('size', as_index=False)['energy'].agg({'low': 'min', 'high': 'max', 'mean': 'mean'})
data.reset_index(inplace=True)
data.plot(ax=ax, x='size', y='mean', label=key)
#plt.fill_between(x='size', y1='low', y2='high', alpha=0.3, data=data)
plt.show()
test = "test"
plt.show()