-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomGenerator.java
More file actions
47 lines (39 loc) · 1.53 KB
/
RandomGenerator.java
File metadata and controls
47 lines (39 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cs2030.simulator;
import java.util.Random;
public class RandomGenerator {
private final Random rngArrival;
private final Random rngService;
private final Random rngRest;
private final Random rngRestPeriod;
private final Random rngTimeoutPeriod;
private final Random rngCustomerType;
private final double customerArrivalRate;
private final double customerServiceRate;
private final double serverRestingRate;
RandomGenerator(int var1, double var2, double var4, double var6) {
this.rngArrival = new Random((long)var1);
this.rngService = new Random((long)(var1 + 1));
this.rngRest = new Random((long)(var1 + 2));
this.rngRestPeriod = new Random((long)(var1 + 3));
this.rngCustomerType = new Random((long)(var1 + 4));
this.rngTimeoutPeriod = new Random((long)(var1 + 5));
this.customerArrivalRate = var2;
this.customerServiceRate = var4;
this.serverRestingRate = var6;
}
double genInterArrivalTime() {
return -Math.log(this.rngArrival.nextDouble()) / this.customerArrivalRate;
}
double genServiceTime() {
return -Math.log(this.rngService.nextDouble()) / this.customerServiceRate;
}
double genRandomRest() {
return this.rngRest.nextDouble();
}
double genRestPeriod() {
return -Math.log(this.rngRestPeriod.nextDouble()) / this.serverRestingRate;
}
double genCustomerType() {
return this.rngCustomerType.nextDouble();
}
}