Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/14/10 05:31:49 (14 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on operators
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Permutation/3.3/InversionManipulator.cs

    r1530 r2794  
    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;
    23 using System.Collections.Generic;
    24 using System.Text;
    2522using HeuristicLab.Core;
     23using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2624
    2725namespace HeuristicLab.Permutation {
    2826  /// <summary>
    29   /// Manipulates a permutation array by reversing a randomly chosen interval.
     27  /// An operator which inverts a randomly chosen part of a permutation.
    3028  /// </summary>
    31   public class InversionManipulator : PermutationManipulatorBase {
    32     /// <inheritdoc select="summary"/>
    33     public override string Description {
    34       get { return @"TODO\r\nOperator description still missing ..."; }
    35     }
     29  [Item("InversionManipulator", "An operator which inverts a randomly chosen part of a permutation.")]
     30  [EmptyStorableClass]
     31  [Creatable("Test")]
     32  public class InversionManipulator : PermutationManipulator {
    3633
    3734    /// <summary>
    38     /// Reverses the specified <paramref name="permutation"/> between two randomly generated positions.
     35    /// Inverts a randomly chosen part of a permutation.
    3936    /// </summary>
    40     /// <param name="random">The random number generator.</param>
    41     /// <param name="permutation">The permutation array to manipulate.</param>
    42     /// <returns>The new permuation array with the manipulated data.</returns>
    43     public static int[] Apply(IRandom random, int[] permutation) {
    44       int[] result = (int[])permutation.Clone();
     37    /// <param name="random">A random number generator.</param>
     38    /// <param name="permutation">The permutation to manipulate.</param>
     39    /// <returns>The new manipulated permutation.</returns>
     40    public static Permutation Apply(IRandom random, Permutation permutation) {
     41      Permutation result = (Permutation)permutation.Clone();
    4542      int breakPoint1, breakPoint2;
    4643
     
    5148      if (breakPoint2 < breakPoint1) { int h = breakPoint1; breakPoint1 = breakPoint2; breakPoint2 = h; }
    5249
    53       for (int i = 0; i <= (breakPoint2 - breakPoint1); i++) {  // reverse permutation between breakpoints
     50      for (int i = 0; i <= (breakPoint2 - breakPoint1); i++) {  // invert permutation between breakpoints
    5451        result[breakPoint1 + i] = permutation[breakPoint2 - i];
    5552      }
     
    5855
    5956    /// <summary>
    60     /// Reverses the specified <paramref name="permutation"/> between two randomly generated positions.
     57    /// Inverts a randomly chosen part of a permutation.
    6158    /// </summary>
    62     /// <remarks>Calls <see cref="Apply"/>.</remarks>
    63     /// <param name="scope">The current scope.</param>
    64     /// <param name="random">The random number generator.</param>
    65     /// <param name="permutation">The permutation array to manipulate.</param>
    66     /// <returns>The new permuation array with the manipulated data.</returns>
    67     protected override int[] Manipulate(IScope scope, IRandom random, int[] permutation) {
     59    /// <param name="random">A random number generator.</param>
     60    /// <param name="permutation">The permutation to manipulate.</param>
     61    /// <returns>The new manipulated permuation.</returns>
     62    protected override Permutation Manipulate(IRandom random, Permutation permutation) {
    6863      return Apply(random, permutation);
    6964    }
Note: See TracChangeset for help on using the changeset viewer.