Changements par rapport à l'ajout d'une 2ème cellule
This commit is contained in:
parent
06f3e82c4a
commit
41f50c9e83
@ -8,21 +8,17 @@ public class AccessPoint {
|
|||||||
|
|
||||||
private final Cell cell1;
|
private final Cell cell1;
|
||||||
private final Cell cell2;
|
private final Cell cell2;
|
||||||
private final List<Cell> cellList;
|
|
||||||
|
|
||||||
public AccessPoint(Cell cell1, Cell cell2){
|
public AccessPoint(Cell cell1, Cell cell2){
|
||||||
this.cell1 = cell1;
|
this.cell1 = cell1;
|
||||||
this.cell2 = cell2;
|
this.cell2 = cell2;
|
||||||
cellList = new ArrayList<>();
|
|
||||||
cellList.add(cell1);
|
|
||||||
cellList.add(cell2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lancer la simulation
|
* Lancer la simulation
|
||||||
* @param duration
|
* @param duration
|
||||||
*/
|
*/
|
||||||
public void startSimulation(int duration, List<User> users) {
|
public void startSimulation(int duration) {
|
||||||
for (int ticks = 0; ticks < duration; ++ticks) {
|
for (int ticks = 0; ticks < duration; ++ticks) {
|
||||||
// Simulation
|
// Simulation
|
||||||
cell1.reset();
|
cell1.reset();
|
||||||
@ -35,8 +31,8 @@ public class AccessPoint {
|
|||||||
// computeInterference();
|
// computeInterference();
|
||||||
// traite les données et les enregistre dans un fichier
|
// traite les données et les enregistre dans un fichier
|
||||||
try {
|
try {
|
||||||
cell1.analyseData(ticks, users);
|
cell1.analyseData(ticks);
|
||||||
cell2.analyseData(ticks, users);
|
cell2.analyseData(ticks);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Can't export data");
|
System.out.println("Can't export data");
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class Cell {
|
|||||||
scheduler.scheduling(tick);
|
scheduler.scheduling(tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void analyseData(int tick, List<User> users) throws IOException {
|
public void analyseData(int tick) throws IOException {
|
||||||
double delayAverage = 0.0;
|
double delayAverage = 0.0;
|
||||||
int nbPacketsSent = 0;
|
int nbPacketsSent = 0;
|
||||||
for(User u: users){
|
for(User u: users){
|
||||||
|
@ -55,19 +55,23 @@ public class Main {
|
|||||||
Cell.setSubCarrierNb(subCarrierNb);
|
Cell.setSubCarrierNb(subCarrierNb);
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||||
for(int i = 2; i <= maximumLoad; i += 2) {
|
for(int i = 2; i <= maximumLoad; i += 2) {
|
||||||
List<User> users = generateUsers(i, timeSlotNb, subCarrierNb);
|
List<User> usersCell1 = generateUsers(i, timeSlotNb, subCarrierNb);
|
||||||
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
|
List<User> usersCell2 = generateUsers(i, timeSlotNb, subCarrierNb);
|
||||||
|
|
||||||
|
ResourceBlock[][] frame1 = new ResourceBlock[timeSlotNb][subCarrierNb];
|
||||||
|
ResourceBlock[][] frame2 = new ResourceBlock[timeSlotNb][subCarrierNb];
|
||||||
|
|
||||||
//TODO : changes schedulers
|
//TODO : changes schedulers
|
||||||
Scheduler schedulerCell1 = new RoundRobin(frame, users);
|
Scheduler schedulerCell1 = new RoundRobin(frame1, frame2, usersCell1);
|
||||||
Scheduler schedulerCell2 = new RoundRobin(frame, users);
|
Scheduler schedulerCell2 = new RoundRobin(frame2, frame1, usersCell2);
|
||||||
try{
|
try{
|
||||||
FileOutputStream output = new FileOutputStream("export" + File.separator + users.size() + ".csv", true);
|
FileOutputStream output = new FileOutputStream("export" + File.separator + (usersCell1.size()+usersCell2.size()) + ".csv", true);
|
||||||
output.write("tick;x;y;user;bandwidth;delay;cell;\n".getBytes());
|
output.write("tick;x;y;user;bandwidth;delay;cell;\n".getBytes());
|
||||||
|
|
||||||
Cell cell1 = new Cell(0, schedulerCell1, frame, users, output);
|
Cell cell1 = new Cell(0, schedulerCell1, frame1, usersCell1, output);
|
||||||
Cell cell2 = new Cell(1, schedulerCell2, frame, users, output);
|
Cell cell2 = new Cell(1, schedulerCell2, frame2, usersCell2, output);
|
||||||
AccessPoint accessPoint = new AccessPoint(cell1, cell2);
|
AccessPoint accessPoint = new AccessPoint(cell1, cell2);
|
||||||
executor.submit(() -> accessPoint.startSimulation(numberOfTicks, users));
|
executor.submit(() -> accessPoint.startSimulation(numberOfTicks));
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
System.err.println(e.getClass().getSimpleName() + " : " + e.getMessage());
|
System.err.println(e.getClass().getSimpleName() + " : " + e.getMessage());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
@ -90,7 +94,7 @@ public class Main {
|
|||||||
private static List<User> generateUsers(int nbUsers, int timeSlotNb, int subCarrierNb) {
|
private static List<User> generateUsers(int nbUsers, int timeSlotNb, int subCarrierNb) {
|
||||||
List<User> users = new ArrayList<>();
|
List<User> users = new ArrayList<>();
|
||||||
// 2 groupes d'utilisateurs, proches et éloignés
|
// 2 groupes d'utilisateurs, proches et éloignés
|
||||||
double[] distance = { 200d, 400d };
|
double[] distance = { 150d, 500d };
|
||||||
for (double v : distance) {
|
for (double v : distance) {
|
||||||
for (int j = 0; j < nbUsers; j++) {
|
for (int j = 0; j < nbUsers; j++) {
|
||||||
User user = new User(v, timeSlotNb, subCarrierNb);
|
User user = new User(v, timeSlotNb, subCarrierNb);
|
||||||
|
@ -7,10 +7,12 @@ import fr.ntr.User;
|
|||||||
public class MaxSNR extends Scheduler {
|
public class MaxSNR extends Scheduler {
|
||||||
|
|
||||||
private final List<User> users;
|
private final List<User> users;
|
||||||
private final ResourceBlock[][] frame;
|
private final ResourceBlock[][] myFrame;
|
||||||
|
private final ResourceBlock[][] neighborFrame;
|
||||||
|
|
||||||
public MaxSNR( ResourceBlock[][] frame, List<User> users) {
|
public MaxSNR(ResourceBlock[][] myFrame, ResourceBlock[][] neighborFrame, List<User> users) {
|
||||||
this.frame = frame;
|
this.myFrame = myFrame;
|
||||||
|
this.neighborFrame = neighborFrame;
|
||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,7 +22,14 @@ public class MaxSNR extends Scheduler {
|
|||||||
for(int ts = 0; ts < 2; ts++){
|
for(int ts = 0; ts < 2; ts++){
|
||||||
for(int sp = 0; sp < 100; sp++){
|
for(int sp = 0; sp < 100; sp++){
|
||||||
userMax = userSelection(ts, sp);
|
userMax = userSelection(ts, sp);
|
||||||
allocateRessource(userMax, frame, ts, sp, ticks);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,12 @@ public class ProportionalFair extends Scheduler {
|
|||||||
|
|
||||||
private final List<User> users;
|
private final List<User> users;
|
||||||
|
|
||||||
private final ResourceBlock[][] frame;
|
private final ResourceBlock[][] myFrame;
|
||||||
|
private final ResourceBlock[][] neighborFrame;
|
||||||
|
|
||||||
public ProportionalFair(ResourceBlock[][] frame, List<User> users) {
|
public ProportionalFair(ResourceBlock[][] myFrame, ResourceBlock[][] neighborFrame, List<User> users) {
|
||||||
this.frame = frame;
|
this.myFrame = myFrame;
|
||||||
|
this.neighborFrame = neighborFrame;
|
||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +37,7 @@ public class ProportionalFair extends Scheduler {
|
|||||||
for(int ts = 0; ts < 2; ts++){
|
for(int ts = 0; ts < 2; ts++){
|
||||||
for(int sp = 0; sp < 100; sp++){
|
for(int sp = 0; sp < 100; sp++){
|
||||||
User selectedUser = userSelection(ts, sp, users, averageBandwiths);
|
User selectedUser = userSelection(ts, sp, users, averageBandwiths);
|
||||||
allocateRessource(selectedUser, frame, ts, sp, ticks);
|
allocateRessource(selectedUser, myFrame, neighborFrame, ts, sp, ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,13 @@ import fr.ntr.User;
|
|||||||
public class RoundRobin extends Scheduler {
|
public class RoundRobin extends Scheduler {
|
||||||
|
|
||||||
private final List<User> users;
|
private final List<User> users;
|
||||||
private final ResourceBlock[][] frame;
|
private final ResourceBlock[][] myFrame;
|
||||||
|
private final ResourceBlock[][] neighborFrame;
|
||||||
|
|
||||||
public RoundRobin(ResourceBlock[][] frame, List<User> users) {
|
|
||||||
this.frame = frame;
|
public RoundRobin(ResourceBlock[][] myFrame, ResourceBlock[][] neighborFrame, List<User> users) {
|
||||||
|
this.myFrame = myFrame;
|
||||||
|
this.neighborFrame = neighborFrame;
|
||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +38,7 @@ public class RoundRobin extends Scheduler {
|
|||||||
break loop;
|
break loop;
|
||||||
}
|
}
|
||||||
User userSelected = userSelection(userCopy);
|
User userSelected = userSelection(userCopy);
|
||||||
allocateRessource(userSelected, frame, ts, sp, ticks);
|
allocateRessource(userSelected, myFrame, neighborFrame, ts, sp, ticks);
|
||||||
if(!userSelected.getPacketsToSend().isEmpty())
|
if(!userSelected.getPacketsToSend().isEmpty())
|
||||||
userCopy.add(userSelected);
|
userCopy.add(userSelected);
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,25 @@ public abstract class Scheduler {
|
|||||||
*/
|
*/
|
||||||
public abstract void scheduling(int ticks);
|
public abstract void scheduling(int ticks);
|
||||||
|
|
||||||
protected void allocateRessource(User userMax, ResourceBlock[][] frame, int ts, int sp, int ticks) {
|
protected void allocateRessource(User userMax, ResourceBlock[][] myFrame, ResourceBlock[][] neighborFrame, int ts, int sp, int ticks) {
|
||||||
|
ResourceBlock rb1 = myFrame[ts][sp];
|
||||||
|
ResourceBlock rb2 = neighborFrame[ts][sp];
|
||||||
if (userMax != null && !userMax.getPacketsToSend().isEmpty()) {
|
if (userMax != null && !userMax.getPacketsToSend().isEmpty()) {
|
||||||
|
User user2 = rb2.getUser();
|
||||||
|
if ((userMax != null || user2 != null) && userMax == user2) {
|
||||||
|
double bandwidth1 = rb1.getBandwidth();
|
||||||
|
double bandwidth2 = rb2.getBandwidth();
|
||||||
|
//User proche
|
||||||
|
if (userMax.getDistance() < 200d) {
|
||||||
|
rb1.getUser().getBandwidthTable()[ts][sp] = bandwidth1 / 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Packets p = userMax.getPacketsToSend().get(userMax.getPacketsToSend().size()-1);
|
Packets p = userMax.getPacketsToSend().get(userMax.getPacketsToSend().size()-1);
|
||||||
if(p.getBitsNumberRemaining() >= 0){
|
if(p.getBitsNumberRemaining() >= 0){
|
||||||
p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]);
|
p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]);
|
||||||
@ -36,8 +53,8 @@ public abstract class Scheduler {
|
|||||||
userMax.getPacketsSent().add(p);
|
userMax.getPacketsSent().add(p);
|
||||||
userMax.getPacketsToSend().remove(p);
|
userMax.getPacketsToSend().remove(p);
|
||||||
}
|
}
|
||||||
frame[ts][sp].setUser(userMax);
|
myFrame[ts][sp].setUser(userMax);
|
||||||
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
|
myFrame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user