Fix userSelection in RR
This commit is contained in:
parent
6442356450
commit
c778fcb6da
10
plot/main.py
10
plot/main.py
@ -33,16 +33,8 @@ def rb_available() -> np.ndarray:
|
|||||||
data = pd.read_csv(".." + os.sep + "export" + os.sep + i, delimiter=';').to_numpy()
|
data = pd.read_csv(".." + os.sep + "export" + os.sep + i, delimiter=';').to_numpy()
|
||||||
nb_users = i.split(".")[0]
|
nb_users = i.split(".")[0]
|
||||||
available[nb, 0] = int(nb_users)
|
available[nb, 0] = int(nb_users)
|
||||||
available[nb, 1] = data.shape[0] / (200 * 10000)
|
available[nb, 1] = (data.shape[0] / (200 * 10000)) * 100
|
||||||
nb += 1
|
nb += 1
|
||||||
|
|
||||||
"""for j in range(0, 2):
|
|
||||||
for k in range(0, 10000):
|
|
||||||
nb_users = i.split(".")[0]
|
|
||||||
available[nb, 0] = int(nb_users)
|
|
||||||
if j == data[nb, 1] and k == data[:, 2]:
|
|
||||||
available[nb, 1] += 1
|
|
||||||
"""
|
|
||||||
return available
|
return available
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,11 +26,12 @@ public class Main {
|
|||||||
}
|
}
|
||||||
int timeSlotNb = 2;
|
int timeSlotNb = 2;
|
||||||
int subCarrierNb = 100;
|
int subCarrierNb = 100;
|
||||||
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);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -19,21 +19,25 @@ public class MaxSNR extends Scheduler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scheduling(int ticks) {
|
public void scheduling(int ticks) {
|
||||||
User userMax = null;
|
User userMax;
|
||||||
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, users);
|
userMax = userSelection(ts, sp);
|
||||||
allocateRessource(userMax, frame, ts, sp, ticks);
|
allocateRessource(userMax, frame, ts, sp, ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private User userSelection(int ts, int sp, List<User> Users) {
|
/**
|
||||||
double MaxSnr = 0.0;
|
* Sélectionne le prochain utilisateur en fonction du contexte
|
||||||
|
* @return the user with the best bandwidth
|
||||||
|
*/
|
||||||
|
private User userSelection(int ts, int sp) {
|
||||||
|
double maxSnr = 0.0;
|
||||||
User userMax = null;
|
User userMax = null;
|
||||||
for(User u: Users){
|
for(User u: users){
|
||||||
if (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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,17 +9,17 @@ import fr.ntr.User;
|
|||||||
|
|
||||||
public class RoundRobin extends Scheduler {
|
public class RoundRobin extends Scheduler {
|
||||||
|
|
||||||
private String name;
|
private final Random random;
|
||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
private List<User> users;
|
private final List<User> users;
|
||||||
private ResourceBlock[][] frame;
|
private final ResourceBlock[][] frame;
|
||||||
|
|
||||||
public RoundRobin(String name, int index, ResourceBlock[][] frame, List<User> users) {
|
public RoundRobin(ResourceBlock[][] frame, List<User> users) {
|
||||||
this.name = name;
|
this.index = 0;
|
||||||
this.index = index;
|
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
this.users = users;
|
this.users = users;
|
||||||
|
this.random = new Random();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,14 +29,14 @@ public class RoundRobin extends Scheduler {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void scheduling(int ticks) {
|
public void scheduling(int ticks) {
|
||||||
//selection aleatoire du premier utilisateur
|
//selection aléatoire du premier utilisateur
|
||||||
Random random = new Random();
|
|
||||||
index = random.nextInt(users.size());
|
index = random.nextInt(users.size());
|
||||||
|
|
||||||
//Pour chaque time slot et sous porteuses
|
//Pour chaque time slot et sous porteuses
|
||||||
for (int ts = 0; ts < AccessPoint.getTimeSlotNb(); ts++) {
|
for (int ts = 0; ts < AccessPoint.getTimeSlotNb(); ts++) {
|
||||||
for(int sp = 0; sp < AccessPoint.getSubCarrierNb(); sp++) {
|
for(int sp = 0; sp < AccessPoint.getSubCarrierNb(); sp++) {
|
||||||
User userSelected = userSelection(ts, sp, users);
|
User userSelected = userSelection();
|
||||||
allocateRessource(userSelected, frame, ts, sp, ticks);
|
allocateRessource(userSelected, frame, ts, sp, ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,16 +45,17 @@ public class RoundRobin extends Scheduler {
|
|||||||
/**
|
/**
|
||||||
* Entry Time slot (int), Sous porteuse(int), and users ( List<User>)
|
* Entry Time slot (int), Sous porteuse(int), and users ( List<User>)
|
||||||
* Return the user in function of TS and SP selected
|
* Return the user in function of TS and SP selected
|
||||||
|
*
|
||||||
|
* @return the next user which have something to send, null otherwise
|
||||||
*/
|
*/
|
||||||
private User userSelection(int ts, int sp, List<User> users) {
|
private User userSelection() {
|
||||||
//compte le nombre de bloc attribue
|
for(int i = index; i < index + users.size(); i++) {
|
||||||
for (int i = 0; i < ts; i++){
|
User user = users.get(index % (users.size()));
|
||||||
for (int j = 0; j < sp; j++) {
|
if(!user.getPacketsToSend().isEmpty()) {
|
||||||
index++;
|
index = i;
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//on retourne l'utilisateur
|
return null;
|
||||||
return users.get(index%(users.size() - 1));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user