Changeset 3356 for trunk/sources/HeuristicLab.Optimization.Operators
- Timestamp:
- 04/15/10 17:16:57 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization.Operators/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Operators/3.3/HeuristicLab.Optimization.Operators-3.3.csproj
r3226 r3356 93 93 <Compile Include="QualityComparator.cs" /> 94 94 <Compile Include="SolutionsCreator.cs" /> 95 <Compile Include="UnidirectionalRingMigrator.cs" /> 95 96 </ItemGroup> 96 97 <ItemGroup> -
trunk/sources/HeuristicLab.Optimization.Operators/3.3/UnidirectionalRingMigrator.cs
r1529 r3356 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.Data; 24 using HeuristicLab.Operators; 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 26 28 namespace HeuristicLab. Evolutionary{27 namespace HeuristicLab.Optimization.Operators { 29 28 /// <summary> 30 /// Operator class that migrates one sub scope of each child to its left neighbour sub scope, like aring.29 /// Operator that migrates the selected sub scopes in each subscope in an unidirectional ring. 31 30 /// </summary> 32 public class UnidirectionalRingMigrator : OperatorBase { 33 /// <inheritdoc select="summary"/> 34 public override string Description { 35 get { return @"TODO\r\nOperator description still missing ..."; } 36 } 37 31 [Item("UnidirectionalRingMigrator", "Migrates the selected sub scopes in each subscope in an unidirectional ring.")] 32 [StorableClass] 33 public class UnidirectionalRingMigrator : SingleSuccessorOperator, IMigrator { 38 34 /// <summary> 39 35 /// Migrates every first sub scope of each child to its left neighbour (like a ring). 40 36 /// <pre> 41 /// scope scope 42 /// / | \ / | \ 43 /// A B C => A B C 44 /// /|\ /|\ /|\ /|\ /|\ /|\ 45 /// G H I J K L M N O H I J K L M N O G 37 /// __ scope __ __ scope __ 38 /// / | \ / | \ 39 /// Pop1 Pop2 Pop3 => Pop1 Pop2 Pop3 40 /// / \ / \ / \ / \ / \ / \ 41 /// R S R S R S R S R S R S 42 /// /|\ | /|\ | /|\ | /|\ | /|\ | /|\ | 43 /// ABC A DEF D GHI G ABC G DEF A GHI D 46 44 /// </pre> 47 45 /// </summary> 48 /// < param name="scope">The scope whose sub scopes of the children should migrate.</param>49 /// <returns><c>null</c>.</returns>50 public override IOperation Apply(IScope scope) {51 IList<IScope> emigrantsList = new List<IScope>();46 /// <returns>The next operation.</returns> 47 public override IOperation Apply() { 48 IScope scope = ExecutionContext.Scope; 49 List<IScope> emigrantsList = new List<IScope>(); 52 50 53 51 for (int i = 0; i < scope.SubScopes.Count; i++) { 54 52 IScope emigrants = scope.SubScopes[i].SubScopes[1]; 55 scope.SubScopes[i]. RemoveSubScope(emigrants);53 scope.SubScopes[i].SubScopes.Remove(emigrants); 56 54 emigrantsList.Add(emigrants); 57 55 } … … 62 60 63 61 for (int i = 0; i < scope.SubScopes.Count; i++) 64 scope.SubScopes[i]. AddSubScope(emigrantsList[i]);62 scope.SubScopes[i].SubScopes.Add(emigrantsList[i]); 65 63 66 return null;64 return base.Apply(); 67 65 } 68 66 }
Note: See TracChangeset
for help on using the changeset viewer.