using System; using System.Collections.Generic; using System.Linq; using HeuristicLab.Core; using HeuristicLab.Optimization; using HeuristicLab.Common; using HeuristicLab.Analysis.FitnessLandscape.DataTables; using HEAL.Attic; namespace HeuristicLab.Analysis.FitnessLandscape { [Item("Information Stability Aggregator", "Aggregates information stability analyses.")] [StorableType("0E2319B7-EB74-4363-A89F-26A3517CB7F7")] public class InformationStabilityAggregator : Aggregator { [StorableConstructor] protected InformationStabilityAggregator(StorableConstructorFlag _) : base(_) { } protected InformationStabilityAggregator(InformationStabilityAggregator original, Cloner cloner) : base(original, cloner) { } public InformationStabilityAggregator() { } public override IDeepCloneable Clone(Cloner cloner) { return new InformationStabilityAggregator(this, cloner); } public override IResult CreateResult() { return new Result("Information Stabilities Summary", Aggregate(items)); } public static DataTable Aggregate(List informationStabilityTables) { DataTable table = new DataTable("Information Stabilities"); if (informationStabilityTables.Count == 0) return table; try { List values = new List(); foreach (var t in informationStabilityTables) { if (t.Rows.Count > 0 && t.Rows.First().Values.Count > 0) values.Add(t.Rows.First().Values.Last()); } DataRow valuesRow = new DataRow("values", "information stability values", values); valuesRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points; table.Rows.Add(valuesRow); double max = values.Max(); double min = values.Min(); double avg = values.Average(); table.Rows.Add(new DataRow("max", "Maximum", values.Select(v => max))); table.Rows.Add(new DataRow("min", "Minimum", values.Select(v => min))); table.Rows.Add(new DataRow("avg", "Average", values.Select(v => avg))); } catch (Exception) { } return table; } } }