Merge branch 'master' of gitlab.istic.univ-rennes1.fr:18008147/ntr
This commit is contained in:
commit
a7f93da59a
65
plot/main.py
65
plot/main.py
@ -7,33 +7,62 @@ nb_files = os.listdir(".." + os.sep + "export")
|
|||||||
|
|
||||||
size = len(nb_files)
|
size = len(nb_files)
|
||||||
|
|
||||||
# main array
|
|
||||||
averages = np.empty((size, 2))
|
|
||||||
nb = 0
|
|
||||||
for i in nb_files:
|
|
||||||
data = pd.read_csv(".." + os.sep + "export" + os.sep + i, delimiter=';').to_numpy()
|
|
||||||
rb = data[:, 4]
|
|
||||||
|
|
||||||
total = 0.0
|
def mean_mkn() -> np.ndarray:
|
||||||
for x in rb:
|
averages_mkn = np.empty((size, 2))
|
||||||
total = total + x
|
nb = 0
|
||||||
average = total / len(rb)
|
for i in nb_files:
|
||||||
nb_users = i.split(".")[0]
|
data = pd.read_csv(".." + os.sep + "export" + os.sep + i, delimiter=';').to_numpy()
|
||||||
averages[nb, 0] = int(nb_users)
|
rb = data[:, 4]
|
||||||
averages[nb, 1] = average
|
|
||||||
nb += 1
|
|
||||||
|
|
||||||
|
total = 0.0
|
||||||
|
for x in rb:
|
||||||
|
total = total + x
|
||||||
|
average = total / len(rb)
|
||||||
|
nb_users = i.split(".")[0]
|
||||||
|
averages_mkn[nb, 0] = int(nb_users)
|
||||||
|
averages_mkn[nb, 1] = average
|
||||||
|
nb += 1
|
||||||
|
return averages_mkn
|
||||||
|
|
||||||
|
|
||||||
|
def rb_available() -> np.ndarray:
|
||||||
|
available = np.zeros((size, 2))
|
||||||
|
nb = 0
|
||||||
|
for i in nb_files:
|
||||||
|
data = pd.read_csv(".." + os.sep + "export" + os.sep + i, delimiter=';').to_numpy()
|
||||||
|
nb_users = i.split(".")[0]
|
||||||
|
available[nb, 0] = int(nb_users)
|
||||||
|
available[nb, 1] = data.shape[0] / (200 * 10000)
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
averages = mean_mkn()
|
||||||
|
available = rb_available()
|
||||||
# Data for plotting
|
# Data for plotting
|
||||||
averages.sort(axis=0)
|
averages.sort(axis=0)
|
||||||
x = averages[:, 0]
|
|
||||||
y = averages[:, 1]
|
|
||||||
|
|
||||||
print(averages)
|
print(averages)
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
ax.scatter(x, y)
|
ax.scatter(averages[:, 0], averages[:, 1])
|
||||||
|
|
||||||
ax.set(xlabel='users', ylabel='ressources (RB)', title='MaxSNR')
|
ax.set(xlabel='number of users', ylabel='Efficacité spectrale', title='Efficacité spectrale')
|
||||||
ax.grid()
|
ax.grid()
|
||||||
|
|
||||||
# fig.savefig("test.png")
|
# fig.savefig("test.png")
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
fig, ax = plt.subplots()
|
||||||
|
ax.scatter(available[:, 0], available[:, 1])
|
||||||
|
ax.set(xlabel='number of users', ylabel='RB utilisés', title='Pourcentage de RB utilisés')
|
||||||
|
ax.grid()
|
||||||
|
plt.show()
|
||||||
|
@ -82,14 +82,14 @@ public class AccessPoint {
|
|||||||
|
|
||||||
private void updateBandwidth(int ticks) {
|
private void updateBandwidth(int ticks) {
|
||||||
int n = 200;
|
int n = 200;
|
||||||
int timeInterval = 50 + random.nextInt(51);
|
int timeInterval = Math.max(1, random.nextInt(51)); // avoid div by 0
|
||||||
for(User user : users) {
|
for(User user : users) {
|
||||||
// On régénère le tableau de débits toutes les 50 ms
|
// On régénère le tableau de débits toutes les 50 ms
|
||||||
if(ticks % 50 == 0){
|
if(ticks % 50 == 0){
|
||||||
user.generateBandwidth();
|
user.generateBandwidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
// On régénère les sources toutes les 50-100 ms
|
// On régénère les sources toutes les 0-50 ms
|
||||||
if(ticks % timeInterval == 0){
|
if(ticks % timeInterval == 0){
|
||||||
timeInterval = 50 + random.nextInt(51);
|
timeInterval = 50 + random.nextInt(51);
|
||||||
n = user.createPackets(n, ticks);
|
n = user.createPackets(n, ticks);
|
||||||
|
@ -28,7 +28,7 @@ public class User {
|
|||||||
double random = this.random.nextDouble();
|
double random = this.random.nextDouble();
|
||||||
for(int x = 0; x < bandwidthTable.length; x++) {
|
for(int x = 0; x < bandwidthTable.length; x++) {
|
||||||
double h = 1 * Math.sqrt(-2 * Math.log(1 - random));
|
double h = 1 * Math.sqrt(-2 * Math.log(1 - random));
|
||||||
double gain = h * Math.pow(10, random * 1/10) * Math.pow(1 / this.distance, 3.5);
|
double gain = h * h * Math.pow(10, random * 1/10) * Math.pow(1 / this.distance, 3.5);
|
||||||
double spectralEfficiency = (20 * gain) / (15000 * (3.9*Math.pow(10, -21)));
|
double spectralEfficiency = (20 * gain) / (15000 * (3.9*Math.pow(10, -21)));
|
||||||
double mkn = Math.log(1 + spectralEfficiency) / Math.log(2);
|
double mkn = Math.log(1 + spectralEfficiency) / Math.log(2);
|
||||||
this.bandwidthTable[x][y] = mkn;
|
this.bandwidthTable[x][y] = mkn;
|
||||||
|
@ -30,16 +30,11 @@ public class ProportionalFair extends Scheduler {
|
|||||||
avg = avg / (bandwidthTable.length * bandwidthTable[0].length);
|
avg = avg / (bandwidthTable.length * bandwidthTable[0].length);
|
||||||
averageBandwiths.add(avg);
|
averageBandwiths.add(avg);
|
||||||
}
|
}
|
||||||
User selectedUser = null;
|
User selectedUser;
|
||||||
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++){
|
||||||
selectedUser = selectionUtilisateur(ts, sp, users, averageBandwiths);
|
selectedUser = selectionUtilisateur(ts, sp, users, averageBandwiths);
|
||||||
if (selectedUser.getPacketsToSend().size() != 0) {
|
allocateRessource(selectedUser, frame, ts, sp);
|
||||||
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]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public class RoundRobin extends Scheduler {
|
|||||||
//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++) {
|
||||||
if (users.get(index).getPacketsToSend().size() != 0) {
|
if (!users.get(index).getPacketsToSend().isEmpty()) {
|
||||||
// on enlève le packet transmis de la liste
|
// on enlève le packet transmis de la liste
|
||||||
// TODO Verify sub the packet send need Set packet
|
// TODO Verify sub the packet send need Set packet
|
||||||
users.get(index).getPacketsSent().add(users.get(index).getPacketsToSend().get(0));
|
users.get(index).getPacketsSent().add(users.get(index).getPacketsToSend().get(0));
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package fr.ntr.scheduler;
|
package fr.ntr.scheduler;
|
||||||
|
|
||||||
|
import fr.ntr.ResourceBlock;
|
||||||
|
import fr.ntr.User;
|
||||||
|
|
||||||
public abstract class Scheduler {
|
public abstract class Scheduler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,7 +11,13 @@ public abstract class Scheduler {
|
|||||||
* Return
|
* Return
|
||||||
*/
|
*/
|
||||||
public abstract void scheduling(int ticks);
|
public abstract void scheduling(int ticks);
|
||||||
protected void TraitementDonnees() {
|
|
||||||
|
|
||||||
|
protected void allocateRessource(User userMax, ResourceBlock[][] frame, int ts, int sp) {
|
||||||
|
if (userMax != null && !userMax.getPacketsToSend().isEmpty()) {
|
||||||
|
userMax.getPacketsSent().add(userMax.getPacketsToSend().get(0));
|
||||||
|
userMax.getPacketsToSend().remove(userMax.getPacketsToSend().get(0));
|
||||||
|
frame[ts][sp].setUser(userMax);
|
||||||
|
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user