- Timestamp:
- 04/20/12 15:45:10 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators
- Files:
-
- 2 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 } -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt/TSPInversionMovePathEvaluator.cs
r7259 r7743 46 46 } 47 47 48 protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates) { 49 InversionMove move = InversionMoveParameter.ActualValue; 48 public static double EvaluateByCoordinates(Permutation permutation, InversionMove move, DoubleMatrix coordinates, TSPInversionMovePathEvaluator evaluator) { 50 49 int edge1source = permutation.GetCircular(move.Index1 - 1); 51 50 int edge1target = permutation[move.Index1]; … … 55 54 double moveQuality = 0; 56 55 // remove two edges 57 moveQuality -= CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],56 moveQuality -= evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1], 58 57 coordinates[edge1target, 0], coordinates[edge1target, 1]); 59 moveQuality -= CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],58 moveQuality -= evaluator.CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1], 60 59 coordinates[edge2target, 0], coordinates[edge2target, 1]); 61 60 // add two edges 62 moveQuality += CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],61 moveQuality += evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1], 63 62 coordinates[edge2source, 0], coordinates[edge2source, 1]); 64 moveQuality += CalculateDistance(coordinates[edge1target, 0], coordinates[edge1target, 1],63 moveQuality += evaluator.CalculateDistance(coordinates[edge1target, 0], coordinates[edge1target, 1], 65 64 coordinates[edge2target, 0], coordinates[edge2target, 1]); 66 65 return moveQuality; 67 66 } 68 67 69 protected override double EvaluateByDistanceMatrix(Permutation permutation, DistanceMatrix distanceMatrix) { 70 InversionMove move = InversionMoveParameter.ActualValue; 68 public static double EvaluateByDistanceMatrix(Permutation permutation, InversionMove move, DistanceMatrix distanceMatrix) { 71 69 int edge1source = permutation.GetCircular(move.Index1 - 1); 72 70 int edge1target = permutation[move.Index1]; … … 83 81 return moveQuality; 84 82 } 83 84 protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates) { 85 return EvaluateByCoordinates(permutation, InversionMoveParameter.ActualValue, coordinates, this); 86 } 87 88 protected override double EvaluateByDistanceMatrix(Permutation permutation, DistanceMatrix distanceMatrix) { 89 return EvaluateByDistanceMatrix(permutation, InversionMoveParameter.ActualValue, distanceMatrix); 90 } 85 91 } 86 92 }
Note: See TracChangeset
for help on using the changeset viewer.