1 | using System.Collections.Generic;
|
---|
2 | using HeuristicLab.Analysis.FitnessLandscape.DataTables;
|
---|
3 | using HeuristicLab.Common;
|
---|
4 | using HeuristicLab.Core;
|
---|
5 | using HeuristicLab.Optimization;
|
---|
6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.Analysis.FitnessLandscape {
|
---|
9 |
|
---|
10 | [Item("QualityTrailSummary Aggregator", "Aggregates quality trail summaries.")]
|
---|
11 | [StorableClass]
|
---|
12 | public class QualityTrailSummaryAggregator : Aggregator<QualityTrailSummaryTable> {
|
---|
13 |
|
---|
14 | [StorableConstructor]
|
---|
15 | protected QualityTrailSummaryAggregator(bool deserializing) : base(deserializing) { }
|
---|
16 | protected QualityTrailSummaryAggregator(QualityTrailSummaryAggregator original, Cloner cloner) : base(original, cloner) { }
|
---|
17 | public QualityTrailSummaryAggregator() { }
|
---|
18 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
19 | return new QualityTrailSummaryAggregator(this, cloner);
|
---|
20 | }
|
---|
21 |
|
---|
22 | public override IResult CreateResult() {
|
---|
23 | return new Result("Quality Trail Summary", Aggregate(items));
|
---|
24 | }
|
---|
25 |
|
---|
26 | public static DataTable Aggregate(List<QualityTrailSummaryTable> qualityTrailSummaryTables) {
|
---|
27 |
|
---|
28 | DataRow minRow = new DataRow("Minima");
|
---|
29 | DataRow q1Row = new DataRow("Q1");
|
---|
30 | DataRow medRow = new DataRow("Medians");
|
---|
31 | DataRow q3Row = new DataRow("Q3");
|
---|
32 | DataRow maxRow = new DataRow("Maxima");
|
---|
33 | foreach (var table in qualityTrailSummaryTables) {
|
---|
34 | var quartiles = table.Rows["Value Quantiles"].Values;
|
---|
35 | minRow.Values.Add(quartiles[0]);
|
---|
36 | q1Row.Values.Add(quartiles[1]);
|
---|
37 | medRow.Values.Add(quartiles[2]);
|
---|
38 | q3Row.Values.Add(quartiles[3]);
|
---|
39 | maxRow.Values.Add(quartiles[4]);
|
---|
40 | }
|
---|
41 | DataTable summaryTable = new DataTable("Quality Quartiles");
|
---|
42 | summaryTable.Rows.Add(minRow);
|
---|
43 | summaryTable.Rows.Add(q1Row);
|
---|
44 | summaryTable.Rows.Add(medRow);
|
---|
45 | summaryTable.Rows.Add(q3Row);
|
---|
46 | summaryTable.Rows.Add(maxRow);
|
---|
47 | return summaryTable;
|
---|
48 | }
|
---|
49 | }
|
---|
50 | }
|
---|