Changeset 14662 for trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Manipulators/TranslocationManipulator.cs
- Timestamp:
- 02/11/17 00:27:04 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Manipulators/TranslocationManipulator.cs
r14185 r14662 65 65 66 66 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); 87 68 } 88 69
Note: See TracChangeset
for help on using the changeset viewer.