Changeset 3404 for trunk/sources/HeuristicLab.Selection
- Timestamp:
- 04/19/10 01:51:50 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Selection/3.3
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Selection/3.3/HeuristicLab.Selection-3.3.csproj
r3384 r3404 83 83 <None Include="HeuristicLabSelectionPlugin.cs.frame" /> 84 84 <Compile Include="BestSelector.cs" /> 85 <Compile Include="GenderSpecificSelector.cs" /> 86 <Compile Include="RightChildReducer.cs" /> 85 87 <Compile Include="SingleObjectiveSelector.cs" /> 86 88 <Compile Include="LeftReducer.cs" /> -
trunk/sources/HeuristicLab.Selection/3.3/RightChildReducer.cs
r1530 r3404 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-20 08Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 using System.Text;25 23 using HeuristicLab.Core; 26 using HeuristicLab.Operators; 24 using HeuristicLab.Optimization; 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 26 28 27 namespace HeuristicLab.Selection { 29 28 /// <summary> 30 /// Reduces the sub scopes by one level, so that the right sub scope contains also the right child scopes31 /// of the left sub scope and the left sub scope represents its left child scope.29 /// Reduces the sub-scopes, so that the selected sub-scope contains all selected leaves (1) and (2) 30 /// and the remaining sub-scope contains the sub-scopes of the bottom-most remaining scope (3). 32 31 /// <pre> 33 /// scopescope34 /// / |\ / \35 /// L ... R => A R36 /// / | \ \ / /\\37 /// A ... LR C C D EF38 /// 39 /// D EF32 /// scope scope 33 /// / \ / \ 34 /// R S(1) => R S 35 /// / \ \ /|\ /|\ 36 /// R(3) S(2) C ABCDEF CDEF 37 /// /|\ /|\ 38 /// ABCDEF DEF 40 39 /// </pre> 41 40 /// </summary> 42 public class RightChildReducer : ReducerBase { 43 /// <inheritdoc select="summary"/> 44 public override string Description { 45 get { return @"TODO\r\nOperator description still missing ..."; } 46 } 47 41 [Item("RightChildReducer", "Merges all sub-scopes generated by successively selecting sub-scopes of the remaining part.")] 42 [StorableClass] 43 public class RightChildReducer : Reducer, IReducer { 48 44 /// <summary> 49 /// Reduces the right child of the left sub scope and adds its sub scopes to the right sub scope.50 /// The left sub scope is also narrowed, which means it represents then its left child.45 /// Reduces the sub-scopes, so that the selected sub-scope contains all selected leaves 46 /// and the remaining sub-scope contains the sub-scopes of the bottom-most remaining scope. 51 47 /// </summary> 52 48 /// <param name="scope">The current scope to reduce.</param> 53 49 /// <returns>A list of the new reduced sub scopes.</returns> 54 protected override ICollection<IScope> Reduce(IScope scope) { 55 IScope rightChild = scope.SubScopes[scope.SubScopes.Count - 1]; 56 IScope leftChild = scope.SubScopes[0]; 57 IScope leftRightChild = leftChild.SubScopes[leftChild.SubScopes.Count - 1]; 50 protected override List<IScope> Reduce(List<IScope> scopes) { 51 IScope rightChild = scopes[scopes.Count - 1]; 52 IScope leftChild = scopes[0]; 53 while (leftChild.SubScopes.Count > 1 && leftChild.SubScopes[0].SubScopes.Count > 0) { 54 IScope leftRightChild = leftChild.SubScopes[leftChild.SubScopes.Count - 1]; 58 55 59 // merge right children60 for (int i = 0; i < leftRightChild.SubScopes.Count; i++)61 rightChild.AddSubScope(leftRightChild.SubScopes[i]);56 // merge right children 57 while (leftRightChild.SubScopes.Count > 0) 58 rightChild.SubScopes.Add(leftRightChild.SubScopes[0]); 62 59 63 leftChild = leftChild.SubScopes[0];64 60 leftChild = leftChild.SubScopes[0]; 61 } 65 62 List<IScope> subScopes = new List<IScope>(); 66 63 subScopes.Add(leftChild);
Note: See TracChangeset
for help on using the changeset viewer.