52 lines
2.0 KiB
Java
52 lines
2.0 KiB
Java
package fr.ntr;
|
|
|
|
import fr.ntr.scheduler.RoundRobin;
|
|
import fr.ntr.scheduler.Scheduler;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class Main {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
if(args.length == 2) {
|
|
int numberOfTicks; // Nombre de ticks de la simulation -> durée de la simulation
|
|
int maximumLoad; // Nombre maximal d'utilisateurs dans le système
|
|
try {
|
|
numberOfTicks = Integer.parseInt(args[0]);
|
|
maximumLoad = Integer.parseInt(args[1]);
|
|
System.out.println("ticks: " + numberOfTicks + ", users: " + maximumLoad);
|
|
} catch (NumberFormatException e) {
|
|
System.err.println("Cannot parse launch argument to integer");
|
|
System.exit(1);
|
|
return;
|
|
}
|
|
int timeSlotNb = 2;
|
|
int subCarrierNb = 100;
|
|
List<User> users = generateUsers(20, timeSlotNb, subCarrierNb);
|
|
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
|
|
Scheduler scheduler = new RoundRobin("round robin", 0, frame, users);
|
|
AccessPoint accessPoint = new AccessPoint(scheduler, frame, users, timeSlotNb, subCarrierNb, 0, 50);
|
|
accessPoint.startSimulation(numberOfTicks, maximumLoad);
|
|
}
|
|
else {
|
|
System.err.println("Please give launch arguments");
|
|
System.err.println("gradle run --args=\"<number of ticks> <number of users>\"");
|
|
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 (double v : distance) {
|
|
for (int j = 0; j < nbUsers; j++) {
|
|
User user = new User(v, timeSlotNb, subCarrierNb);
|
|
users.add(user);
|
|
}
|
|
}
|
|
return users;
|
|
}
|
|
} |