[7228] | 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.Data;
|
---|
| 8 | using HeuristicLab.Parameters;
|
---|
| 9 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 10 |
|
---|
| 11 | namespace 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 | }
|
---|