Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/15/10 17:16:57 (15 years ago)
Author:
abeham
Message:

updated IslandGeneticAlgorithm #971

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  
    9393    <Compile Include="QualityComparator.cs" />
    9494    <Compile Include="SolutionsCreator.cs" />
     95    <Compile Include="UnidirectionalRingMigrator.cs" />
    9596  </ItemGroup>
    9697  <ItemGroup>
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/UnidirectionalRingMigrator.cs

    r1529 r3356  
    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.Data;
     24using HeuristicLab.Operators;
     25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2726
    28 namespace HeuristicLab.Evolutionary {
     27namespace HeuristicLab.Optimization.Operators {
    2928  /// <summary>
    30   /// Operator class that migrates one sub scope of each child to its left neighbour sub scope, like a ring.
     29  /// Operator that migrates the selected sub scopes in each subscope in an unidirectional ring.
    3130  /// </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 {
    3834    /// <summary>
    3935    /// Migrates every first sub scope of each child to its left neighbour (like a ring).
    4036    /// <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
    4644    /// </pre>
    4745    /// </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>();
    5250
    5351      for (int i = 0; i < scope.SubScopes.Count; i++) {
    5452        IScope emigrants = scope.SubScopes[i].SubScopes[1];
    55         scope.SubScopes[i].RemoveSubScope(emigrants);
     53        scope.SubScopes[i].SubScopes.Remove(emigrants);
    5654        emigrantsList.Add(emigrants);
    5755      }
     
    6260
    6361      for (int i = 0; i < scope.SubScopes.Count; i++)
    64         scope.SubScopes[i].AddSubScope(emigrantsList[i]);
     62        scope.SubScopes[i].SubScopes.Add(emigrantsList[i]);
    6563
    66       return null;
     64      return base.Apply();
    6765    }
    6866  }
Note: See TracChangeset for help on using the changeset viewer.