diff --git a/src/main/java/fr/ntr/Main.java b/src/main/java/fr/ntr/Main.java index 5f2551f..f7b8430 100644 --- a/src/main/java/fr/ntr/Main.java +++ b/src/main/java/fr/ntr/Main.java @@ -1,5 +1,6 @@ package fr.ntr; +import fr.ntr.scheduler.MaxSNR; import fr.ntr.scheduler.RoundRobin; import fr.ntr.scheduler.Scheduler; @@ -26,7 +27,8 @@ public class Main { int subCarrierNb = 100; List users = generateUsers(maximumLoad, timeSlotNb, subCarrierNb); ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb]; - Scheduler scheduler = new RoundRobin("round robin", 0, frame, users); + //Scheduler scheduler = new RoundRobin("round robin", 0, frame, users); + Scheduler scheduler = new MaxSNR(frame, users); AccessPoint accessPoint = new AccessPoint(scheduler, frame, users, timeSlotNb, subCarrierNb, 0, 50); accessPoint.startSimulation(numberOfTicks); } diff --git a/src/main/java/fr/ntr/scheduler/MaxSNR.java b/src/main/java/fr/ntr/scheduler/MaxSNR.java index 21da04c..2d55916 100644 --- a/src/main/java/fr/ntr/scheduler/MaxSNR.java +++ b/src/main/java/fr/ntr/scheduler/MaxSNR.java @@ -10,15 +10,24 @@ public class MaxSNR extends Scheduler { private ResourceBlock[][] frame; + + public MaxSNR( ResourceBlock[][] frame, List users) { + this.frame = frame; + this.users = users; + } + @Override public void scheduling() { User userMax = null; for(int ts = 0; ts < 2; ts++){ for(int sp = 0; sp < 100; sp++){ userMax = selectionUtilisateur(sp, ts, users); - userMax.getPacketsSent().add(userMax.getPacketsToSend().get(0)); - userMax.getPacketsToSend().remove(userMax.getPacketsToSend().get(0)); - frame[ts][sp].setUser(selectionUtilisateur(sp, ts, users)); + if (userMax.getPacketsToSend().size() != 0) { + userMax.getPacketsSent().add(userMax.getPacketsToSend().get(0)); + userMax.getPacketsToSend().remove(userMax.getPacketsToSend().get(0)); + frame[ts][sp].setUser(userMax); + frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]); + } } } }