Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Analysis/Aggregators/InformationStabilityAggregator.cs @ 17607

Last change on this file since 17607 was 16995, checked in by gkronber, 6 years ago

#2520 Update plugin dependencies and references for HL.FLA for new persistence

File size: 2.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using HeuristicLab.Core;
5using HeuristicLab.Optimization;
6using HeuristicLab.Common;
7using HeuristicLab.Analysis.FitnessLandscape.DataTables;
8using HEAL.Attic;
9
10namespace 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}
Note: See TracBrowser for help on using the repository browser.