Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/17/10 00:30:46 (15 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on selection
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Selection/3.3/MergingReducer.cs

    r1530 r2817  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    24 using System.Text;
    2523using HeuristicLab.Core;
    26 using HeuristicLab.Operators;
     24using HeuristicLab.Data;
     25using HeuristicLab.Parameters;
     26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    2828namespace HeuristicLab.Selection {
    2929  /// <summary>
    30   /// Merges all sub scopes of the children to one list.
     30  /// An operator which reduces to the sub-scopes of all sub-scopes of the current scope.
    3131  /// </summary>
    32   public class MergingReducer : ReducerBase {
    33     /// <inheritdoc select="summary"/>
    34     public override string Description {
    35       get { return @"TODO\r\nOperator description still missing ..."; }
    36     }
     32  [Item("MergingReducer", "An operator which reduces to the sub-scopes of all sub-scopes of the current scope.")]
     33  [EmptyStorableClass]
     34  [Creatable("Test")]
     35  public sealed class MergingReducer : Reducer {
     36    public MergingReducer() : base() { }
    3737
    38     /// <summary>
    39     /// Merges all sub scopes of the sub scopes of the current <paramref name="scope"/>.
    40     /// </summary>
    41     /// <param name="scope">The current scope whose sub scopes to merge.</param>
    42     /// <returns>A list of all merged subscopes of the given <paramref name="scope"/>.</returns>
    43     protected override ICollection<IScope> Reduce(IScope scope) {
    44       List<IScope> subScopes = new List<IScope>();
    45 
    46       for (int i = 0; i < scope.SubScopes.Count; i++) {
    47         for (int j = 0; j < scope.SubScopes[i].SubScopes.Count; j++)
    48           subScopes.Add(scope.SubScopes[i].SubScopes[j]);
    49       }
    50       return subScopes;
     38    protected override ScopeList Reduce(ScopeList scopes) {
     39      ScopeList reduced = new ScopeList();
     40      for (int i = 0; i < scopes.Count; i++)
     41        reduced.AddRange(scopes[i].SubScopes);
     42      return reduced;
    5143    }
    5244  }
Note: See TracChangeset for help on using the changeset viewer.