Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/11/17 00:27:04 (7 years ago)
Author:
abeham
Message:

#2731: Added better performing manipulation methods to Permutation and adapted the manipulators to use them

  • Added unit tests
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Manipulators/TranslocationManipulator.cs

    r14185 r14662  
    6565
    6666    public static void Apply(Permutation permutation, int breakPoint1, int breakPoint2, int insertPoint) {
    67       Permutation original = (Permutation)permutation.Clone();
    68 
    69       int i = 0;  // index in new permutation
    70       int j = 0;  // index in old permutation
    71       while (i < original.Length) {
    72         if (i == insertPoint) {  // copy translocated area
    73           for (int k = breakPoint1; k <= breakPoint2; k++) {
    74             permutation[i] = original[k];
    75             i++;
    76           }
    77         }
    78         if (j == breakPoint1) {  // skip area between breakpoints
    79           j = breakPoint2 + 1;
    80         }
    81         if ((i < original.Length) && (j < original.Length)) {
    82           permutation[i] = original[j];
    83           i++;
    84           j++;
    85         }
    86       }
     67      permutation.Move(breakPoint1, breakPoint2, insertPoint);
    8768    }
    8869
Note: See TracChangeset for help on using the changeset viewer.