Compare commits
No commits in common. "d114314ba13ef5d38c6f1e13e0e3c48bf321e10d" and "797b2a17f7ea97730fbd5344108fca5476f4e6e4" have entirely different histories.
d114314ba1
...
797b2a17f7
61
plot/main.py
61
plot/main.py
@ -3,7 +3,7 @@ import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
nb_files = os.listdir("PF")
|
||||
nb_files = os.listdir(".." + os.sep + "export")
|
||||
|
||||
size = len(nb_files)
|
||||
|
||||
@ -29,7 +29,7 @@ def rb_available(arr: list[tuple[int, np.ndarray]]) -> np.ndarray:
|
||||
nb = 0
|
||||
for nb_users, data in arr:
|
||||
available[nb, 0] = nb_users
|
||||
available[nb, 1] = (data.shape[0] / (200 * 20000)) * 100
|
||||
available[nb, 1] = (data.shape[0] / (200 * 10000)) * 100
|
||||
nb += 1
|
||||
return available
|
||||
|
||||
@ -46,71 +46,30 @@ def delay(arr: list[tuple[int, np.ndarray]]) -> np.ndarray:
|
||||
return delays
|
||||
|
||||
|
||||
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
|
||||
# print(n/data.shape[0])
|
||||
nb += 1
|
||||
return allocate
|
||||
|
||||
|
||||
np_arr: list[tuple[int, np.ndarray]] = list()
|
||||
for i in nb_files:
|
||||
np_arr.append((int(i.split(".")[0]), pd.read_csv("PF" + os.sep + i, delimiter=';').to_numpy()))
|
||||
np_arr.append((int(i.split(".")[0]), pd.read_csv(".." + os.sep + "export" + os.sep + i, delimiter=';').to_numpy()))
|
||||
|
||||
averages = mean_mkn(np_arr)
|
||||
available = rb_available(np_arr)
|
||||
|
||||
allocate_lp1 = rb_allocate_distance(np_arr, 100)
|
||||
allocate_lp2 = rb_allocate_distance(np_arr, 500)
|
||||
allocate_total = allocate_lp1[:, 1] + allocate_lp2[:, 1]
|
||||
|
||||
delays = delay(np_arr)
|
||||
delays.sort(axis=0)
|
||||
# Data for plotting
|
||||
averages.sort(axis=0)
|
||||
available.sort(axis=0)
|
||||
|
||||
del np_arr
|
||||
|
||||
fig, ax = plt.subplots(2, 2)
|
||||
ax[0, 0].plot(averages[:, 0], averages[:, 1], marker="o")
|
||||
ax[0, 0].set(xlabel='number of users', ylabel='% Spectral efficiency', title='Spectral efficiency PF')
|
||||
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[0, 0].set_ylim([0, 40])
|
||||
|
||||
ax[0, 1].plot(available[:, 0], available[:, 1], marker="o")
|
||||
ax[0, 1].set(xlabel='number of users', ylabel=' % RB used', title='Percentage of RB used PF')
|
||||
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()
|
||||
ax[0, 1].set_ylim([0, 105])
|
||||
|
||||
ax[1, 0].plot(delays[:, 0], delays[:, 1], marker="o")
|
||||
ax[1, 0].set(xlabel='number of users', ylabel='delay(ms)', title='Delay PF')
|
||||
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()
|
||||
|
||||
available.sort(axis=0)
|
||||
|
||||
#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), label="100 meters group")
|
||||
|
||||
#ax[1, 1].scatter(allocate_lp2[:, 0], (allocate_lp2[:, 1]/(allocate_lp1[:, 1])+allocate_lp2[:, 1])*100)
|
||||
|
||||
#ax[1, 1].plot(available[:, 0], available[:, 1], marker="o", label="RB used")
|
||||
|
||||
ax[1, 1].plot(available[:, 0], (allocate_lp2[:, 1]/(allocate_lp1[:, 1]+allocate_lp2[:, 1])*100), label="500 meters group")
|
||||
|
||||
ax[1, 1].set(xlabel='number of users', ylabel='% RB used', title='RB used depending on the distance PF')
|
||||
ax[1, 1].grid()
|
||||
ax[1, 1].set_ylim([0, 105])
|
||||
ax[1, 1].legend(loc="upper left")
|
||||
|
||||
plt.show()
|
||||
plt.show()
|
@ -1,18 +1,17 @@
|
||||
package fr.ntr;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class AccessPoint {
|
||||
|
||||
private final List<Cell> cells;
|
||||
private final Cell cell1;
|
||||
private final Cell cell2;
|
||||
|
||||
private final boolean reuse3;
|
||||
private final Boolean reuse3 = false;
|
||||
|
||||
public AccessPoint (boolean reuse3, Cell... cells){
|
||||
this.reuse3 = reuse3;
|
||||
this.cells = Arrays.stream(cells).toList();
|
||||
public AccessPoint (Cell cell1, Cell cell2){
|
||||
this.cell1 = cell1;
|
||||
this.cell2 = cell2;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -22,40 +21,35 @@ public class AccessPoint {
|
||||
public void startSimulation (int duration) {
|
||||
for (int ticks = 0; ticks < duration; ++ticks) {
|
||||
// Simulation
|
||||
cells.forEach(Cell::reset);
|
||||
cell1.reset();
|
||||
cell2.reset();
|
||||
|
||||
int finalTicks = ticks;
|
||||
cells.forEach(c -> c.updateBandwidth(finalTicks));
|
||||
cells.forEach(Cell::preScheduling);
|
||||
cell1.updateBandwidth(ticks);
|
||||
cell2.updateBandwidth(ticks);
|
||||
cell1.preScheduling();
|
||||
cell2.preScheduling();
|
||||
for(int ts = 0; ts < Cell.getTimeSlotNb(); ts++) {
|
||||
for (int sp = 0; sp < (reuse3 ? Cell.getSubCarrierNb() / 2 : Cell.getSubCarrierNb()); sp++) {
|
||||
User user1 = cells.get(0).schedule(ticks, ts, sp);
|
||||
if(cells.size() > 1) {
|
||||
User user2 = cells.get(1).schedule(ticks, ts, (reuse3 ? 50 : 0) + sp);
|
||||
//FIXME pour avoir 20
|
||||
for (int sp = 0; sp < (reuse3 ? Cell.getSubCarrierNb() : Cell.getSubCarrierNb()/2); sp++) {
|
||||
User user1 = cell1.schedule(ticks, ts, sp);
|
||||
User user2 = cell2.schedule(ticks, ts, reuse3 ? 0 : 50 + sp);
|
||||
boolean haveInterference = user1 == user2 && user1 != null;
|
||||
int finalTs = ts;
|
||||
int finalSp = sp;
|
||||
cells.forEach(c -> c.consumeResource(finalTicks, finalTs, finalSp, haveInterference));
|
||||
cells.get(0).postScheduling(user1);
|
||||
cells.get(1).postScheduling(user2);
|
||||
} else {
|
||||
cells.get(0).consumeResource(ticks, ts, sp, false);
|
||||
cells.get(0).postScheduling(user1);
|
||||
}
|
||||
cell1.consumeResource(ticks, ts, sp, haveInterference);
|
||||
cell2.consumeResource(ticks, ts, sp, haveInterference);
|
||||
|
||||
cell1.postScheduling(user1);
|
||||
cell2.postScheduling(user2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// traite les données et les enregistre dans un fichier
|
||||
int finalTicks1 = ticks;
|
||||
cells.forEach(c -> {
|
||||
try {
|
||||
c.analyseData(finalTicks1);
|
||||
} catch (IOException e) {
|
||||
System.err.println("IO Error: " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
});
|
||||
try {
|
||||
cell1.analyseData(ticks);
|
||||
cell2.analyseData(ticks);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Can't export data");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public class Cell {
|
||||
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 +";" + ur.getUser().getDistance() + ";" + id + "\n");
|
||||
String data = (tick + ";" + i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";" + delayAverage +";" + id + "\n");
|
||||
try{
|
||||
outputDataFile.write(data.getBytes());
|
||||
}catch(IOException e){
|
||||
|
@ -13,7 +13,6 @@ import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Main {
|
||||
|
||||
@ -86,14 +85,14 @@ public class Main {
|
||||
try {
|
||||
//préparation à exportation des données de chaque cellule
|
||||
FileOutputStream output = new FileOutputStream("export" + File.separator + (usersCell1.size()) + ".csv", true);
|
||||
output.write("tick;x;y;user;bandwidth;delay;distance;cell;\n".getBytes());
|
||||
output.write("tick;x;y;user;bandwidth;delay;cell;\n".getBytes());
|
||||
|
||||
//création des cellules
|
||||
Cell cell1 = new Cell(0, schedulerCell1, frame1, usersCell1, output);
|
||||
Cell cell2 = new Cell(1, schedulerCell2, frame2, usersCell2, output);
|
||||
|
||||
//création de l'AccessPoint
|
||||
AccessPoint accessPoint = new AccessPoint(false, cell1, cell2);
|
||||
AccessPoint accessPoint = new AccessPoint(cell1, cell2);
|
||||
executor.submit(() -> accessPoint.startSimulation(numberOfTicks));
|
||||
}
|
||||
catch (IOException e) {
|
||||
@ -101,15 +100,7 @@ public class Main {
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
executor.shutdown();
|
||||
try {
|
||||
executor.awaitTermination(5, TimeUnit.MINUTES);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
executor.shutdownNow();
|
||||
|
||||
executor.close();
|
||||
System.out.println("Executor closed");
|
||||
}
|
||||
else {
|
||||
|
16
src/main/java/fr/ntr/Reuse/Reuse1.java
Normal file
16
src/main/java/fr/ntr/Reuse/Reuse1.java
Normal file
@ -0,0 +1,16 @@
|
||||
package fr.ntr.Reuse;
|
||||
|
||||
import fr.ntr.Cell;
|
||||
import fr.ntr.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Reuse1 {
|
||||
|
||||
public static void BandwithReuse1(List<Cell> cellList, int tick) {
|
||||
for (Cell cell : cellList) {
|
||||
cell.updateBandwidth(tick);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
16
src/main/java/fr/ntr/Reuse/Reuse3.java
Normal file
16
src/main/java/fr/ntr/Reuse/Reuse3.java
Normal file
@ -0,0 +1,16 @@
|
||||
package fr.ntr.Reuse;
|
||||
import fr.ntr.Cell;
|
||||
import fr.ntr.ResourceBlock;
|
||||
import fr.ntr.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Reuse3 {
|
||||
|
||||
public static void BandwithReuse3(List<Cell> cellList, int tick) {
|
||||
for (Cell cell : cellList) {
|
||||
|
||||
cell.updateBandwidth(tick);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user