Changeset 7743 for trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/ThreeOpt/TSPTranslocationMovePathEvaluator.cs
- Timestamp:
- 04/20/12 15:45:10 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/ThreeOpt/TSPTranslocationMovePathEvaluator.cs
r7259 r7743 46 46 } 47 47 48 protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates) { 49 TranslocationMove move = TranslocationMoveParameter.ActualValue; 48 public static double EvaluateByCoordinates(Permutation permutation, TranslocationMove move, DoubleMatrix coordinates, TSPTranslocationMovePathEvaluator evaluator) { 49 if (move.Index1 == move.Index3 50 || move.Index2 == permutation.Length - 1 && move.Index3 == 0 51 || move.Index1 == 0 && move.Index3 == permutation.Length - 1 - move.Index2) return 0; 52 50 53 int edge1source = permutation.GetCircular(move.Index1 - 1); 51 54 int edge1target = permutation[move.Index1]; … … 60 63 edge3target = permutation[move.Index3]; 61 64 } 62 if (move.Index1 == move.Index363 || move.Index2 - move.Index1 >= permutation.Length - 264 || move.Index1 == permutation.Length - 1 && move.Index3 == 065 || move.Index1 == 0 && move.Index3 == permutation.Length - 1) return 0;66 65 double moveQuality = 0; 67 66 // remove three edges 68 moveQuality -= CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],67 moveQuality -= evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1], 69 68 coordinates[edge1target, 0], coordinates[edge1target, 1]); 70 moveQuality -= CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],69 moveQuality -= evaluator.CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1], 71 70 coordinates[edge2target, 0], coordinates[edge2target, 1]); 72 moveQuality -= CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1],71 moveQuality -= evaluator.CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1], 73 72 coordinates[edge3target, 0], coordinates[edge3target, 1]); 74 73 // add three edges 75 moveQuality += CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1],74 moveQuality += evaluator.CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1], 76 75 coordinates[edge1target, 0], coordinates[edge1target, 1]); 77 moveQuality += CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],76 moveQuality += evaluator.CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1], 78 77 coordinates[edge3target, 0], coordinates[edge3target, 1]); 79 moveQuality += CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],78 moveQuality += evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1], 80 79 coordinates[edge2target, 0], coordinates[edge2target, 1]); 81 80 return moveQuality; 82 81 } 83 82 84 protected override double EvaluateByDistanceMatrix(Permutation permutation, DistanceMatrix distanceMatrix) { 85 TranslocationMove move = TranslocationMoveParameter.ActualValue; 83 public static double EvaluateByDistanceMatrix(Permutation permutation, TranslocationMove move, DistanceMatrix distanceMatrix) { 84 if (move.Index1 == move.Index3 85 || move.Index2 == permutation.Length - 1 && move.Index3 == 0 86 || move.Index1 == 0 && move.Index3 == permutation.Length - 1 - move.Index2) return 0; 87 86 88 int edge1source = permutation.GetCircular(move.Index1 - 1); 87 89 int edge1target = permutation[move.Index1]; … … 96 98 edge3target = permutation[move.Index3]; 97 99 } 98 if (move.Index1 == move.Index399 || move.Index2 - move.Index1 >= permutation.Length - 2100 || move.Index1 == permutation.Length - 1 && move.Index3 == 0101 || move.Index1 == 0 && move.Index3 == permutation.Length - 1) return 0;102 100 double moveQuality = 0; 103 101 // remove three edges … … 111 109 return moveQuality; 112 110 } 111 112 protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates) { 113 return EvaluateByCoordinates(permutation, TranslocationMoveParameter.ActualValue, coordinates, this); 114 } 115 116 protected override double EvaluateByDistanceMatrix(Permutation permutation, DistanceMatrix distanceMatrix) { 117 return EvaluateByDistanceMatrix(permutation, TranslocationMoveParameter.ActualValue, distanceMatrix); 118 } 113 119 } 114 120 }
Note: See TracChangeset
for help on using the changeset viewer.