-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResult.java
More file actions
489 lines (462 loc) · 21.7 KB
/
Copy pathResult.java
File metadata and controls
489 lines (462 loc) · 21.7 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
package runner;
import java.util.ArrayList;
import java.util.List;
import util.Utility;
/**
* <code>Result</code> captures the several statistics of executing several runs.
* <p>
* This class provides methods for inquiring the results over the runs. For
* instance, to get the minimum value across all runs, you can use {@link #min}
* method of this class.
* @author Ahmed Hassan (ahmedhassan@aims.ac.za)
*/
public class Result {
private final List<ThreadOutput> outputList;
private final List<Double> results;
private final Utility util;
private int minPeriods;
public Result(List<ThreadOutput> outputList) {
this.outputList = outputList;
results = new ArrayList<>(outputList.size());
minPeriods = Integer.MAX_VALUE;
for(ThreadOutput output : outputList) {
results.add(output.bestValue);
if(output.imprScoresList.size() < minPeriods){
minPeriods = output.imprScoresList.size();
}
}
util = new Utility();
}
/**
* Returns the minimum value of all runs.
* @return the minimum value of all runs
*/
public double min(){
return util.min(results);
}
/**
* Returns the mean of all runs.
* @return the mean of all runs
*/
public double mean(){
return util.mean(results);
}
/**
* Returns the standard deviation.
* @return the standard deviation
*/
public double std(){
return util.std(results);
}
/**
* Returns the median of all runs.
* @return the median of all runs
*/
public double median(){
return util.median(results);
}
/**
* Returns the maximum value of all runs.
* @return the maximum value of all runs
*/
public double max(){
return util.max(results);
}
/**
* Returns the average percentage improvement for each heuristic across all runs.
* <p>
* The value at index <code>idx</code> of the returned array represents the
* average percentage improvement of the heuristic at index <code>idx</code> in
* the universal set.
* @return the average percentage improvement for each heuristic across all runs
*/
public double[] avgImprovement(){
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).imprScores);
}
return util.meanHeurPerf(perfList);
}
/**
* Returns the average percentage disimprovement for each heuristic across all runs.
* <p>
* The value at index <code>idx</code> of the returned array represents the
* average percentage disimprovement of the heuristic at index <code>idx</code> in
* the universal set.
* @return the average percentage disimprovement for each heuristic across all runs
*/
public double[] avgDisimprovement(){
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).disimprScores);
}
return util.meanHeurPerf(perfList);
}
/**
* Returns the average number of improvements for each heuristic across all runs.
* <p>
* The value at index <code>idx</code> of the returned array represents the
* average number of improvements of the heuristic at index <code>idx</code> in
* the universal set.
* @return the average number of improvements for each heuristic across all runs
*/
public double[] avgNumberOfImprovements(){
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).numImprScores);
}
return util.meanHeurPerf(perfList);
}
/**
* Returns the average number of disimprovements for each heuristic across all runs.
* <p>
* The value at index <code>idx</code> of the returned array represents the
* average number of disimprovements of the heuristic at index <code>idx</code> in
* the universal set.
* @return the average number of disimprovements for each heuristic across all runs
*/
public double[] avgNumberOfDisimprovements(){
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).numDisimprScores);
}
return util.meanHeurPerf(perfList);
}
/**
* Returns the ratios of the contribution of all heuristics in the total
* percentage improvement made by all heuristics.
* <p>
* The value at index <code>idx</code> is the ratio of percentage improvement
* that the the heuristic at index <code>idx</code> in the universal set has
* contributed to the total percentage improvement.
* @return the ratios of the contribution of all heuristic in the total
* percentage improvement made by all heuristics.
*/
public double[] avgGroupImprovement(){
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).groupImprScores);
}
return util.meanHeurPerf(perfList);
}
/**
* Returns the ratios of the contribution of all heuristics in the total
* percentage disimprovement made by all heuristics.
* <p>
* The value at index <code>idx</code> is the ratio of percentage disimprovement
* that the the heuristic at index <code>idx</code> in the universal set has
* contributed to the total percentage disimprovement.
* @return the ratios of the contribution of all heuristic in the total
* percentage disimprovement made by all heuristics.
*/
public double[] avgGroupDisimprovement(){
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).groupDisimprScores);
}
return util.meanHeurPerf(perfList);
}
/**
* Returns the ratios of the contribution of all heuristics in the total
* number of improvements made by all heuristics.
* <p>
* The value at index <code>idx</code> is the ratio of number of improvements
* that the the heuristic at index <code>idx</code> in the universal set has
* contributed to the total number improvements.
* @return the ratios of the contribution of all heuristic in the total
* number of improvements made by all heuristics.
*/
public double[] avgGroupNumberOfImprovements(){
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).groupNumImprScores);
}
return util.meanHeurPerf(perfList);
}
/**
* Returns the ratios of the contribution of all heuristics in the total
* number of disimprovements made by all heuristics.
* <p>
* The value at index <code>idx</code> is the ratio of number of disimprovements
* that the the heuristic at index <code>idx</code> in the universal set has
* contributed to the total number disimprovements.
* @return the ratios of the contribution of all heuristic in the total
* number of disimprovements made by all heuristics.
*/
public double[] avgGroupNumberOfDisimprovements(){
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).groupNumDisimprScores);
}
return util.meanHeurPerf(perfList);
}
/**
* Returns the ratios of the share of all heuristics in the total computational
* time used by all heuristics.
* <p>
* The value at index <code>idx</code> is the share in the computational time
* that the the heuristic at index <code>idx</code> in the universal set has
* used up.
* @return the ratios of the share of all heuristics in the total computational
* time used by all heuristics.
*/
public double[] avgDurations(){
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).groupDurations);
}
return util.meanHeurPerf(perfList);
}
/**
* Returns the average percentage improvement for each heuristic across all
* runs over several periods.
* <p>
* The search is made of several periods of equal computational time. The
* performance of each heuristic is observed in each period.
* <p>
* The performance of each heuristic in a period <code>pd</code> is an array
* at index <code>pd-1</code> in the returned list. The value at index
* <code>idx</code> in the returned array represents the average percentage
* improvement of the heuristic at index <code>idx</code> in the universal
* set in the period <code>pd</code>.
* @return the average percentage improvement for each heuristic across all
* runs over several periods
*/
public List<double[]> avgImprovementOverPeriods(){
//A list to store average performance over several periods
List<double[]> perfOverPeriods = new ArrayList<>(minPeriods);
for(int period=0; period < minPeriods; period++){
//A list to store the performance for the current period obtained
//by several threads
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).imprScoresList.get(period));
}
//Calculate the average performance for the current period
perfOverPeriods.add(util.meanHeurPerf(perfList));
}
return perfOverPeriods;
}
/**
* Returns the average percentage disimprovement for each heuristic across all
* runs over several periods.
* <p>
* The search is made of several periods of equal computational time. The
* performance of each heuristic is observed in each period.
* <p>
* The performance of each heuristic in a period <code>pd</code> is an array
* at index <code>pd-1</code> in the returned list. The value at index
* <code>idx</code> in the returned array represents the average percentage
* disimprovement of the heuristic at index <code>idx</code> in the universal
* set in the period <code>pd</code>.
* @return the average percentage disimprovement for each heuristic across all
* runs over several periods
*/
public List<double[]> avgDisimprovementOverPeriods(){
//A list to store average performance over several periods
List<double[]> perfOverPeriods = new ArrayList<>(minPeriods);
for(int period=0; period < minPeriods; period++){
//A list to store the performance for the current period obtained
//by several threads
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).disimprScoresList.get(period));
}
//Calculate the average performance for the current period
perfOverPeriods.add(util.meanHeurPerf(perfList));
}
return perfOverPeriods;
}
/**
* Returns the average number of improvements for each heuristic across all
* runs over several periods.
* <p>
* The search is made of several periods of equal computational time. The
* performance of each heuristic is observed in each period.
* <p>
* The performance of each heuristic in a period <code>pd</code> is an array
* at index <code>pd-1</code> in the returned list. The value at index
* <code>idx</code> in the returned array represents the average number of
* improvements of the heuristic at index <code>idx</code> in the universal
* set in the period <code>pd</code>.
* @return the average number of improvements for each heuristic across all
* runs over several periods
*/
public List<double[]> avgNumberOfImprovementsOverPeriods(){
//A list to store average performance over several periods
List<double[]> perfOverPeriods = new ArrayList<>(minPeriods);
for(int period=0; period < minPeriods; period++){
//A list to store the performance for the current period obtained
//by several threads
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).numImprScoresList.get(period));
}
//Calculate the average performance for the current period
perfOverPeriods.add(util.meanHeurPerf(perfList));
}
return perfOverPeriods;
}
/**
* Returns the average number of disimprovements for each heuristic across all
* runs over several periods.
* <p>
* The search is made of several periods of equal computational time. The
* performance of each heuristic is observed in each period.
* <p>
* The performance of each heuristic in a period <code>pd</code> is an array
* at index <code>pd-1</code> in the returned list. The value at index
* <code>idx</code> in the returned array represents the average number of
* disimprovements of the heuristic at index <code>idx</code> in the universal
* set in the period <code>pd</code>.
* @return the average number of disimprovements for each heuristic across all
* runs over several periods
*/
public List<double[]> avgNumberOfDisimprovementsOverPeriods(){
//A list to store average performance over several periods
List<double[]> perfOverPeriods = new ArrayList<>(minPeriods);
for(int period=0; period < minPeriods; period++){
//A list to store the performance for the current period obtained
//by several threads
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).numDisimprScoresList.get(period));
}
//Calculate the average performance for the current period
perfOverPeriods.add(util.meanHeurPerf(perfList));
}
return perfOverPeriods;
}
/**
* Returns the ratios of percentage improvement that each heuristic has
* contributed in the total percentage improvement across all runs over
* several periods.
* <p>
* The search is made of several periods of equal computational time. The
* performance of each heuristic is observed in each period.
* <p>
* The performance of each heuristic in a period <code>pd</code> is an array
* at index <code>pd-1</code> in the returned list. The value at index
* <code>idx</code> in the returned array represents the average ratio of
* percentage improvement that the heuristic at index <code>idx</code> in
* the universal set in the period <code>pd</code> has contributed to the
* total percentage improvement.
* @return the ratios of percentage improvement that each heuristic has
* contributed in the total percentage improvement across all runs over
* several periods
*/
public List<double[]> avgGroupImprovementOverPeriods(){
//A list to store average performance over several periods
List<double[]> perfOverPeriods = new ArrayList<>(minPeriods);
for(int period=0; period < minPeriods; period++){
//A list to store the performance for the current period obtained
//by several threads
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).groupImprScoresList.get(period));
}
//Calculate the average performance for the current period
perfOverPeriods.add(util.meanHeurPerf(perfList));
}
return perfOverPeriods;
}
/**
* Returns the ratios of percentage disimprovement that each heuristic has
* contributed in the total percentage disimprovement across all runs over
* several periods.
* <p>
* The search is made of several periods of equal computational time. The
* performance of each heuristic is observed in each period.
* <p>
* The performance of each heuristic in a period <code>pd</code> is an array
* at index <code>pd-1</code> in the returned list. The value at index
* <code>idx</code> in the returned array represents the average ratio of
* percentage disimprovement that the heuristic at index <code>idx</code> in
* the universal set in the period <code>pd</code> has contributed to the
* total percentage disimprovement.
* @return the ratios of percentage disimprovement that each heuristic has
* contributed in the total percentage disimprovement across all runs over
* several periods
*/
public List<double[]> avgGroupDisimprovementOverPeriods(){
//A list to store average performance over several periods
List<double[]> perfOverPeriods = new ArrayList<>(minPeriods);
for(int period=0; period < minPeriods; period++){
//A list to store the performance for the current period obtained
//by several threads
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).groupDisimprScoresList.get(period));
}
//Calculate the average performance for the current period
perfOverPeriods.add(util.meanHeurPerf(perfList));
}
return perfOverPeriods;
}
/**
* Returns the ratios of number of improvements that each heuristic has
* contributed in the total number of improvements across all runs over
* several periods.
* <p>
* The search is made of several periods of equal computational time. The
* performance of each heuristic is observed in each period.
* <p>
* The performance of each heuristic in a period <code>pd</code> is an array
* at index <code>pd-1</code> in the returned list. The value at index
* <code>idx</code> in the returned array represents the average ratio of
* number of improvements that the heuristic at index <code>idx</code> in
* the universal set in the period <code>pd</code> has contributed to the
* total number of improvements.
* @return the ratios of number of improvements that each heuristic has
* contributed in the total number of improvements across all runs over
* several periods
*/
public List<double[]> avgGroupNumberOfImprovementsOverPeriod(){
//A list to store average performance over several periods
List<double[]> perfOverPeriods = new ArrayList<>(minPeriods);
for(int period=0; period < minPeriods; period++){
//A list to store the performance for the current period obtained
//by several threads
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).groupNumImprScoresList.get(period));
}
//Calculate the average performance for the current period
perfOverPeriods.add(util.meanHeurPerf(perfList));
}
return perfOverPeriods;
}
/**
* Returns the ratios of number of disimprovements that each heuristic has
* contributed in the total number of disimprovements across all runs over
* several periods.
* <p>
* The search is made of several periods of equal computational time. The
* performance of each heuristic is observed in each period.
* <p>
* The performance of each heuristic in a period <code>pd</code> is an array
* at index <code>pd-1</code> in the returned list. The value at index
* <code>idx</code> in the returned array represents the average ratio of
* number of disimprovements that the heuristic at index <code>idx</code> in
* the universal set in the period <code>pd</code> has contributed to the
* total number of disimprovements.
* @return the ratios of number of disimprovements that each heuristic has
* contributed in the total number of disimprovements across all runs over
* several periods
*/
public List<double[]> avgGroupNumberOfDisimprovementsOverPeriods(){
//A list to store average performance over several periods
List<double[]> perfOverPeriods = new ArrayList<>(minPeriods);
for(int period=0; period < minPeriods; period++){
//A list to store the performance for the current period obtained
//by several threads
List<double[]> perfList = new ArrayList<>(outputList.size());
for(int thread=0; thread < outputList.size(); thread++){
perfList.add(outputList.get(thread).groupNumDisimprScoresList.get(period));
}
//Calculate the average performance for the current period
perfOverPeriods.add(util.meanHeurPerf(perfList));
}
return perfOverPeriods;
}
}