- Timestamp:
- 02/14/10 05:31:49 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Permutation/3.3/InversionManipulator.cs
r1530 r2794 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 using System.Collections.Generic;24 using System.Text;25 22 using HeuristicLab.Core; 23 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 24 27 25 namespace HeuristicLab.Permutation { 28 26 /// <summary> 29 /// Manipulates a permutation array by reversing a randomly chosen interval.27 /// An operator which inverts a randomly chosen part of a permutation. 30 28 /// </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 { 36 33 37 34 /// <summary> 38 /// Reverses the specified <paramref name="permutation"/> between two randomly generated positions.35 /// Inverts a randomly chosen part of a permutation. 39 36 /// </summary> 40 /// <param name="random"> Therandom number generator.</param>41 /// <param name="permutation">The permutation arrayto 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(); 45 42 int breakPoint1, breakPoint2; 46 43 … … 51 48 if (breakPoint2 < breakPoint1) { int h = breakPoint1; breakPoint1 = breakPoint2; breakPoint2 = h; } 52 49 53 for (int i = 0; i <= (breakPoint2 - breakPoint1); i++) { // reversepermutation between breakpoints50 for (int i = 0; i <= (breakPoint2 - breakPoint1); i++) { // invert permutation between breakpoints 54 51 result[breakPoint1 + i] = permutation[breakPoint2 - i]; 55 52 } … … 58 55 59 56 /// <summary> 60 /// Reverses the specified <paramref name="permutation"/> between two randomly generated positions.57 /// Inverts a randomly chosen part of a permutation. 61 58 /// </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) { 68 63 return Apply(random, permutation); 69 64 }
Note: See TracChangeset
for help on using the changeset viewer.