1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Core;
|
---|
6 | using HeuristicLab.Optimization;
|
---|
7 | using HeuristicLab.Data;
|
---|
8 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
9 | using HeuristicLab.Common;
|
---|
10 | using HeuristicLab.Common.Resources;
|
---|
11 | using HeuristicLab.Analysis.FitnessLandscape.DataTables;
|
---|
12 | using System.Drawing;
|
---|
13 | using HeuristicLab.Analysis.FitnessLandscape.Analysis;
|
---|
14 |
|
---|
15 | namespace 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 | }
|
---|