This repository has been archived on 2023-08-28. You can view files and clone it, but cannot push or open issues or pull requests.
ntr-interferences/src/main/java/fr/ntr/Main.java

52 lines
2.0 KiB
Java
Raw Normal View History

2023-03-03 10:22:51 +01:00
package fr.ntr;
import fr.ntr.scheduler.RoundRobin;
import fr.ntr.scheduler.Scheduler;
2023-03-03 12:10:32 +01:00
2023-03-17 11:11:26 +01:00
import java.util.ArrayList;
import java.util.List;
2023-03-03 10:22:51 +01:00
public class Main {
2023-03-03 12:10:32 +01:00
2023-03-03 10:22:51 +01:00
public static void main(String[] args) {
2023-03-03 12:10:32 +01:00
2023-03-10 08:06:56 +01:00
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
2023-03-10 08:06:56 +01:00
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;
2023-03-10 08:06:56 +01:00
}
2023-03-17 11:18:48 +01:00
int timeSlotNb = 2;
int subCarrierNb = 100;
2023-03-17 11:11:26 +01:00
List<User> users = generateUsers(20, timeSlotNb, subCarrierNb);
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
2023-03-17 11:13:25 +01:00
Scheduler scheduler = new RoundRobin("round robin", 0, frame, users);
2023-03-17 11:11:26 +01:00
AccessPoint accessPoint = new AccessPoint(scheduler, frame, users, timeSlotNb, subCarrierNb, 0, 50);
accessPoint.startSimulation(numberOfTicks, maximumLoad);
2023-03-17 11:11:26 +01:00
}
else {
2023-03-10 08:06:56 +01:00
System.err.println("Please give launch arguments");
System.err.println("gradle run --args=\"<number of ticks> <number of users>\"");
System.exit(1);
}
2023-03-03 10:22:51 +01:00
}
2023-03-17 11:11:26 +01:00
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;
}
2023-03-10 09:17:15 +01:00
}