Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceSpeedUp/HeuristicLab.Optimization/3.3/RunCollectionValueRemover.cs @ 10866

Last change on this file since 10866 was 6760, checked in by epitzer, 13 years ago

#1530 integrate changes from trunk

File size: 1.7 KB
RevLine 
[6665]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Common;
6using HeuristicLab.Core;
7using HeuristicLab.Data;
8using HeuristicLab.Parameters;
9using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
10
11namespace HeuristicLab.Optimization {
12
13  [Item("RunCollection Value Remover", "Modifies a RunCollection by removing results or parameters.")]
14  [StorableClass]
15  public class RunCollectionValueRemover : ParameterizedNamedItem, IRunCollectionModifier {
16   
17    public ValueParameter<CheckedItemCollection<StringValue>> ValuesParameter {
18      get { return (ValueParameter<CheckedItemCollection<StringValue>>)Parameters["Values"]; }
19    }
20
21    public IEnumerable<string> Values {
22      get { return ValuesParameter.Value.CheckedItems.Select(v => v.Value); }
23    }
24
25    #region Construction & Cloning   
26    [StorableConstructor]
27    protected RunCollectionValueRemover(bool deserializing) : base(deserializing) { }
28    protected RunCollectionValueRemover(RunCollectionValueRemover original, Cloner cloner)
29      : base(original, cloner) {
30    }
31    public RunCollectionValueRemover() {
32      Parameters.Add(new ValueParameter<CheckedItemCollection<StringValue>>("Values", "The result or parameter values to be removed from each run."));     
33    }
34    public override IDeepCloneable Clone(Cloner cloner) {
35      return new RunCollectionValueRemover(this, cloner);
36    }   
37    #endregion   
38
39    public void Modify(List<IRun> runs) {     
40      foreach (var run in runs) {
41        foreach (var value in Values) {
42          run.Parameters.Remove(value);
43          run.Results.Remove(value);
44        }       
45      }     
46    }
47   
48  }
49}
Note: See TracBrowser for help on using the repository browser.