- Timestamp:
- 04/16/13 13:13:41 (12 years ago)
- Location:
- branches/OaaS
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 23 24 packages
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.Encodings.PermutationEncoding
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Encodings.PermutationEncoding (added) merged: 8246,8338,8600
- Property svn:mergeinfo changed
-
branches/OaaS/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/ExhaustiveInsertionMoveGenerator.cs
r7259 r9363 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Core; … … 39 41 } 40 42 41 public static TranslocationMove[] Apply(Permutation permutation) {43 public static IEnumerable<TranslocationMove> Generate(Permutation permutation) { 42 44 int length = permutation.Length; 43 45 if (length == 1) throw new ArgumentException("ExhaustiveInsertionMoveGenerator: There cannot be an insertion move given a permutation of length 1.", "permutation"); 44 TranslocationMove[] moves = null; 45 int count = 0; 46 46 47 if (permutation.PermutationType == PermutationTypes.Absolute) { 47 moves = new TranslocationMove[length * (length - 1)];48 48 for (int i = 0; i < length; i++) { 49 49 for (int j = 1; j <= length - 1; j++) { 50 moves[count++] =new TranslocationMove(i, i, (i + j) % length);50 yield return new TranslocationMove(i, i, (i + j) % length); 51 51 } 52 52 } 53 53 } else { 54 54 if (length > 2) { 55 moves = new TranslocationMove[length * (length - 1) - 2];56 55 for (int i = 0; i < length; i++) { 57 56 for (int j = 1; j <= length - 1; j++) { 58 57 if (i == 0 && j == length - 1 59 58 || i == length - 1 && j == 1) continue; 60 moves[count++] =new TranslocationMove(i, i, (i + j) % length);59 yield return new TranslocationMove(i, i, (i + j) % length); 61 60 } 62 61 } 63 62 } else { // doesn't make sense, but just create a dummy move to not crash the algorithms 64 moves = new TranslocationMove[1]; 65 moves[0] = new TranslocationMove(0, 0, 1); 63 yield return new TranslocationMove(0, 0, 1); 66 64 } 67 65 } 68 System.Diagnostics.Debug.Assert(count == moves.Length); 69 return moves; 66 } 67 68 public static TranslocationMove[] Apply(Permutation permutation) { 69 return Generate(permutation).ToArray(); 70 70 } 71 71
Note: See TracChangeset
for help on using the changeset viewer.