[16995] | 1 | using System.Collections.Generic;
|
---|
[7208] | 2 | using System.Linq;
|
---|
| 3 | using HeuristicLab.Common;
|
---|
| 4 | using HeuristicLab.Core;
|
---|
| 5 | using HeuristicLab.Optimization;
|
---|
| 6 | using HeuristicLab.Data;
|
---|
[16573] | 7 | using HEAL.Attic;
|
---|
[7208] | 8 |
|
---|
| 9 | namespace 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 | }
|
---|