Change scheduler to RR
This commit is contained in:
parent
d646be8a6e
commit
5f18a8f3ea
@ -37,15 +37,15 @@ public class AccessPoint {
|
|||||||
* Lancer la simulation
|
* Lancer la simulation
|
||||||
* @param duration
|
* @param duration
|
||||||
*/
|
*/
|
||||||
public void startSimulation(int duration) {
|
public void startSimulation(int duration, List<User> users) {
|
||||||
/*try{
|
try{
|
||||||
this.outputDataFile = new FileOutputStream("export" + File.separator + this.users.size() + ".csv", true);
|
this.outputDataFile = new FileOutputStream("export" + File.separator + users.size() + ".csv", true);
|
||||||
outputDataFile.write("tick;x;y;user;bandwidth;delay;\n".getBytes());
|
outputDataFile.write("tick;x;y;user;bandwidth;delay;\n".getBytes());
|
||||||
} 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);
|
||||||
return;
|
return;
|
||||||
} */
|
}
|
||||||
for (int ticks = 0; ticks < duration; ++ticks) {
|
for (int ticks = 0; ticks < duration; ++ticks) {
|
||||||
// Simulation
|
// Simulation
|
||||||
cell1.reset();
|
cell1.reset();
|
||||||
@ -58,7 +58,7 @@ 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 {
|
||||||
analyseData(ticks);
|
analyseData(ticks, users);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Can't export data");
|
System.out.println("Can't export data");
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ public class AccessPoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void computeInterference () {
|
public void computeInterference() {
|
||||||
ResourceBlock[][] frameCell1 = cell1.getFrame();
|
ResourceBlock[][] frameCell1 = cell1.getFrame();
|
||||||
ResourceBlock[][] frameCell2 = cell2.getFrame();
|
ResourceBlock[][] frameCell2 = cell2.getFrame();
|
||||||
|
|
||||||
@ -93,10 +93,10 @@ public class AccessPoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void analyseData(int tick) throws IOException {
|
private void analyseData(int tick, List<User> users) throws IOException {
|
||||||
/*double delayAverage = 0.0;
|
/* double delayAverage = 0.0;
|
||||||
int nbPacketsSent = 0;
|
int nbPacketsSent = 0;
|
||||||
for(User u: this.users){
|
for(User u: users){
|
||||||
List<Packets> packets = u.getPacketsSent();
|
List<Packets> packets = u.getPacketsSent();
|
||||||
nbPacketsSent += packets.size();
|
nbPacketsSent += packets.size();
|
||||||
for (Packets p: packets){
|
for (Packets p: packets){
|
||||||
|
@ -9,7 +9,7 @@ public class Cell {
|
|||||||
|
|
||||||
private final List<User> users;
|
private final List<User> users;
|
||||||
/**
|
/**
|
||||||
* scheduler utilisé par la cellule
|
* Scheduler utilisé par la cellule
|
||||||
*/
|
*/
|
||||||
private final Scheduler scheduler;
|
private final Scheduler scheduler;
|
||||||
/**
|
/**
|
||||||
@ -24,13 +24,6 @@ public class Cell {
|
|||||||
* Trame
|
* Trame
|
||||||
*/
|
*/
|
||||||
private final ResourceBlock[][] frame;
|
private final ResourceBlock[][] frame;
|
||||||
/**
|
|
||||||
* Reste pour la prochaine source
|
|
||||||
*/
|
|
||||||
private double leftForNextSource;
|
|
||||||
|
|
||||||
private final Random random = new Random();
|
|
||||||
|
|
||||||
public Cell(Scheduler scheduler, ResourceBlock[][] frame, List<User> users) {
|
public Cell(Scheduler scheduler, ResourceBlock[][] frame, List<User> users) {
|
||||||
this.users = users;
|
this.users = users;
|
||||||
this.scheduler = scheduler;
|
this.scheduler = scheduler;
|
||||||
|
@ -56,13 +56,13 @@ public class Main {
|
|||||||
List<User> users = generateUsers(i, timeSlotNb, subCarrierNb);
|
List<User> users = generateUsers(i, timeSlotNb, subCarrierNb);
|
||||||
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
|
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
|
||||||
//TODO : changes schedulers
|
//TODO : changes schedulers
|
||||||
Scheduler schedulerCell1 = new MaxSNR(frame, users);
|
Scheduler schedulerCell1 = new RoundRobin(frame, users);
|
||||||
Scheduler schedulerCell2 = new MaxSNR(frame, users);
|
Scheduler schedulerCell2 = new RoundRobin(frame, users);
|
||||||
|
|
||||||
Cell cell1 = new Cell(schedulerCell1, frame, users);
|
Cell cell1 = new Cell(schedulerCell1, frame, users);
|
||||||
Cell cell2 = new Cell(schedulerCell2, frame, users);
|
Cell cell2 = new Cell(schedulerCell2, frame, users);
|
||||||
AccessPoint accessPoint = new AccessPoint(cell1, cell2);
|
AccessPoint accessPoint = new AccessPoint(cell1, cell2);
|
||||||
executor.submit(() -> accessPoint.startSimulation(numberOfTicks));
|
executor.submit(() -> accessPoint.startSimulation(numberOfTicks, users));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user