From f93b1c4c22508172689ca048c45ba8bc68f32343 Mon Sep 17 00:00:00 2001 From: iboyeau Date: Tue, 4 Apr 2023 16:59:45 +0200 Subject: [PATCH] add space and maj reuse3 --- src/main/java/fr/ntr/AccessPoint.java | 31 ++----------------- src/main/java/fr/ntr/Main.java | 22 ++++++++----- src/main/java/fr/ntr/scheduler/MaxSNR.java | 8 ----- src/main/java/fr/ntr/scheduler/Scheduler.java | 10 ++---- 4 files changed, 20 insertions(+), 51 deletions(-) diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index 792b207..aac6f42 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -9,7 +9,7 @@ public class AccessPoint { private final Cell cell1; private final Cell cell2; - public AccessPoint(Cell cell1, Cell cell2){ + public AccessPoint (Cell cell1, Cell cell2){ this.cell1 = cell1; this.cell2 = cell2; } @@ -18,7 +18,7 @@ public class AccessPoint { * Lancer la simulation * @param duration */ - public void startSimulation(int duration) { + public void startSimulation (int duration) { for (int ticks = 0; ticks < duration; ++ticks) { // Simulation cell1.reset(); @@ -39,31 +39,4 @@ public class AccessPoint { } } - - public void computeInterference() { - ResourceBlock[][] frameCell1 = cell1.getFrame(); - ResourceBlock[][] frameCell2 = cell2.getFrame(); - - 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(); - User user2 = frameCell2[k][l].getUser(); - if ((user1 != null || user2 != null) && user1 == user2) { - double bandwidth1 = frameCell1[k][l].getBandwidth(); - double bandwidth2 = frameCell2[k][l].getBandwidth(); - //User proche - if (user1.getDistance() < 200d) { - frameCell1[k][l].getUser().getBandwidthTable()[k][l] = bandwidth1 / 2; - frameCell2[k][l].getUser().getBandwidthTable()[k][l] = bandwidth2 / 2; - } - //User loin - else { - frameCell1[k][l].getUser().getBandwidthTable()[k][l] = bandwidth1 / 4; - frameCell2[k][l].getUser().getBandwidthTable()[k][l] = bandwidth2 / 4; - } - } - } - } - } } diff --git a/src/main/java/fr/ntr/Main.java b/src/main/java/fr/ntr/Main.java index 7753cf0..cfbcd6b 100644 --- a/src/main/java/fr/ntr/Main.java +++ b/src/main/java/fr/ntr/Main.java @@ -16,13 +16,13 @@ import java.util.concurrent.TimeUnit; public class Main { - public static void main(String[] args) { - if(args.length == 2) { + public static void main (String[] args) { + if (args.length == 2) { int numberOfTicks; // Nombre de ticks de la simulation -> durée de la simulation int maximumLoad; // Nombre maximal d'utilisateurs dans le système - //TODO make this cleanly + boolean isReuse3 = false; //reuse 1 par défaut sinon reuse 3 int nbcell = 2; //nombre de cellules que l'on va utiliser @@ -39,11 +39,19 @@ public class Main { //instancie nombre de time slots et sous-porteuses int timeSlotNb = 2; - int subCarrierNb = 100; + //nb subcarrier si reuse1 ou reuse3 + int subCarrierNb; + if (isReuse3) { + subCarrierNb = 100 / nbcell; + } + else{ + subCarrierNb = 100; + } + //préparation pour exportation des données File folder = new File("export"); - if(!folder.exists() && !folder.mkdir()) { + if (!folder.exists() && !folder.mkdir()) { System.err.println("Cannot create export folder"); System.exit(1); } @@ -59,7 +67,7 @@ public class Main { Cell.setTimeSlotNb(timeSlotNb); Cell.setSubCarrierNb(subCarrierNb); ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); - for(int i = 2; i <= maximumLoad; i += 2) { + for (int i = 2; i <= maximumLoad; i += 2) { //génération des utilisateurs List usersCell1 = generateUsers(i, timeSlotNb, subCarrierNb); List usersCell2 = generateUsers(i, timeSlotNb, subCarrierNb); @@ -86,7 +94,7 @@ public class Main { AccessPoint accessPoint = new AccessPoint(cell1, cell2); executor.submit(() -> accessPoint.startSimulation(numberOfTicks)); } - catch(IOException e) { + catch (IOException e) { System.err.println(e.getClass().getSimpleName() + " : " + e.getMessage()); System.exit(1); } diff --git a/src/main/java/fr/ntr/scheduler/MaxSNR.java b/src/main/java/fr/ntr/scheduler/MaxSNR.java index d64d164..46e02b7 100644 --- a/src/main/java/fr/ntr/scheduler/MaxSNR.java +++ b/src/main/java/fr/ntr/scheduler/MaxSNR.java @@ -26,13 +26,6 @@ public class MaxSNR extends Scheduler { allocateRessource(userMax, myFrame, neighborFrame, ts, sp, ticks); } } - - for(int ts = 0; ts < 2; ts++){ - for(int sp = 0; sp < 100; sp++){ - userMax = userSelection(ts, sp); - allocateRessource(userMax, myFrame, neighborFrame, ts, sp, ticks); - } - } } /** @@ -48,7 +41,6 @@ public class MaxSNR extends Scheduler { 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/Scheduler.java b/src/main/java/fr/ntr/scheduler/Scheduler.java index 7dd8c45..799b911 100644 --- a/src/main/java/fr/ntr/scheduler/Scheduler.java +++ b/src/main/java/fr/ntr/scheduler/Scheduler.java @@ -6,11 +6,7 @@ import fr.ntr.User; public abstract class Scheduler { - /** - * Entry - * Rempli la trame avec les utilisateurs - * Return - */ + public abstract void scheduling(int ticks); protected void allocateRessource(User userMax, ResourceBlock[][] myFrame, ResourceBlock[][] neighborFrame, int ts, int sp, int ticks) { @@ -24,12 +20,12 @@ public abstract class Scheduler { //User proche if (userMax.getDistance() < 200d) { rb1.getUser().getBandwidthTable()[ts][sp] = bandwidth1 / 2; - rb2.getUser().getBandwidthTable()[ts][sp] = bandwidth2 / 2; + //rb2.getUser().getBandwidthTable()[ts][sp] = bandwidth2 / 2; } //User loin else { rb1.getUser().getBandwidthTable()[ts][sp] = bandwidth1 / 4; - rb2.getUser().getBandwidthTable()[ts][sp] = bandwidth2 / 4; + //rb2.getUser().getBandwidthTable()[ts][sp] = bandwidth2 / 4; } } Packets p = userMax.getPacketsToSend().get(userMax.getPacketsToSend().size()-1);