PF scheduling
This commit is contained in:
parent
2c1c2819f3
commit
b597d68597
@ -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.RoundRobin;
|
import fr.ntr.scheduler.RoundRobin;
|
||||||
import fr.ntr.scheduler.Scheduler;
|
import fr.ntr.scheduler.Scheduler;
|
||||||
|
|
||||||
@ -28,7 +29,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);
|
||||||
AccessPoint accessPoint = new AccessPoint(scheduler, frame, users, timeSlotNb, subCarrierNb, 0, 50);
|
AccessPoint accessPoint = new AccessPoint(scheduler, frame, users, timeSlotNb, subCarrierNb, 0, 50);
|
||||||
accessPoint.startSimulation(numberOfTicks);
|
accessPoint.startSimulation(numberOfTicks);
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,63 @@
|
|||||||
package fr.ntr.scheduler;
|
package fr.ntr.scheduler;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.ntr.ResourceBlock;
|
||||||
import fr.ntr.User;
|
import fr.ntr.User;
|
||||||
|
|
||||||
public class ProportionalFair extends Scheduler {
|
public class ProportionalFair extends Scheduler {
|
||||||
|
private List<User> users;
|
||||||
|
|
||||||
private String name;
|
private ResourceBlock[][] frame;
|
||||||
private int index;
|
|
||||||
|
|
||||||
public ProportionalFair(String name, int index) {
|
public ProportionalFair(ResourceBlock[][] frame, List<User> users) {
|
||||||
this.name = name;
|
this.frame = frame;
|
||||||
this.index = index;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scheduling() {
|
public void scheduling() {
|
||||||
|
ArrayList<Double> averageBandwiths = new ArrayList<Double>();
|
||||||
|
for(User u : users){
|
||||||
|
double avg = 0d;
|
||||||
|
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(new Double(avg));
|
||||||
|
}
|
||||||
|
User selectedUser = null;
|
||||||
|
for(int ts = 0; ts < 2; ts++){
|
||||||
|
for(int sp = 0; sp < 100; sp++){
|
||||||
|
selectedUser = selectionUtilisateur(ts, sp, users, averageBandwiths);
|
||||||
|
if (selectedUser.getPacketsToSend().size() != 0) {
|
||||||
|
selectedUser.getPacketsSent().add(selectedUser.getPacketsToSend().get(0));
|
||||||
|
selectedUser.getPacketsToSend().remove(selectedUser.getPacketsToSend().get(0));
|
||||||
|
frame[ts][sp].setUser(selectedUser);
|
||||||
|
frame[ts][sp].setBandwidth(selectedUser.getBandwidthTable()[ts][sp]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectionUtilisateur(int Ts, int Sp, List<User> Users) {
|
private User selectionUtilisateur(int ts, int sp, List<User> users, List<Double> averageBandwiths) {
|
||||||
|
double PF = 0.0;
|
||||||
|
User selectedUser = null;
|
||||||
|
for(int i = 0; i < users.size(); i++){
|
||||||
|
User u = users.get(i);
|
||||||
|
double mkn = u.getBandwidthTable()[ts][sp];
|
||||||
|
double averageMkn = averageBandwiths.get(i);
|
||||||
|
double pf = mkn / averageMkn;
|
||||||
|
if (PF < pf){
|
||||||
|
PF = pf;
|
||||||
|
selectedUser = u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selectedUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void TraitementDonnees() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user