update main

This commit is contained in:
Tr1xt4n 2023-04-13 10:56:15 +02:00
parent cc73eb8a93
commit 431248b0a4
2 changed files with 17 additions and 10 deletions

View File

@ -48,13 +48,15 @@ def delay(arr: list[tuple[int, np.ndarray]]) -> np.ndarray:
def rb_allocate_distance(arr: list[tuple[int, np.ndarray]], distance) -> np.ndarray: def rb_allocate_distance(arr: list[tuple[int, np.ndarray]], distance) -> np.ndarray:
allocate = np.zeros((size, 2)) allocate = np.zeros((size, 2))
nb = 0 nb = 0
arr.sort()
for nb_users, data in arr: for nb_users, data in arr:
n = 0 n = 0
for x in data[:,6]: for x in data[:,6]:
if int(x) == distance: if int(x) == distance:
n+=1 n+=1
allocate[nb, 0] = nb_users allocate[nb, 0] = nb_users
allocate[nb, 1] = n#(n/ (200 * 10000)) * 100 allocate[nb, 1] = n
print(n/data.shape[0])
nb += 1 nb += 1
return allocate return allocate
@ -68,6 +70,9 @@ available = rb_available(np_arr)
allocate_lp1 = rb_allocate_distance(np_arr, 200) allocate_lp1 = rb_allocate_distance(np_arr, 200)
allocate_lp2 = rb_allocate_distance(np_arr, 400) allocate_lp2 = rb_allocate_distance(np_arr, 400)
allocate_total = allocate_lp1[:, 1] + allocate_lp2[:, 1]
print(allocate_total)
delays = delay(np_arr) delays = delay(np_arr)
delays.sort(axis=0) delays.sort(axis=0)
@ -87,19 +92,18 @@ ax[1, 0].scatter(delays[:, 0], delays[:, 1])
ax[1, 0].set(xlabel='number of users', ylabel='delays(ms)', title='Delay') ax[1, 0].set(xlabel='number of users', ylabel='delays(ms)', title='Delay')
ax[1, 0].grid() ax[1, 0].grid()
#ax[1, 1].scatter(available[:, 0], (available[:, 1]/available_lp1[:, 1]/available_lp2[:, 1])*100)
available.sort(axis=0) available.sort(axis=0)
ax[1, 1].scatter(available[:, 0], (allocate_lp1[:, 1]/(allocate_lp1[:, 1] + allocate_lp2[:, 1]))*100) #ax[1, 1].scatter(allocate_lp1[:, 0], (allocate_lp1[:, 1]/(allocate_lp1[:, 1])+allocate_lp2[:, 1])*100)
ax[1, 1].plot(available[:, 0], (allocate_lp1[:, 1]/(allocate_lp1[:, 1] + allocate_lp2[:, 1]))*100) ax[1, 1].plot(available[:, 0], (allocate_lp1[:, 1]/(allocate_lp1[:, 1]+allocate_lp2[:, 1])*100))
ax[1, 1].scatter(available[:, 0], (allocate_lp2[:, 1]/(allocate_lp1[:, 1] + allocate_lp2[:, 1]))*100) #ax[1, 1].scatter(allocate_lp2[:, 0], (allocate_lp2[:, 1]/(allocate_lp1[:, 1])+allocate_lp2[:, 1])*100)
ax[1, 1].plot(available[:, 0], (allocate_lp2[:, 1]/(allocate_lp1[:, 1] + allocate_lp2[:, 1]))*100) ax[1, 1].plot(available[:, 0], (allocate_lp2[:, 1]/(allocate_lp1[:, 1]+allocate_lp2[:, 1])*100))
ax[1, 1].set(xlabel='number of users', ylabel='RB utilisés proche/loin/total', title='RB utilisés distance') ax[1, 1].set(xlabel='number of users', ylabel='RB utilisés proche/loin/total', title='RB utilisés distance')
ax[1, 1].grid() ax[1, 1].grid()
plt.ylim(0, 100)
plt.show() plt.show()

View File

@ -2,6 +2,7 @@ package fr.ntr;
import fr.ntr.scheduler.MaxSNR; import fr.ntr.scheduler.MaxSNR;
import fr.ntr.scheduler.ProportionalFair; import fr.ntr.scheduler.ProportionalFair;
import fr.ntr.scheduler.RoundRobin;
import fr.ntr.scheduler.Scheduler; import fr.ntr.scheduler.Scheduler;
import java.io.File; import java.io.File;
@ -50,9 +51,9 @@ public class Main {
for(int i = 2; i <= maximumLoad; i += 2) { for(int i = 2; i <= maximumLoad; i += 2) {
List<User> users = generateUsers(i, timeSlotNb, subCarrierNb); List<User> users = generateUsers(i, timeSlotNb, subCarrierNb);
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb]; ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
// Scheduler scheduler = new MaxSNR(frame, users); //Scheduler scheduler = new MaxSNR(frame, users);
Scheduler scheduler = new ProportionalFair(frame, users); //Scheduler scheduler = new ProportionalFair(frame, users);
// Scheduler scheduler = new RoundRobin(frame, users); Scheduler scheduler = new RoundRobin(frame, users);
AccessPoint accessPoint = new AccessPoint(scheduler, frame, users); AccessPoint accessPoint = new AccessPoint(scheduler, frame, users);
executor.submit(() -> accessPoint.startSimulation(numberOfTicks)); executor.submit(() -> accessPoint.startSimulation(numberOfTicks));
} }
@ -84,4 +85,6 @@ public class Main {
return users; return users;
} }
} }