1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Common;
|
---|
6 | using HeuristicLab.Core;
|
---|
7 | using HeuristicLab.Optimization;
|
---|
8 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
9 | using HeuristicLab.Data;
|
---|
10 |
|
---|
11 | namespace HeuristicLab.Analysis.FitnessLandscape.BoxChart {
|
---|
12 | [Item("Result Names Collector", "Collects all occuring names of parameters and results in the currenly visible runs")]
|
---|
13 | [StorableClass]
|
---|
14 | public class ResultNamesCollector : ParameterizedNamedItem, IRunCollectionModifier {
|
---|
15 |
|
---|
16 | #region Construction & Cloning
|
---|
17 |
|
---|
18 | [StorableConstructor]
|
---|
19 | protected ResultNamesCollector(bool deserializing) : base(deserializing) {}
|
---|
20 |
|
---|
21 | protected ResultNamesCollector(ResultNamesCollector original, Cloner cloner) : base(original, cloner) {}
|
---|
22 | public ResultNamesCollector() {}
|
---|
23 |
|
---|
24 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
25 | return new ResultNamesCollector(this, cloner);
|
---|
26 | }
|
---|
27 |
|
---|
28 | #endregion
|
---|
29 |
|
---|
30 | #region IRunCollectionModifier Members
|
---|
31 |
|
---|
32 | public void Modify(List<IRun> runs) {
|
---|
33 | var resultNames = new HashSet<string>();
|
---|
34 | var parameterNames = new HashSet<string>();
|
---|
35 | foreach (var run in runs) {
|
---|
36 | foreach (var name in run.Parameters.Select(p => p.Key))
|
---|
37 | parameterNames.Add(name);
|
---|
38 | foreach (var name in run.Results.Select(r => r.Key))
|
---|
39 | resultNames.Add(name);
|
---|
40 | }
|
---|
41 | var newRun = new Run();
|
---|
42 | newRun.Results.Add("Result Names",
|
---|
43 | new CheckedItemCollection<StringValue>(resultNames.Select(r => new StringValue(r))));
|
---|
44 | newRun.Parameters.Add("Parameter Names",
|
---|
45 | new CheckedItemCollection<StringValue>(parameterNames.Select(p => new StringValue(p))));
|
---|
46 | runs.Add(newRun);
|
---|
47 | }
|
---|
48 |
|
---|
49 | #endregion
|
---|
50 | }
|
---|
51 | }
|
---|