-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCapacidad.py
More file actions
202 lines (156 loc) · 8.02 KB
/
Copy pathCapacidad.py
File metadata and controls
202 lines (156 loc) · 8.02 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import math
import GUI
import tkinter as tk
from tkinter import messagebox
class Eficiencia:
# Datos de CQI (tabla derecha de la imagen)
N_emplazamientos_voz = 0
N_emplazamientos_datos_mes = 0
N_emplazamientos_datos_instantaneo = 0
cqi_data = {
1: ("QPSK", 0.078, 2),
2: ("QPSK", 0.120, 2),
3: ("QPSK", 0.193, 2),
4: ("QPSK", 0.308, 2),
5: ("QPSK", 0.449, 2),
6: ("QPSK", 0.6016, 2),
7: ("16QAM", 0.378, 4),
8: ("16QAM", 0.490, 4),
9: ("16QAM", 0.616, 4),
10: ("64QAM", 0.466, 6),
11: ("64QAM", 0.567, 6),
12: ("64QAM", 0.666, 6),
13: ("64QAM", 0.772, 6),
14: ("64QAM", 0.873, 6),
15: ("64QAM", 0.948, 6),
}
# Lista para guardar elecciones
selected_cqis = []
assigned_percentages = []
eficiencia_espectral_unitaria = 0
eficiencia_espectral = 0
# Función al seleccionar un CQI
def select_cqi(self):
try:
cqi = int(GUI.cqi_selector.get())
percent = float(GUI.percent_entry.get())
except ValueError:
messagebox.showwarning("Error", "Introduce un valor válido.")
return
if percent <= 0 or percent > 100:
messagebox.showerror("Error", "El porcentaje debe estar entre 0 y 100.")
return
if cqi in self.selected_cqis:
messagebox.showinfo("Info", f"El CQI {cqi} ya ha sido seleccionado.")
return
total = sum(self.assigned_percentages) + percent
if total > 100:
messagebox.showerror("Error", f"El total de porcentaje excede 100%. Actualmente: {sum(self.assigned_percentages)}%.")
return
self.selected_cqis.append(cqi)
self.assigned_percentages.append(percent)
self.calculo_eficiencia(cqi,percent)
self.update_history_table()
def update_history_table(self):
# Limpia y actualiza la tabla de selección
for i in GUI.history_table.get_children():
GUI.history_table.delete(i)
for i, cqi in enumerate(self.selected_cqis):
mod, rate, bits = self.cqi_data[cqi]
GUI.history_table.insert("", "end", values=(cqi, mod, rate, bits, f"{self.assigned_percentages[i]}%"))
def calculo_eficiencia(self,cqi,percent):
mod, rate, bits = self.cqi_data[cqi]
tasa_binaria_CQI = 168*1e3 * rate * bits
eficiencia_espectral_unitaria = tasa_binaria_CQI/(200*1e3)
self.eficiencia_espectral += (eficiencia_espectral_unitaria * (percent/100))
GUI.eficiencia_var.set(self.eficiencia_espectral)
GUI.entry_Ef.delete(0,tk.END)
GUI.entry_Ef.insert(0,self.eficiencia_espectral)
def reset_all(self):
self.selected_cqis.clear()
self.assigned_percentages.clear()
self.update_history_table()
GUI.eficiencia_var.set("0")
GUI.cqi_selector.set("")
GUI.percent_entry.delete(0, tk.END)
self.eficiencia_espectral = 0
class Capacidad:
def erlang_b(self, A, N):
numerator = (A ** N) / math.factorial(N)
denominator = sum((A ** k) / math.factorial(k) for k in range(N + 1))
return numerator / denominator
def erlangs(self, N, Pb, epsilon=1e-4, max_A=2000, debug=False):
A = 0.0
while A < max_A:
Pb1 = self.erlang_b(A, N)
if debug:
print(f"Trying A={A:.4f}, Pb1={Pb1:.6f}")
if abs(Pb1 - Pb) < epsilon:
return A
A += 0.01
if debug:
print("No suitable A found within max_A")
return None
def calcular_capacidad_voz(self, Bv_MHz, Ef, RbCODEC_bps, trafico_usuario_mErlang, poblacion_cliente, Pb):
Bv_Hz = Bv_MHz * 1e6
N_canales_voz = (Bv_Hz * Ef) / (RbCODEC_bps * 1e3)
#print(f"N_canales_voz: {N_canales_voz}")
N_canales_voz_neto = int(N_canales_voz * 0.85) # restamos 15% para señalización
#print(f"N_canales_voz_neto: {N_canales_voz_neto}")
trafico_total_voz = self.erlangs(N_canales_voz_neto, Pb / 100)
print(f"trafico_total_voz: {trafico_total_voz}")
if trafico_total_voz is None:
print("Error: No se pudo calcular el tráfico total de voz. Verifique los parámetros de entrada.")
return None
trafico_usuario_Erlang = trafico_usuario_mErlang / 1000
#print(f"trafico_usuario_Erlang: {trafico_usuario_Erlang}")
if trafico_usuario_Erlang == 0:
print("Error: trafico_usuario_Erlang es cero, no se puede dividir.")
return None
N_usuarios_voz_sector = trafico_total_voz / trafico_usuario_Erlang
N_usuarios_voz_emplazamiento = N_usuarios_voz_sector * 3
if N_usuarios_voz_emplazamiento == 0:
print("Error: N_usuarios_voz_emplazamiento es cero, no se puede dividir.")
return None
N_emplazamientos_voz = poblacion_cliente / N_usuarios_voz_emplazamiento
return N_emplazamientos_voz
def calcular_capacidad_datos(self,Btotal_MHz, Bv_MHz, Ef, load_sector, Trafico_usuario_GB_mes, porcentaje_BH, poblacion_cliente, OveerbookingFactor, CapacidadInstantanea):
Bd_MHz = Btotal_MHz - Bv_MHz
C_T_Mbps = Ef * Bd_MHz
C_media_Mbps = C_T_Mbps * (load_sector/100)
C_media_Gbps = C_media_Mbps / 1000
Trafico_diario_BH_Gbps = ((Trafico_usuario_GB_mes / 30) * (porcentaje_BH/100) * (8)) / 3600
N_usuarios_sector_mes = C_media_Gbps / Trafico_diario_BH_Gbps
N_usuarios_emplazamiento_mes = N_usuarios_sector_mes * 3
N_emplazamientos_datos_mes = poblacion_cliente / N_usuarios_emplazamiento_mes
N_usuarios_sector_instantaneo = (C_media_Mbps/CapacidadInstantanea)*OveerbookingFactor
N_usuarios_emplazamiento_instantaneo = N_usuarios_sector_instantaneo * 3
N_emplazamientos_datos_instantaneo = poblacion_cliente / N_usuarios_emplazamiento_instantaneo
return N_emplazamientos_datos_mes, N_emplazamientos_datos_instantaneo
def calcular_capacidad(self):
val_Btotal_MHz = float(GUI.entry_Btotal_MHz.get())
val_Bv_MHz = float(GUI.entry_Bv_MHz.get())
val_Ef = float(GUI.entry_Ef.get())
val_Pb = float(GUI.entry_Pb.get())
val_RbCODEC_bps = float(GUI.entry_RbCODEC_bps.get())
val_trafico_usuario_mErlang = float(GUI.entry_trafico_usuario_mErlang.get())
val_Trafico_usuario_GB_mes = float(GUI.entry_Trafico_usuario_GB_mes.get())
val_porcentaje_BH = float(GUI.entry_porcentaje_BH.get())
val_load_sector = float(GUI.entry_load_sector.get())
val_poblacion_cliente = int(GUI.entry_poblacion_cliente.get())
val_OF = int(GUI.entry_OF.get())
val_Cu = float(GUI.entry_Cu.get())
self.N_emplazamientos_voz = self.calcular_capacidad_voz(val_Bv_MHz, val_Ef, val_RbCODEC_bps, val_trafico_usuario_mErlang, val_poblacion_cliente, val_Pb)
self.N_emplazamientos_datos_mes, self.N_emplazamientos_datos_instantaneo = self.calcular_capacidad_datos(val_Btotal_MHz, val_Bv_MHz, val_Ef, val_load_sector, val_Trafico_usuario_GB_mes, val_porcentaje_BH, val_poblacion_cliente, val_OF, val_Cu)
GUI.label_resultados1_set.configure(text= math.ceil(self.N_emplazamientos_voz))
GUI.label_resultados2_set.configure(text=math.ceil(self.N_emplazamientos_datos_mes))
GUI.label_resultados3_set.configure(text=math.ceil(self.N_emplazamientos_datos_instantaneo))
def calculodistanciacobertura(self):
EstacionesBase = math.ceil(max(self.N_emplazamientos_voz,self.N_emplazamientos_datos_mes,self.N_emplazamientos_datos_instantaneo))
print(EstacionesBase)
AreaT = float(GUI.entry_areacoberturacapacidad_manual.get())
AreaEfectiva = AreaT/EstacionesBase
d = math.sqrt(AreaEfectiva/1.95)
GUI.label_resultados4_set.configure(text=d)
ef = Eficiencia()
cap = Capacidad()