From 21ae722975055b009485fc20735493118bf4d147 Mon Sep 17 00:00:00 2001 From: iboyeau Date: Thu, 30 Mar 2023 08:13:48 +0200 Subject: [PATCH 1/2] correct "<" --- src/main/java/fr/ntr/AccessPoint.java | 50 ++++++++++++++++++--------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index ff0634d..9981739 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -66,7 +66,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(); @@ -86,25 +86,43 @@ public class AccessPoint { } } } + + // traite les données et les enregistre dans un fichier + + /* try { + analyseData(ticks); + } catch (IOException e) { + System.out.println("Can't export data"); + }*/ + } } + /* private void analyseData(int tick) throws IOException { - for(int i = 0; i < cell1.getFrame().length; i++) { - for(int j = 0; j < cell1.getFrame()[i].length; j++) { - ResourceBlock ur = cell1.getFrame()[i][j]; - if(ur.getUser() != null) { - String data = (tick + ";" + i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";\n"); - try{ - outputDataFile.write(data.getBytes()); - }catch(IOException e){ - System.err.println("Cannot write the data in the output file"); - System.exit(1); - return; - } + double delayAverage = 0.0; + int nbPacketsSent = 0; + for(User u: this.users){ + List packets = u.getPacketsSent(); + nbPacketsSent += packets.size(); + for (Packets p: packets){ + delayAverage += p.getDurationSending(); } } - } - } - */ + /*delayAverage = delayAverage/nbPacketsSent; + for(int i = 0; i < frame.length; i++) { + for(int j = 0; j < frame[i].length; j++) { + ResourceBlock ur = frame[i][j]; + if(ur.getUser() != null) { + String data = (tick + ";" + i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";" + delayAverage +";\n"); + try{ + outputDataFile.write(data.getBytes()); + }catch(IOException e){ + System.err.println("Cannot write the data in the output file"); + System.exit(1); + return; + } + } + } + }*/ } From f6407b1584aade0c220ce84d22fec92e1439f5c6 Mon Sep 17 00:00:00 2001 From: Loris Date: Thu, 30 Mar 2023 06:30:37 +0200 Subject: [PATCH 2/2] fixed comparison in computeInterference --- src/main/java/fr/ntr/AccessPoint.java | 6 +++--- src/main/java/fr/ntr/Main.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index 9981739..9569a6a 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -12,8 +12,8 @@ import fr.ntr.scheduler.Scheduler; public class AccessPoint { - private Cell cell1; - private Cell cell2; + private final Cell cell1; + private final Cell cell2; private List users; private FileOutputStream outputDataFile; @@ -75,7 +75,7 @@ public class AccessPoint { double bandwidth1 = frameCell1[k][l].getBandwidth(); double bandwidth2 = frameCell2[k][l].getBandwidth(); //User proche - if (user1.getDistance() > 200d) { + if (user1.getDistance() < 200d) { frameCell1[k][l].setBandwidth(bandwidth1 / 2); frameCell2[k][l].setBandwidth(bandwidth2 / 2); } diff --git a/src/main/java/fr/ntr/Main.java b/src/main/java/fr/ntr/Main.java index 8462de4..69b7bd2 100644 --- a/src/main/java/fr/ntr/Main.java +++ b/src/main/java/fr/ntr/Main.java @@ -25,7 +25,7 @@ public class Main { } int timeSlotNb = 2; int subCarrierNb = 100; - for(int i = 2; i < maximumLoad; i+=2) { + for(int i = 2; i < maximumLoad; i += 2) { List users = generateUsers(i, timeSlotNb, subCarrierNb); ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb]; //TODO : changes schedulers