-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconventional.py
36 lines (28 loc) · 1.1 KB
/
conventional.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
import math
class ConventionalMethod:
chi_factor = 1
bw = 20*100 # MHz
# choosen_network:
# 0: wifi
# 1: lifi
def __init__(self, chosen_network, snr_list, proportion_of_time):
self.name = 'convetional-method'
self.chosen_network = chosen_network
self.snr_list = snr_list
self.shannon_capacity_list = self.shannon_capacity(self.snr_list)
self.proportion_of_time = proportion_of_time
def shannon_capacity(self, snr_list):
shannon_capacity_list = []
for snr in snr_list:
shannon_capacity_list.append(self.bw*math.log2(1 + snr))
return shannon_capacity_list
def avg_throughput(self):
if (self.chosen_network == 1):
ans = 0
for i in range(len(self.snr_list)):
ans += self.chi_factor*self.proportion_of_time*self.shannon_capacity_list[i]
elif (self.chosen_network == 0):
ans = 0
for i in range(len(self.snr_list)):
ans += self.chi_factor*self.proportion_of_time*self.shannon_capacity_list[i]
return ans