Move random to improve performances
This commit is contained in:
parent
ef7e5f287a
commit
366853dfec
@ -33,6 +33,8 @@ public class AccessPoint {
|
||||
*/
|
||||
private final double min, max;
|
||||
|
||||
private Random random = new Random();
|
||||
|
||||
|
||||
public AccessPoint(Scheduler scheduler, ResourceBlock[][] frame, List<User> users, int timeSlotNb, int subCarrierNb, double min, double max) {
|
||||
this.min = min;
|
||||
@ -65,7 +67,6 @@ public class AccessPoint {
|
||||
|
||||
private void updateBandwidth(int ticks) {
|
||||
int n = 200;
|
||||
Random random = new Random();
|
||||
int timeInterval = 50 + random.nextInt(51);
|
||||
for(User user : users) {
|
||||
// On régénère le tableau de débits toutes les 50 ms
|
||||
|
@ -12,6 +12,8 @@ public class User {
|
||||
private final List<Packets> packetsSent;
|
||||
private int leftForNextSource;
|
||||
|
||||
private Random random = new Random();
|
||||
|
||||
public User(double distance, int timeSlotNb, int subCarrierNb) {
|
||||
this.distance = distance;
|
||||
this.bandwidthTable = new double[timeSlotNb][subCarrierNb];
|
||||
@ -21,7 +23,7 @@ public class User {
|
||||
}
|
||||
|
||||
public void generateBandwidth() {
|
||||
double random = Math.random();
|
||||
double random = this.random.nextDouble();
|
||||
for(int i = 0; i < bandwidthTable.length; i++) {
|
||||
for(int j = 0; j < bandwidthTable[i].length; j++) {
|
||||
double h = 1 * Math.sqrt(-2 * Math.log(1 - random));
|
||||
@ -34,7 +36,6 @@ public class User {
|
||||
}
|
||||
|
||||
public int createPackets(int m) {
|
||||
Random random = new Random();
|
||||
int mbis = random.nextInt(2 * m);
|
||||
int nbPacketsToSend = mbis / Packets.packetSize;
|
||||
this.leftForNextSource = mbis % Packets.packetSize;
|
||||
|
Reference in New Issue
Block a user