Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/BoxChart/ResultNamesCollector.cs @ 17717

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

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

File size: 1.7 KB
RevLine 
[16995]1using System.Collections.Generic;
[7208]2using System.Linq;
3using HeuristicLab.Common;
4using HeuristicLab.Core;
5using HeuristicLab.Optimization;
6using HeuristicLab.Data;
[16573]7using HEAL.Attic;
[7208]8
9namespace HeuristicLab.Analysis.FitnessLandscape.BoxChart {
10  [Item("Result Names Collector", "Collects all occuring names of parameters and results in the currenly visible runs")]
[16573]11  [StorableType("90ADFC82-D508-4532-8F5E-690EB4F3F60F")]
[7208]12  public class ResultNamesCollector : ParameterizedNamedItem, IRunCollectionModifier {
13
14    #region Construction & Cloning
15
16    [StorableConstructor]
[16573]17    protected ResultNamesCollector(StorableConstructorFlag _) : base(_) { }
[7208]18
19    protected ResultNamesCollector(ResultNamesCollector original, Cloner cloner) : base(original, cloner) {}
20    public ResultNamesCollector() {}
21
22    public override IDeepCloneable Clone(Cloner cloner) {
23      return new ResultNamesCollector(this, cloner);
24    }
25
26    #endregion
27
28    #region IRunCollectionModifier Members
29
30    public void Modify(List<IRun> runs) {
31      var resultNames = new HashSet<string>();
32      var parameterNames = new HashSet<string>();
33      foreach (var run in runs) {
34        foreach (var name in run.Parameters.Select(p => p.Key))
35          parameterNames.Add(name);
36        foreach (var name in run.Results.Select(r => r.Key))
37          resultNames.Add(name);
38      }
39      var newRun = new Run();
[7211]40      newRun.Results.Add("Result Names",
41        new CheckedItemCollection<StringValue>(resultNames.Select(r => new StringValue(r))));
42      newRun.Parameters.Add("Parameter Names",
43        new CheckedItemCollection<StringValue>(parameterNames.Select(p => new StringValue(p))));
[7208]44      runs.Add(newRun);
45    }
46
47    #endregion
48  }
49}
Note: See TracBrowser for help on using the repository browser.