Move init to avoid re-creating users every time
This commit is contained in:
parent
fdc5445b25
commit
76183acdee
@ -44,29 +44,21 @@ public class AccessPoint {
|
||||
* @param duration
|
||||
*/
|
||||
public void startSimulation(int duration, int nbUsers) {
|
||||
init(nbUsers);
|
||||
for (int ticks = 0; ticks < duration; ++ticks) {
|
||||
// Simulation
|
||||
reset();
|
||||
init(nbUsers, ticks);
|
||||
updateBandwidth(ticks);
|
||||
schedule();
|
||||
// traite les données et les enregistre dans un fichier
|
||||
analyseData();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Génération du débit et des paquets
|
||||
*/
|
||||
private void init(int nbUsers, int ticks) {
|
||||
private void updateBandwidth(int ticks) {
|
||||
int n = 200;
|
||||
int timeInterval = 50 + new Random().nextInt(50);
|
||||
|
||||
// 2 groupes d'utilisateurs, proches et éloignés
|
||||
double[] distance = { 200d, 1000d };
|
||||
for (int i = 0; i < distance.length; i++) {
|
||||
for(int j = 0; j < nbUsers; j++){
|
||||
User user = new User(distance[i], timeSlotNb, subCarrierNb);
|
||||
|
||||
for(User user : users) {
|
||||
// On regénère le tableau de débits toutes les 50 ms
|
||||
if(ticks % 50 == 0){
|
||||
user.generateBandwidth();
|
||||
@ -77,6 +69,18 @@ public class AccessPoint {
|
||||
n = user.createPackets(n);
|
||||
timeInterval = 50 + new Random().nextInt(51);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Génération du débit et des paquets
|
||||
*/
|
||||
private void init(int nbUsers) {
|
||||
// 2 groupes d'utilisateurs, proches et éloignés
|
||||
double[] distance = { 200d, 1000d };
|
||||
for (int i = 0; i < distance.length; i++) {
|
||||
for(int j = 0; j < nbUsers; j++){
|
||||
User user = new User(distance[i], timeSlotNb, subCarrierNb);
|
||||
this.users.add(user);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user