1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using HeuristicLab.Core;
|
---|
5 | using HeuristicLab.Optimization;
|
---|
6 | using HeuristicLab.Common;
|
---|
7 | using HeuristicLab.Analysis.FitnessLandscape.DataTables;
|
---|
8 | using HEAL.Attic;
|
---|
9 |
|
---|
10 | namespace HeuristicLab.Analysis.FitnessLandscape {
|
---|
11 |
|
---|
12 | [Item("Information Stability Aggregator", "Aggregates information stability analyses.")]
|
---|
13 | [StorableType("0E2319B7-EB74-4363-A89F-26A3517CB7F7")]
|
---|
14 | public class InformationStabilityAggregator : Aggregator<InformationStabilityTable> {
|
---|
15 |
|
---|
16 | [StorableConstructor]
|
---|
17 | protected InformationStabilityAggregator(StorableConstructorFlag _) : base(_) { }
|
---|
18 | protected InformationStabilityAggregator(InformationStabilityAggregator original, Cloner cloner) : base(original, cloner) { }
|
---|
19 | public InformationStabilityAggregator() { }
|
---|
20 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
21 | return new InformationStabilityAggregator(this, cloner);
|
---|
22 | }
|
---|
23 |
|
---|
24 | public override IResult CreateResult() {
|
---|
25 | return new Result("Information Stabilities Summary", Aggregate(items));
|
---|
26 | }
|
---|
27 |
|
---|
28 | public static DataTable Aggregate(List<InformationStabilityTable> informationStabilityTables) {
|
---|
29 | DataTable table = new DataTable("Information Stabilities");
|
---|
30 | if (informationStabilityTables.Count == 0)
|
---|
31 | return table;
|
---|
32 | try {
|
---|
33 | List<double> values = new List<double>();
|
---|
34 | foreach (var t in informationStabilityTables) {
|
---|
35 | if (t.Rows.Count > 0 && t.Rows.First().Values.Count > 0)
|
---|
36 | values.Add(t.Rows.First().Values.Last());
|
---|
37 | }
|
---|
38 | DataRow valuesRow = new DataRow("values", "information stability values", values);
|
---|
39 | valuesRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points;
|
---|
40 | table.Rows.Add(valuesRow);
|
---|
41 | double max = values.Max();
|
---|
42 | double min = values.Min();
|
---|
43 | double avg = values.Average();
|
---|
44 | table.Rows.Add(new DataRow("max", "Maximum", values.Select(v => max)));
|
---|
45 | table.Rows.Add(new DataRow("min", "Minimum", values.Select(v => min)));
|
---|
46 | table.Rows.Add(new DataRow("avg", "Average", values.Select(v => avg)));
|
---|
47 | } catch (Exception) { }
|
---|
48 | return table;
|
---|
49 | }
|
---|
50 | }
|
---|
51 | }
|
---|