Changeset 6685 for branches/GeneralizedQAP/HeuristicLab.Encodings.PermutationEncoding/3.3/Manipulators
- Timestamp:
- 08/31/11 11:52:11 (13 years ago)
- Location:
- branches/GeneralizedQAP
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP
- Property svn:mergeinfo changed
/trunk/sources (added) merged: 6648-6649,6652-6656,6661-6674,6676-6681,6684
- Property svn:mergeinfo changed
-
branches/GeneralizedQAP/HeuristicLab.Encodings.PermutationEncoding
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Encodings.PermutationEncoding (added) merged: 6648
- Property svn:mergeinfo changed
-
branches/GeneralizedQAP/HeuristicLab.Encodings.PermutationEncoding/3.3/Manipulators/ScrambleManipulator.cs
r5445 r6685 50 50 /// <param name="permutation">The permutation to manipulate.</param> 51 51 public static void Apply(IRandom random, Permutation permutation) { 52 Permutation original = (Permutation)permutation.Clone();53 54 52 int breakPoint1, breakPoint2; 55 53 int[] scrambledIndices, remainingIndices, temp; 56 54 int selectedIndex, index; 57 55 58 breakPoint1 = random.Next( original.Length - 1);59 breakPoint2 = random.Next(breakPoint1 + 1, original.Length);56 breakPoint1 = random.Next(permutation.Length - 1); 57 breakPoint2 = random.Next(breakPoint1 + 1, permutation.Length); 60 58 61 59 scrambledIndices = new int[breakPoint2 - breakPoint1 + 1]; … … 80 78 } 81 79 82 for (int i = 0; i <= (breakPoint2 - breakPoint1); i++) { // scramble permutation between breakpoints 83 permutation[breakPoint1 + i] = original[breakPoint1 + scrambledIndices[i]]; 80 Apply(permutation, breakPoint1, scrambledIndices); 81 } 82 83 public static void Apply(Permutation permutation, int startIndex, int[] scrambleArray) { 84 Permutation original = (Permutation)permutation.Clone(); 85 for (int i = 0; i < scrambleArray.Length; i++) { // scramble permutation between breakpoints 86 permutation[startIndex + i] = original[startIndex + scrambleArray[i]]; 84 87 } 85 88 }
Note: See TracChangeset
for help on using the changeset viewer.