Improve pf performances
This commit is contained in:
parent
05d51acdc0
commit
b073d58f21
@ -1,6 +1,7 @@
|
|||||||
package fr.ntr;
|
package fr.ntr;
|
||||||
|
|
||||||
import fr.ntr.scheduler.MaxSNR;
|
import fr.ntr.scheduler.MaxSNR;
|
||||||
|
import fr.ntr.scheduler.ProportionalFair;
|
||||||
import fr.ntr.scheduler.Scheduler;
|
import fr.ntr.scheduler.Scheduler;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -49,8 +50,8 @@ public class Main {
|
|||||||
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> users = generateUsers(i, timeSlotNb, subCarrierNb);
|
||||||
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
|
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
|
||||||
Scheduler scheduler = new MaxSNR(frame, users);
|
// Scheduler scheduler = new MaxSNR(frame, users);
|
||||||
// Scheduler scheduler = new ProportionalFair(frame, users);
|
Scheduler scheduler = new ProportionalFair(frame, users);
|
||||||
// Scheduler scheduler = new RoundRobin(frame, users);
|
// Scheduler scheduler = new RoundRobin(frame, users);
|
||||||
AccessPoint accessPoint = new AccessPoint(scheduler, frame, users);
|
AccessPoint accessPoint = new AccessPoint(scheduler, frame, users);
|
||||||
executor.submit(() -> accessPoint.startSimulation(numberOfTicks));
|
executor.submit(() -> accessPoint.startSimulation(numberOfTicks));
|
||||||
|
@ -3,15 +3,15 @@ package fr.ntr.scheduler;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.ntr.AccessPoint;
|
||||||
import fr.ntr.ResourceBlock;
|
import fr.ntr.ResourceBlock;
|
||||||
import fr.ntr.User;
|
import fr.ntr.User;
|
||||||
|
|
||||||
public class ProportionalFair extends Scheduler {
|
public class ProportionalFair extends Scheduler {
|
||||||
|
|
||||||
|
private final List<User> users;
|
||||||
|
|
||||||
private List<User> users;
|
private final ResourceBlock[][] frame;
|
||||||
|
|
||||||
private ResourceBlock[][] frame;
|
|
||||||
|
|
||||||
public ProportionalFair(ResourceBlock[][] frame, List<User> users) {
|
public ProportionalFair(ResourceBlock[][] frame, List<User> users) {
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
@ -20,35 +20,29 @@ public class ProportionalFair extends Scheduler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scheduling(int ticks) {
|
public void scheduling(int ticks) {
|
||||||
ArrayList<Double> averageBandwiths = new ArrayList<Double>();
|
for(int ts = 0; ts < AccessPoint.getTimeSlotNb(); ts++){
|
||||||
for(User u : users){
|
for(int sp = 0; sp < AccessPoint.getSubCarrierNb(); sp++){
|
||||||
double avg = 0d;
|
User selectedUser = userSelection(ts, sp, users);
|
||||||
double[][] bandwidthTable = u.getBandwidthTable();
|
|
||||||
for(int i = 0; i < bandwidthTable.length; i++){
|
|
||||||
for(int j = 0; j < bandwidthTable[i].length; j++){
|
|
||||||
avg += bandwidthTable[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
avg = avg / (bandwidthTable.length * bandwidthTable[0].length);
|
|
||||||
averageBandwiths.add(avg);
|
|
||||||
}
|
|
||||||
for(int ts = 0; ts < 2; ts++){
|
|
||||||
for(int sp = 0; sp < 100; sp++){
|
|
||||||
User selectedUser = userSelection(ts, sp, users, averageBandwiths);
|
|
||||||
allocateRessource(selectedUser, frame, ts, sp, ticks);
|
allocateRessource(selectedUser, frame, ts, sp, ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private User userSelection(int ts, int sp, List<User> users, List<Double> averageBandwiths) {
|
private User userSelection(int ts, int sp, List<User> users) {
|
||||||
double PF = 0.0;
|
double PF = 0.0;
|
||||||
User selectedUser = null;
|
User selectedUser = null;
|
||||||
for(int i = 0; i < users.size(); i++){
|
for (User u : users) {
|
||||||
User u = users.get(i);
|
double avg = 0d;
|
||||||
|
double[][] bandwidthTable = u.getBandwidthTable();
|
||||||
|
for (double[] doubles : bandwidthTable) {
|
||||||
|
for (double aDouble : doubles) {
|
||||||
|
avg += aDouble;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
avg = avg / (bandwidthTable.length * bandwidthTable[0].length);
|
||||||
double mkn = u.getBandwidthTable()[ts][sp];
|
double mkn = u.getBandwidthTable()[ts][sp];
|
||||||
double averageMkn = averageBandwiths.get(i);
|
double pf = mkn / avg;
|
||||||
double pf = mkn / averageMkn;
|
if (PF < pf) {
|
||||||
if (PF < pf){
|
|
||||||
PF = pf;
|
PF = pf;
|
||||||
selectedUser = u;
|
selectedUser = u;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user