Moved User generation in Main class
This commit is contained in:
parent
1978e5d636
commit
c7e2fed188
@ -34,10 +34,10 @@ public class AccessPoint {
|
|||||||
private final double min, max;
|
private final double min, max;
|
||||||
|
|
||||||
|
|
||||||
public AccessPoint(Scheduler scheduler, ResourceBlock[][] frame, int timeSlotNb, int subCarrierNb, double min, double max) {
|
public AccessPoint(Scheduler scheduler, ResourceBlock[][] frame, List<User> users, int timeSlotNb, int subCarrierNb, double min, double max) {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
this.users = new ArrayList<>();
|
this.users = users;
|
||||||
this.scheduler = scheduler;
|
this.scheduler = scheduler;
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
this.timeSlotNb = timeSlotNb;
|
this.timeSlotNb = timeSlotNb;
|
||||||
@ -49,7 +49,6 @@ public class AccessPoint {
|
|||||||
* @param duration
|
* @param duration
|
||||||
*/
|
*/
|
||||||
public void startSimulation(int duration, int nbUsers) {
|
public void startSimulation(int duration, int nbUsers) {
|
||||||
init(nbUsers);
|
|
||||||
for (int ticks = 0; ticks < duration; ++ticks) {
|
for (int ticks = 0; ticks < duration; ++ticks) {
|
||||||
// Simulation
|
// Simulation
|
||||||
reset();
|
reset();
|
||||||
@ -82,20 +81,6 @@ public class AccessPoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void schedule() {
|
private void schedule() {
|
||||||
scheduler.scheduling();
|
scheduler.scheduling();
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ package fr.ntr;
|
|||||||
import fr.ntr.scheduler.RoundRobin;
|
import fr.ntr.scheduler.RoundRobin;
|
||||||
import fr.ntr.scheduler.Scheduler;
|
import fr.ntr.scheduler.Scheduler;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -22,14 +25,30 @@ public class Main {
|
|||||||
//TODO : change timeSlotNb and subCarrierNb
|
//TODO : change timeSlotNb and subCarrierNb
|
||||||
int timeSlotNb = 0;
|
int timeSlotNb = 0;
|
||||||
int subCarrierNb = 0;
|
int subCarrierNb = 0;
|
||||||
|
List<User> users = generateUsers(20, timeSlotNb, subCarrierNb);
|
||||||
|
//TODO : generate users
|
||||||
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
|
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
|
||||||
Scheduler scheduler = new RoundRobin("round robin", 0, frame);
|
Scheduler scheduler = new RoundRobin("round robin", 0, frame);
|
||||||
AccessPoint accessPoint = new AccessPoint(scheduler, frame, timeSlotNb, subCarrierNb, 0, 50);
|
AccessPoint accessPoint = new AccessPoint(scheduler, frame, users, timeSlotNb, subCarrierNb, 0, 50);
|
||||||
accessPoint.startSimulation(numberOfTicks, maximumLoad);
|
accessPoint.startSimulation(numberOfTicks, maximumLoad);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
System.err.println("Please give launch arguments");
|
System.err.println("Please give launch arguments");
|
||||||
System.err.println("gradle run --args=\"<number of ticks> <number of users>\"");
|
System.err.println("gradle run --args=\"<number of ticks> <number of users>\"");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<User> generateUsers(int nbUsers, int timeSlotNb, int subCarrierNb) {
|
||||||
|
List<User> users = new ArrayList<>();
|
||||||
|
// 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);
|
||||||
|
users.add(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return users;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user