From 431248b0a45806aff521d83ab0d1c03e00ea2b87 Mon Sep 17 00:00:00 2001 From: Tr1xt4n Date: Thu, 13 Apr 2023 10:56:15 +0200 Subject: [PATCH] update main --- plot/main.py | 18 +++++++++++------- src/main/java/fr/ntr/Main.java | 9 ++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/plot/main.py b/plot/main.py index 6f38a55..b9d9058 100644 --- a/plot/main.py +++ b/plot/main.py @@ -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: allocate = np.zeros((size, 2)) nb = 0 + arr.sort() for nb_users, data in arr: n = 0 for x in data[:,6]: if int(x) == distance: n+=1 allocate[nb, 0] = nb_users - allocate[nb, 1] = n#(n/ (200 * 10000)) * 100 + allocate[nb, 1] = n + print(n/data.shape[0]) nb += 1 return allocate @@ -68,6 +70,9 @@ available = rb_available(np_arr) allocate_lp1 = rb_allocate_distance(np_arr, 200) allocate_lp2 = rb_allocate_distance(np_arr, 400) +allocate_total = allocate_lp1[:, 1] + allocate_lp2[:, 1] + +print(allocate_total) delays = delay(np_arr) 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].grid() -#ax[1, 1].scatter(available[:, 0], (available[:, 1]/available_lp1[:, 1]/available_lp2[:, 1])*100) - 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].grid() +plt.ylim(0, 100) plt.show() \ No newline at end of file diff --git a/src/main/java/fr/ntr/Main.java b/src/main/java/fr/ntr/Main.java index 8431425..d15e277 100644 --- a/src/main/java/fr/ntr/Main.java +++ b/src/main/java/fr/ntr/Main.java @@ -2,6 +2,7 @@ package fr.ntr; import fr.ntr.scheduler.MaxSNR; import fr.ntr.scheduler.ProportionalFair; +import fr.ntr.scheduler.RoundRobin; import fr.ntr.scheduler.Scheduler; import java.io.File; @@ -50,9 +51,9 @@ public class Main { for(int i = 2; i <= maximumLoad; i += 2) { List users = generateUsers(i, timeSlotNb, subCarrierNb); ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb]; - // Scheduler scheduler = new MaxSNR(frame, users); - Scheduler scheduler = new ProportionalFair(frame, users); - // Scheduler scheduler = new RoundRobin(frame, users); + //Scheduler scheduler = new MaxSNR(frame, users); + //Scheduler scheduler = new ProportionalFair(frame, users); + Scheduler scheduler = new RoundRobin(frame, users); AccessPoint accessPoint = new AccessPoint(scheduler, frame, users); executor.submit(() -> accessPoint.startSimulation(numberOfTicks)); } @@ -84,4 +85,6 @@ public class Main { return users; } + + } \ No newline at end of file