[2773] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[17180] | 3 | * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[2773] | 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 |
|
---|
[9934] | 22 | using System;
|
---|
[9838] | 23 | using System.Collections.Generic;
|
---|
[9934] | 24 | using System.Linq;
|
---|
[4722] | 25 | using HeuristicLab.Common;
|
---|
[2773] | 26 | using HeuristicLab.Core;
|
---|
[16565] | 27 | using HEAL.Attic;
|
---|
[2773] | 28 |
|
---|
| 29 | namespace HeuristicLab.Operators {
|
---|
| 30 | /// <summary>
|
---|
[3616] | 31 | /// A base class for operators which apply arbitrary many other operators of a specific type that can be checked or unchecked.
|
---|
[2773] | 32 | /// </summary>
|
---|
[3822] | 33 | [Item("CheckedMultiOperator", "A base class for operators which apply arbitrary many other operators of a specific type that can be checked or unchecked.")]
|
---|
[16565] | 34 | [StorableType("7C166074-0171-4574-8689-8CDB75A9BB1A")]
|
---|
[9159] | 35 | public abstract class CheckedMultiOperator<T> : MultiOperator<T>, ICheckedMultiOperator<T> where T : class, IOperator {
|
---|
[3591] | 36 | /// <summary>
|
---|
| 37 | /// Gets the operators of the checked multi operator
|
---|
| 38 | /// </summary>
|
---|
| 39 | public new ICheckedItemList<T> Operators {
|
---|
| 40 | get { return (ICheckedItemList<T>)base.Operators; }
|
---|
| 41 | protected set { base.Operators = value; }
|
---|
[2773] | 42 | }
|
---|
[4722] | 43 |
|
---|
| 44 | [StorableConstructor]
|
---|
[16565] | 45 | protected CheckedMultiOperator(StorableConstructorFlag _) : base(_) { }
|
---|
[4722] | 46 | protected CheckedMultiOperator(CheckedMultiOperator<T> original, Cloner cloner)
|
---|
| 47 | : base(original, cloner) {
|
---|
| 48 | }
|
---|
[3591] | 49 | /// <summary>
|
---|
| 50 | /// Creates a new instance of CheckedMultiOperator
|
---|
| 51 | /// </summary>
|
---|
| 52 | public CheckedMultiOperator()
|
---|
[2773] | 53 | : base() {
|
---|
[3591] | 54 | Operators = new CheckedItemList<T>();
|
---|
[2773] | 55 | }
|
---|
[9838] | 56 |
|
---|
| 57 | public override void CollectParameterValues(IDictionary<string, IItem> values) {
|
---|
[9934] | 58 | foreach (var param in Parameters.OfType<IValueParameter>().Except(OperatorParameters)) {
|
---|
| 59 | var children = GetCollectedValues(param);
|
---|
| 60 | foreach (var c in children) {
|
---|
| 61 | if (String.IsNullOrEmpty(c.Key))
|
---|
| 62 | values.Add(param.Name, c.Value);
|
---|
| 63 | else values.Add(param.Name + "." + c.Key, c.Value);
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
[9838] | 66 | foreach (var opParam in OperatorParameters) {
|
---|
| 67 | var op = opParam.Value;
|
---|
| 68 | var @checked = Operators.ItemChecked(op);
|
---|
[9934] | 69 | if (!@checked) continue;
|
---|
| 70 | var children = GetCollectedValues(opParam);
|
---|
| 71 | foreach (var c in children) {
|
---|
| 72 | if (String.IsNullOrEmpty(c.Key))
|
---|
| 73 | values.Add(opParam.Name, c.Value);
|
---|
| 74 | else values.Add(opParam.Name + "." + c.Key, c.Value);
|
---|
| 75 | }
|
---|
[9838] | 76 | }
|
---|
| 77 | }
|
---|
[2773] | 78 | }
|
---|
| 79 | }
|
---|