-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutput.java
More file actions
64 lines (54 loc) · 3.32 KB
/
Output.java
File metadata and controls
64 lines (54 loc) · 3.32 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package simModel;
public class Output
{
// SSOVs
public double[] percentExceedWait = new double[3];
public double[] percentBusySignal = new double[2];
public int[][] longWaitPerHourMatrix = new int[3][12];
public int[][] busyPerHourMatrix = new int[2][12];
public int[][] arrivalPerHourMatrix = new int[3][12];
public double[][] percentWaitingHourMatrix = new double[3][12];
public double[][] percentBusyHourMatrix = new double[2][12];
//public int finished = 0; // Debug only, remove
//public int beingSed = 0; // Debug only, remove
public void updateOutput() {
int sumLongWait[] = new int[3];
int sumArrival[] = new int[3];
int sumBusy[] = new int[2];
for (int i = 0; i < 12; i++ ){
try {
percentWaitingHourMatrix[Constants.REGULAR][i] = (double)longWaitPerHourMatrix[Constants.REGULAR][i] / (double)arrivalPerHourMatrix[Constants.REGULAR][i];
} catch (Exception e){
System.err.println("/ by zero R");
percentWaitingHourMatrix[Constants.REGULAR][i] = 0;
}
try {
percentWaitingHourMatrix[Constants.SILVER][i] = (double)longWaitPerHourMatrix[Constants.SILVER][i] / (double)arrivalPerHourMatrix[Constants.SILVER][i];
} catch (Exception e){
System.err.println("/ by zero S");
percentWaitingHourMatrix[Constants.SILVER][i] = 0;
}
try {
percentWaitingHourMatrix[Constants.GOLD][i] = (double)longWaitPerHourMatrix[Constants.GOLD][i] / (double)arrivalPerHourMatrix[Constants.GOLD][i];
} catch (Exception e){
System.err.println("/ by zero G");
percentWaitingHourMatrix[Constants.GOLD][i] = 0;
}
percentBusyHourMatrix[Constants.REGULAR][i] = (double)busyPerHourMatrix[Constants.REGULAR][i] / (double)(arrivalPerHourMatrix[Constants.REGULAR][i] + busyPerHourMatrix[Constants.REGULAR][i]);
percentBusyHourMatrix[Constants.CARDHOLDER][i] = (double)busyPerHourMatrix[Constants.CARDHOLDER][i] / (double)(arrivalPerHourMatrix[Constants.SILVER][i] + arrivalPerHourMatrix[Constants.SILVER][i] + busyPerHourMatrix[Constants.CARDHOLDER][i]);
sumLongWait[Constants.REGULAR] += longWaitPerHourMatrix[Constants.REGULAR][i];
sumLongWait[Constants.SILVER] += longWaitPerHourMatrix[Constants.SILVER][i];
sumLongWait[Constants.GOLD] += longWaitPerHourMatrix[Constants.GOLD][i];
sumArrival[Constants.REGULAR] += arrivalPerHourMatrix[Constants.REGULAR][i];
sumArrival[Constants.SILVER] += arrivalPerHourMatrix[Constants.SILVER][i];
sumArrival[Constants.GOLD] += arrivalPerHourMatrix[Constants.GOLD][i];
sumBusy[Constants.REGULAR] += busyPerHourMatrix[Constants.REGULAR][i];
sumBusy[Constants.CARDHOLDER] += busyPerHourMatrix[Constants.CARDHOLDER][i];
}
percentExceedWait[Constants.REGULAR] = (double)sumLongWait[Constants.REGULAR] / sumArrival[Constants.REGULAR];
percentExceedWait[Constants.SILVER] = (double) sumLongWait[Constants.SILVER] / sumArrival[Constants.SILVER];
percentExceedWait[Constants.GOLD] = (double)sumLongWait[Constants.GOLD] / sumArrival[Constants.GOLD];
percentBusySignal[Constants.REGULAR] = (double)sumBusy[Constants.REGULAR] / (double)(sumArrival[Constants.REGULAR] + sumBusy[Constants.REGULAR]);
percentBusySignal[Constants.CARDHOLDER] = (double)sumBusy[Constants.CARDHOLDER] / (double)(sumArrival[Constants.SILVER] + sumArrival[Constants.GOLD] + sumBusy[Constants.CARDHOLDER]);
}
}