diff --git a/plot/main.py b/plot/main.py index a666898..8d7118f 100644 --- a/plot/main.py +++ b/plot/main.py @@ -57,23 +57,17 @@ delays.sort(axis=0) # Data for plotting averages.sort(axis=0) -fig, ax = plt.subplots() -ax.scatter(averages[:, 0], averages[:, 1]) +fig, ax = plt.subplots(2, 2) +ax[0, 0].scatter(averages[:, 0], averages[:, 1]) +ax[0, 0].set(xlabel='number of users', ylabel='Efficacité spectrale', title='Efficacité spectrale') +ax[0, 0].grid() -ax.set(xlabel='number of users', ylabel='Efficacité spectrale', title='Efficacité spectrale') -ax.grid() +ax[0, 1].scatter(available[:, 0], available[:, 1]) +ax[0, 1].set(xlabel='number of users', ylabel='RB utilisés', title='Pourcentage de RB utilisés') +ax[0, 1].grid() -# fig.savefig("test.png") -plt.show() +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() -fig, ax = plt.subplots() -ax.scatter(available[:, 0], available[:, 1]) -ax.set(xlabel='number of users', ylabel='RB utilisés', title='Pourcentage de RB utilisés') -ax.grid() -plt.show() - -fig, ax = plt.subplots() -ax.scatter(delays[:, 0], delays[:, 1]) -ax.set(xlabel='number of users', ylabel='delays(ms)', title='Delay') -ax.grid() -plt.show() +plt.show() \ No newline at end of file diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index fb4d279..5a9e2c0 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -28,7 +28,7 @@ public class AccessPoint { cell1.schedule(ticks); cell2.schedule(ticks); //simulation des interférences - // computeInterference(); + computeInterference(); // traite les données et les enregistre dans un fichier try { cell1.analyseData(ticks); @@ -44,7 +44,7 @@ public class AccessPoint { ResourceBlock[][] frameCell1 = cell1.getFrame(); ResourceBlock[][] frameCell2 = cell2.getFrame(); - for (int k = 0; k < frameCell1.length; k++ ) { + for (int k = 0; k < frameCell1.length; k++) { for (int l = 0; l < frameCell1[k].length; l++) { //interférences si les deux cellules parlent au même UE sur le même time slot User user1 = frameCell1[k][l].getUser(); diff --git a/src/main/java/fr/ntr/scheduler/MaxSNR.java b/src/main/java/fr/ntr/scheduler/MaxSNR.java index 4d240e2..d64d164 100644 --- a/src/main/java/fr/ntr/scheduler/MaxSNR.java +++ b/src/main/java/fr/ntr/scheduler/MaxSNR.java @@ -1,6 +1,7 @@ package fr.ntr.scheduler; import java.util.List; +import fr.ntr.Cell; import fr.ntr.ResourceBlock; import fr.ntr.User; @@ -43,12 +44,11 @@ public class MaxSNR extends Scheduler { private User userSelection(int ts, int sp) { double maxSnr = 0.0; User userMax = null; - for(User u: users){ - if(!u.getPacketsToSend().isEmpty()) { - if (maxSnr < u.getBandwidthTable()[ts][sp]) { - maxSnr = u.getBandwidthTable()[ts][sp]; - userMax = u; - } + for(User u: users) { + if (!u.getPacketsToSend().isEmpty() && (maxSnr < u.getBandwidthTable()[ts][sp])) { + maxSnr = u.getBandwidthTable()[ts][sp]; + userMax = u; + } } return userMax; diff --git a/src/main/java/fr/ntr/scheduler/ProportionalFair.java b/src/main/java/fr/ntr/scheduler/ProportionalFair.java index 2d7f8bc..0f67d61 100644 --- a/src/main/java/fr/ntr/scheduler/ProportionalFair.java +++ b/src/main/java/fr/ntr/scheduler/ProportionalFair.java @@ -22,7 +22,7 @@ public class ProportionalFair extends Scheduler { @Override public void scheduling(int ticks) { - ArrayList averageBandwiths = new ArrayList(); + ArrayList averageBandwiths = new ArrayList<>(); for(User u : users){ double avg = 0d; double[][] bandwidthTable = u.getBandwidthTable(); @@ -57,5 +57,5 @@ public class ProportionalFair extends Scheduler { } return selectedUser; } - + } diff --git a/src/main/java/fr/ntr/scheduler/Scheduler.java b/src/main/java/fr/ntr/scheduler/Scheduler.java index 066d506..7dd8c45 100644 --- a/src/main/java/fr/ntr/scheduler/Scheduler.java +++ b/src/main/java/fr/ntr/scheduler/Scheduler.java @@ -33,18 +33,8 @@ public abstract class Scheduler { } } Packets p = userMax.getPacketsToSend().get(userMax.getPacketsToSend().size()-1); - if(p.getBitsNumberRemaining() >= 0){ - p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]); - if(p.getBitsNumberRemaining() <= 0) { - if(ticks == 0){ - p.setDurationSending(1); - }else { - p.setDurationSending(ticks); - } - userMax.getPacketsSent().add(p); - userMax.getPacketsToSend().remove(p); - } - } else { + p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]); + if(p.getBitsNumberRemaining() <= 0) { if(ticks == 0){ p.setDurationSending(1); }else {