Copie utilisateurs cell1 vers cell2 pour les interférences
This commit is contained in:
parent
f93b1c4c22
commit
ec7f265940
@ -27,12 +27,10 @@ public class AccessPoint {
|
|||||||
cell2.updateBandwidth(ticks);
|
cell2.updateBandwidth(ticks);
|
||||||
cell1.schedule(ticks);
|
cell1.schedule(ticks);
|
||||||
cell2.schedule(ticks);
|
cell2.schedule(ticks);
|
||||||
// simulation des interférences
|
|
||||||
// computeInterference();
|
|
||||||
// traite les données et les enregistre dans un fichier
|
// traite les données et les enregistre dans un fichier
|
||||||
try {
|
try {
|
||||||
cell1.analyseData(ticks);
|
cell1.analyseData(ticks);
|
||||||
cell2.analyseData(ticks);
|
//cell2.analyseData(ticks);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Can't export data");
|
System.out.println("Can't export data");
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -71,6 +72,19 @@ public class Main {
|
|||||||
//génération des utilisateurs
|
//génération des utilisateurs
|
||||||
List<User> usersCell1 = generateUsers(i, timeSlotNb, subCarrierNb);
|
List<User> usersCell1 = generateUsers(i, timeSlotNb, subCarrierNb);
|
||||||
List<User> usersCell2 = generateUsers(i, timeSlotNb, subCarrierNb);
|
List<User> usersCell2 = generateUsers(i, timeSlotNb, subCarrierNb);
|
||||||
|
//copie de 1/4 des utilisateurs de cell1 vers cell2
|
||||||
|
for(int j = 0; j < i/4; j++){
|
||||||
|
Random r = new Random();
|
||||||
|
int idxCopy = r.nextInt(i);
|
||||||
|
User copiedUser = usersCell1.get(idxCopy);
|
||||||
|
// On vérifie qu'on ne l'a pas déjà copié dans cell2
|
||||||
|
while(usersCell2.contains(copiedUser)){
|
||||||
|
r = new Random();
|
||||||
|
idxCopy = r.nextInt(i);
|
||||||
|
copiedUser = usersCell1.get(idxCopy);
|
||||||
|
}
|
||||||
|
usersCell2.set(idxCopy, copiedUser);
|
||||||
|
}
|
||||||
|
|
||||||
//génération des trames
|
//génération des trames
|
||||||
ResourceBlock[][] frame1 = new ResourceBlock[timeSlotNb][subCarrierNb];
|
ResourceBlock[][] frame1 = new ResourceBlock[timeSlotNb][subCarrierNb];
|
||||||
@ -83,7 +97,7 @@ public class Main {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
//préparation à exportation des données de chaque cellule
|
//préparation à exportation des données de chaque cellule
|
||||||
FileOutputStream output = new FileOutputStream("export" + File.separator + (usersCell1.size()+usersCell2.size()) + ".csv", true);
|
FileOutputStream output = new FileOutputStream("export" + File.separator + (usersCell1.size()) + ".csv", true);
|
||||||
output.write("tick;x;y;user;bandwidth;delay;cell;\n".getBytes());
|
output.write("tick;x;y;user;bandwidth;delay;cell;\n".getBytes());
|
||||||
|
|
||||||
//création des cellules
|
//création des cellules
|
||||||
@ -118,12 +132,16 @@ public class Main {
|
|||||||
private static List<User> generateUsers(int nbUsers, int timeSlotNb, int subCarrierNb) {
|
private static List<User> generateUsers(int nbUsers, int timeSlotNb, int subCarrierNb) {
|
||||||
List<User> users = new ArrayList<>();
|
List<User> users = new ArrayList<>();
|
||||||
// 2 groupes d'utilisateurs, proches et éloignés
|
// 2 groupes d'utilisateurs, proches et éloignés
|
||||||
double[] distance = { 150d, 500d };
|
int half = nbUsers / 2;
|
||||||
for (double v : distance) {
|
for (int i = 0; i < nbUsers; i++) {
|
||||||
for (int j = 0; j < nbUsers; j++) {
|
User user;
|
||||||
User user = new User(v, timeSlotNb, subCarrierNb);
|
if(i >= half ){
|
||||||
users.add(user);
|
user = new User(500d, timeSlotNb, subCarrierNb);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
user = new User(150d, timeSlotNb, subCarrierNb);
|
||||||
|
}
|
||||||
|
users.add(user);
|
||||||
}
|
}
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public abstract class Scheduler {
|
|||||||
User user2 = rb2.getUser();
|
User user2 = rb2.getUser();
|
||||||
if ((userMax != null || user2 != null) && userMax == user2) {
|
if ((userMax != null || user2 != null) && userMax == user2) {
|
||||||
double bandwidth1 = rb1.getBandwidth();
|
double bandwidth1 = rb1.getBandwidth();
|
||||||
double bandwidth2 = rb2.getBandwidth();
|
//double bandwidth2 = rb2.getBandwidth();
|
||||||
//User proche
|
//User proche
|
||||||
if (userMax.getDistance() < 200d) {
|
if (userMax.getDistance() < 200d) {
|
||||||
rb1.getUser().getBandwidthTable()[ts][sp] = bandwidth1 / 2;
|
rb1.getUser().getBandwidthTable()[ts][sp] = bandwidth1 / 2;
|
||||||
|
Reference in New Issue
Block a user