using System.Collections.Generic; using System.Linq; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Optimization; using HeuristicLab.Data; using HEAL.Attic; namespace HeuristicLab.Analysis.FitnessLandscape.BoxChart { [Item("Result Names Collector", "Collects all occuring names of parameters and results in the currenly visible runs")] [StorableType("90ADFC82-D508-4532-8F5E-690EB4F3F60F")] public class ResultNamesCollector : ParameterizedNamedItem, IRunCollectionModifier { #region Construction & Cloning [StorableConstructor] protected ResultNamesCollector(StorableConstructorFlag _) : base(_) { } protected ResultNamesCollector(ResultNamesCollector original, Cloner cloner) : base(original, cloner) {} public ResultNamesCollector() {} public override IDeepCloneable Clone(Cloner cloner) { return new ResultNamesCollector(this, cloner); } #endregion #region IRunCollectionModifier Members public void Modify(List runs) { var resultNames = new HashSet(); var parameterNames = new HashSet(); foreach (var run in runs) { foreach (var name in run.Parameters.Select(p => p.Key)) parameterNames.Add(name); foreach (var name in run.Results.Select(r => r.Key)) resultNames.Add(name); } var newRun = new Run(); newRun.Results.Add("Result Names", new CheckedItemCollection(resultNames.Select(r => new StringValue(r)))); newRun.Parameters.Add("Parameter Names", new CheckedItemCollection(parameterNames.Select(p => new StringValue(p)))); runs.Add(newRun); } #endregion } }