Merge branch 'master' into ajout_cellule
This commit is contained in:
commit
3b012adf61
@ -1,6 +1,7 @@
|
|||||||
package fr.ntr.scheduler;
|
package fr.ntr.scheduler;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.ntr.Cell;
|
||||||
import fr.ntr.ResourceBlock;
|
import fr.ntr.ResourceBlock;
|
||||||
import fr.ntr.User;
|
import fr.ntr.User;
|
||||||
|
|
||||||
@ -17,8 +18,8 @@ public class MaxSNR extends Scheduler {
|
|||||||
@Override
|
@Override
|
||||||
public void scheduling(int ticks) {
|
public void scheduling(int ticks) {
|
||||||
User userMax;
|
User userMax;
|
||||||
for(int ts = 0; ts < 2; ts++){
|
for(int ts = 0; ts < Cell.getTimeSlotNb(); ts++){
|
||||||
for(int sp = 0; sp < 100; sp++){
|
for(int sp = 0; sp < Cell.getSubCarrierNb(); sp++){
|
||||||
userMax = userSelection(ts, sp);
|
userMax = userSelection(ts, sp);
|
||||||
allocateRessource(userMax, frame, ts, sp, ticks);
|
allocateRessource(userMax, frame, ts, sp, ticks);
|
||||||
}
|
}
|
||||||
@ -35,11 +36,10 @@ public class MaxSNR extends Scheduler {
|
|||||||
double maxSnr = 0.0;
|
double maxSnr = 0.0;
|
||||||
User userMax = null;
|
User userMax = null;
|
||||||
for(User u: users) {
|
for(User u: users) {
|
||||||
if(!u.getPacketsToSend().isEmpty()) {
|
if (!u.getPacketsToSend().isEmpty() && (maxSnr < u.getBandwidthTable()[ts][sp])) {
|
||||||
if (maxSnr < u.getBandwidthTable()[ts][sp]) {
|
|
||||||
maxSnr = u.getBandwidthTable()[ts][sp];
|
maxSnr = u.getBandwidthTable()[ts][sp];
|
||||||
userMax = u;
|
userMax = u;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return userMax;
|
return userMax;
|
||||||
|
@ -20,7 +20,7 @@ public class ProportionalFair extends Scheduler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scheduling(int ticks) {
|
public void scheduling(int ticks) {
|
||||||
ArrayList<Double> averageBandwiths = new ArrayList<Double>();
|
ArrayList<Double> averageBandwiths = new ArrayList<>();
|
||||||
for(User u : users){
|
for(User u : users){
|
||||||
double avg = 0d;
|
double avg = 0d;
|
||||||
double[][] bandwidthTable = u.getBandwidthTable();
|
double[][] bandwidthTable = u.getBandwidthTable();
|
||||||
|
@ -16,7 +16,6 @@ public abstract class Scheduler {
|
|||||||
protected void allocateRessource(User userMax, ResourceBlock[][] frame, int ts, int sp, int ticks) {
|
protected void allocateRessource(User userMax, ResourceBlock[][] frame, int ts, int sp, int ticks) {
|
||||||
if (userMax != null && !userMax.getPacketsToSend().isEmpty()) {
|
if (userMax != null && !userMax.getPacketsToSend().isEmpty()) {
|
||||||
Packets p = userMax.getPacketsToSend().get(userMax.getPacketsToSend().size()-1);
|
Packets p = userMax.getPacketsToSend().get(userMax.getPacketsToSend().size()-1);
|
||||||
if(p.getBitsNumberRemaining() >= 0){
|
|
||||||
p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]);
|
p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]);
|
||||||
if(p.getBitsNumberRemaining() <= 0) {
|
if(p.getBitsNumberRemaining() <= 0) {
|
||||||
if(ticks == 0){
|
if(ticks == 0){
|
||||||
@ -27,15 +26,6 @@ public abstract class Scheduler {
|
|||||||
userMax.getPacketsSent().add(p);
|
userMax.getPacketsSent().add(p);
|
||||||
userMax.getPacketsToSend().remove(p);
|
userMax.getPacketsToSend().remove(p);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if(ticks == 0){
|
|
||||||
p.setDurationSending(1);
|
|
||||||
}else {
|
|
||||||
p.setDurationSending(ticks);
|
|
||||||
}
|
|
||||||
userMax.getPacketsSent().add(p);
|
|
||||||
userMax.getPacketsToSend().remove(p);
|
|
||||||
}
|
|
||||||
frame[ts][sp].setUser(userMax);
|
frame[ts][sp].setUser(userMax);
|
||||||
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
|
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user