Free cookie consent management tool by TermsFeed Policy Generator

source: branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Analysis/Aggregators/InformationStabilityAggregator.cs @ 13365

Last change on this file since 13365 was 7128, checked in by epitzer, 13 years ago

#1696 Integrate fitness landscape analysis plugins from Heureka! repository.

File size: 2.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using HeuristicLab.Optimization;
7using HeuristicLab.Data;
8using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
9using HeuristicLab.Common;
10using HeuristicLab.Common.Resources;
11using HeuristicLab.Analysis.FitnessLandscape.DataTables;
12using System.Drawing;
13using HeuristicLab.Analysis.FitnessLandscape.Analysis;
14
15namespace HeuristicLab.Analysis.FitnessLandscape {
16
17  [Item("Information Stability Aggregator", "Aggregates information stability analyses.")]
18  [StorableClass]
19  public class InformationStabilityAggregator : Aggregator<InformationStabilityTable> {
20
21    [StorableConstructor]
22    protected InformationStabilityAggregator(bool deserializing) : base(deserializing) { }
23    protected InformationStabilityAggregator(InformationStabilityAggregator original, Cloner cloner) : base(original, cloner) { }
24    public InformationStabilityAggregator() { }
25    public override IDeepCloneable Clone(Cloner cloner) {
26      return new InformationStabilityAggregator(this, cloner);
27    }
28
29    public override IResult CreateResult() {
30      return new Result("Information Stabilities Summary", Aggregate(items));
31    }
32
33    public static DataTable Aggregate(List<InformationStabilityTable> informationStabilityTables) {
34      DataTable table = new DataTable("Information Stabilities");
35      if (informationStabilityTables.Count == 0)
36        return table;
37      try {
38        List<double> values = new List<double>();
39        foreach (var t in informationStabilityTables) {
40          if (t.Rows.Count > 0 && t.Rows.First().Values.Count > 0)
41            values.Add(t.Rows.First().Values.Last());
42        }
43        DataRow valuesRow = new DataRow("values", "information stability values", values);
44        valuesRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points;
45        table.Rows.Add(valuesRow);
46        double max = values.Max();
47        double min = values.Min();
48        double avg = values.Average();
49        table.Rows.Add(new DataRow("max", "Maximum", values.Select(v => max)));
50        table.Rows.Add(new DataRow("min", "Minimum", values.Select(v => min)));
51        table.Rows.Add(new DataRow("avg", "Average", values.Select(v => avg)));
52      } catch (Exception) { }
53      return table;
54    }
55  }
56}
Note: See TracBrowser for help on using the repository browser.