[8924] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[16453] | 3 | * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[8924] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
[7228] | 22 | using System.Collections.Generic;
|
---|
| 23 | using System.Linq;
|
---|
| 24 | using HeuristicLab.Common;
|
---|
| 25 | using HeuristicLab.Core;
|
---|
| 26 | using HeuristicLab.Data;
|
---|
| 27 | using HeuristicLab.Parameters;
|
---|
[16559] | 28 | using HEAL.Attic;
|
---|
[7228] | 29 |
|
---|
| 30 | namespace HeuristicLab.Optimization {
|
---|
| 31 |
|
---|
| 32 | [Item("RunCollection Value Remover", "Modifies a RunCollection by removing results or parameters.")]
|
---|
[16462] | 33 | [StorableType("300726A9-3E81-4F8E-A11F-4A5B3CDCA796")]
|
---|
[7228] | 34 | public class RunCollectionValueRemover : ParameterizedNamedItem, IRunCollectionModifier {
|
---|
| 35 |
|
---|
| 36 | public ValueParameter<CheckedItemCollection<StringValue>> ValuesParameter {
|
---|
| 37 | get { return (ValueParameter<CheckedItemCollection<StringValue>>)Parameters["Values"]; }
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | public IEnumerable<string> Values {
|
---|
| 41 | get { return ValuesParameter.Value.CheckedItems.Select(v => v.Value); }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | #region Construction & Cloning
|
---|
| 45 | [StorableConstructor]
|
---|
[16462] | 46 | protected RunCollectionValueRemover(StorableConstructorFlag _) : base(_) { }
|
---|
[7228] | 47 | protected RunCollectionValueRemover(RunCollectionValueRemover original, Cloner cloner)
|
---|
| 48 | : base(original, cloner) {
|
---|
| 49 | }
|
---|
| 50 | public RunCollectionValueRemover() {
|
---|
| 51 | Parameters.Add(new ValueParameter<CheckedItemCollection<StringValue>>("Values", "The result or parameter values to be removed from each run."));
|
---|
| 52 | }
|
---|
| 53 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 54 | return new RunCollectionValueRemover(this, cloner);
|
---|
| 55 | }
|
---|
| 56 | #endregion
|
---|
| 57 |
|
---|
| 58 | public void Modify(List<IRun> runs) {
|
---|
| 59 | foreach (var run in runs) {
|
---|
| 60 | foreach (var value in Values) {
|
---|
| 61 | run.Parameters.Remove(value);
|
---|
| 62 | run.Results.Remove(value);
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | }
|
---|
| 68 | }
|
---|