Index: /trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/ThreeOpt/TSPTranslocationMovePathEvaluator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/ThreeOpt/TSPTranslocationMovePathEvaluator.cs	(revision 7742)
+++ /trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/ThreeOpt/TSPTranslocationMovePathEvaluator.cs	(revision 7743)
@@ -46,6 +46,9 @@
     }
 
-    protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates) {
-      TranslocationMove move = TranslocationMoveParameter.ActualValue;
+    public static double EvaluateByCoordinates(Permutation permutation, TranslocationMove move, DoubleMatrix coordinates, TSPTranslocationMovePathEvaluator evaluator) {
+      if (move.Index1 == move.Index3
+        || move.Index2 == permutation.Length - 1 && move.Index3 == 0
+        || move.Index1 == 0 && move.Index3 == permutation.Length - 1 - move.Index2) return 0;
+
       int edge1source = permutation.GetCircular(move.Index1 - 1);
       int edge1target = permutation[move.Index1];
@@ -60,28 +63,27 @@
         edge3target = permutation[move.Index3];
       }
-      if (move.Index1 == move.Index3
-        || move.Index2 - move.Index1 >= permutation.Length - 2
-        || move.Index1 == permutation.Length - 1 && move.Index3 == 0
-        || move.Index1 == 0 && move.Index3 == permutation.Length - 1) return 0;
       double moveQuality = 0;
       // remove three edges
-      moveQuality -= CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
+      moveQuality -= evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
         coordinates[edge1target, 0], coordinates[edge1target, 1]);
-      moveQuality -= CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],
+      moveQuality -= evaluator.CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],
         coordinates[edge2target, 0], coordinates[edge2target, 1]);
-      moveQuality -= CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1],
+      moveQuality -= evaluator.CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1],
         coordinates[edge3target, 0], coordinates[edge3target, 1]);
       // add three edges
-      moveQuality += CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1],
+      moveQuality += evaluator.CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1],
         coordinates[edge1target, 0], coordinates[edge1target, 1]);
-      moveQuality += CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],
+      moveQuality += evaluator.CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],
         coordinates[edge3target, 0], coordinates[edge3target, 1]);
-      moveQuality += CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
+      moveQuality += evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
         coordinates[edge2target, 0], coordinates[edge2target, 1]);
       return moveQuality;
     }
 
-    protected override double EvaluateByDistanceMatrix(Permutation permutation, DistanceMatrix distanceMatrix) {
-      TranslocationMove move = TranslocationMoveParameter.ActualValue;
+    public static double EvaluateByDistanceMatrix(Permutation permutation, TranslocationMove move, DistanceMatrix distanceMatrix) {
+      if (move.Index1 == move.Index3
+        || move.Index2 == permutation.Length - 1 && move.Index3 == 0
+        || move.Index1 == 0 && move.Index3 == permutation.Length - 1 - move.Index2) return 0;
+
       int edge1source = permutation.GetCircular(move.Index1 - 1);
       int edge1target = permutation[move.Index1];
@@ -96,8 +98,4 @@
         edge3target = permutation[move.Index3];
       }
-      if (move.Index1 == move.Index3
-        || move.Index2 - move.Index1 >= permutation.Length - 2
-        || move.Index1 == permutation.Length - 1 && move.Index3 == 0
-        || move.Index1 == 0 && move.Index3 == permutation.Length - 1) return 0;
       double moveQuality = 0;
       // remove three edges
@@ -111,4 +109,12 @@
       return moveQuality;
     }
+
+    protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates) {
+      return EvaluateByCoordinates(permutation, TranslocationMoveParameter.ActualValue, coordinates, this);
+    }
+
+    protected override double EvaluateByDistanceMatrix(Permutation permutation, DistanceMatrix distanceMatrix) {
+      return EvaluateByDistanceMatrix(permutation, TranslocationMoveParameter.ActualValue, distanceMatrix);
+    }
   }
 }
Index: /trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt/TSPInversionMovePathEvaluator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt/TSPInversionMovePathEvaluator.cs	(revision 7742)
+++ /trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt/TSPInversionMovePathEvaluator.cs	(revision 7743)
@@ -46,6 +46,5 @@
     }
 
-    protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates) {
-      InversionMove move = InversionMoveParameter.ActualValue;
+    public static double EvaluateByCoordinates(Permutation permutation, InversionMove move, DoubleMatrix coordinates, TSPInversionMovePathEvaluator evaluator) {
       int edge1source = permutation.GetCircular(move.Index1 - 1);
       int edge1target = permutation[move.Index1];
@@ -55,18 +54,17 @@
       double moveQuality = 0;
       // remove two edges
-      moveQuality -= CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
+      moveQuality -= evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
             coordinates[edge1target, 0], coordinates[edge1target, 1]);
-      moveQuality -= CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],
+      moveQuality -= evaluator.CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],
         coordinates[edge2target, 0], coordinates[edge2target, 1]);
       // add two edges
-      moveQuality += CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
+      moveQuality += evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
         coordinates[edge2source, 0], coordinates[edge2source, 1]);
-      moveQuality += CalculateDistance(coordinates[edge1target, 0], coordinates[edge1target, 1],
+      moveQuality += evaluator.CalculateDistance(coordinates[edge1target, 0], coordinates[edge1target, 1],
         coordinates[edge2target, 0], coordinates[edge2target, 1]);
       return moveQuality;
     }
 
-    protected override double EvaluateByDistanceMatrix(Permutation permutation, DistanceMatrix distanceMatrix) {
-      InversionMove move = InversionMoveParameter.ActualValue;
+    public static double EvaluateByDistanceMatrix(Permutation permutation, InversionMove move, DistanceMatrix distanceMatrix) {
       int edge1source = permutation.GetCircular(move.Index1 - 1);
       int edge1target = permutation[move.Index1];
@@ -83,4 +81,12 @@
       return moveQuality;
     }
+
+    protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates) {
+      return EvaluateByCoordinates(permutation, InversionMoveParameter.ActualValue, coordinates, this);
+    }
+
+    protected override double EvaluateByDistanceMatrix(Permutation permutation, DistanceMatrix distanceMatrix) {
+      return EvaluateByDistanceMatrix(permutation, InversionMoveParameter.ActualValue, distanceMatrix);
+    }
   }
 }
Index: /trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TravelingSalesman-3.3/TSPMoveEvaluatorTest.cs
===================================================================
--- /trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TravelingSalesman-3.3/TSPMoveEvaluatorTest.cs	(revision 7743)
+++ /trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TravelingSalesman-3.3/TSPMoveEvaluatorTest.cs	(revision 7743)
@@ -0,0 +1,133 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using HeuristicLab.Common;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.PermutationEncoding;
+using HeuristicLab.Problems.TravelingSalesman;
+using HeuristicLab.Random;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Problems.TravelingSalesman_33.Tests {
+
+  /// <summary>
+  ///This is a test class for TSP move evaluators
+  ///</summary>
+  [TestClass()]
+  public class TSPMoveEvaluatorTest {
+    private const int ProblemSize = 10;
+    private static DoubleMatrix coordinates;
+    private static DistanceMatrix distances;
+    private static Permutation tour;
+    private static MersenneTwister random;
+
+    private TestContext testContextInstance;
+    /// <summary>
+    ///Gets or sets the test context which provides
+    ///information about and functionality for the current test run.
+    ///</summary>
+    public TestContext TestContext {
+      get { return testContextInstance; }
+      set { testContextInstance = value; }
+    }
+
+    [ClassInitialize]
+    public static void MyClassInitialize(TestContext testContext) {
+      random = new MersenneTwister();
+      coordinates = new DoubleMatrix(ProblemSize, 2);
+      distances = new DistanceMatrix(ProblemSize, ProblemSize);
+      for (int i = 0; i < ProblemSize; i++) {
+        coordinates[i, 0] = random.Next(ProblemSize * 10);
+        coordinates[i, 1] = random.Next(ProblemSize * 10);
+      }
+      for (int i = 0; i < ProblemSize - 1; i++) {
+        for (int j = i + 1; j < ProblemSize; j++) {
+          distances[i, j] = Math.Round(Math.Sqrt(Math.Pow(coordinates[i, 0] - coordinates[j, 0], 2) + Math.Pow(coordinates[i, 1] - coordinates[j, 1], 2)));
+          distances[j, i] = distances[i, j];
+        }
+      }
+      tour = new Permutation(PermutationTypes.RelativeUndirected, ProblemSize, random);
+    }
+
+    [TestMethod]
+    public void InversionMoveEvaluatorTest() {
+      var evaluator = new TSPRoundedEuclideanPathEvaluator();
+      var moveEvaluator = new TSPInversionMoveRoundedEuclideanPathEvaluator();
+      double beforeMatrix = TSPDistanceMatrixEvaluator.Apply(distances, tour);
+      double beforeCoordinates = TSPCoordinatesPathEvaluator.Apply(evaluator, coordinates, tour);
+      Assert.IsTrue(beforeMatrix.IsAlmost(beforeCoordinates), "Evaluation differs between using the coordinates and using the distance matrix.");
+
+      for (int i = 0; i < 500; i++) {
+        var move = StochasticInversionSingleMoveGenerator.Apply(tour, random);
+
+        double moveMatrix = TSPInversionMovePathEvaluator.EvaluateByDistanceMatrix(tour, move, distances);
+        double moveCoordinates = TSPInversionMovePathEvaluator.EvaluateByCoordinates(tour, move, coordinates, moveEvaluator);
+        Assert.IsTrue(moveMatrix.IsAlmost(moveCoordinates), "Evaluation differs between using the coordinates and using the distance matrix.");
+
+        string failureString = string.Format(@"Inversion move is calculated with quality {0}, but actual difference is {4}.
+The move would invert the tour {1} between values {2} and {3}.", moveMatrix.ToString(), tour.ToString(), tour[move.Index1].ToString(), tour[move.Index2].ToString(), "{0}");
+
+        InversionManipulator.Apply(tour, move.Index1, move.Index2);
+
+        double afterMatrix = TSPDistanceMatrixEvaluator.Apply(distances, tour);
+        double afterCoordinates = TSPCoordinatesPathEvaluator.Apply(evaluator, coordinates, tour);
+        Assert.IsTrue(afterMatrix.IsAlmost(afterCoordinates), "Evaluation differs between using the coordinates and using the distance matrix.");
+
+        Assert.IsTrue(moveMatrix.IsAlmost(afterMatrix - beforeMatrix), string.Format(failureString, (afterMatrix - beforeMatrix).ToString()));
+
+        beforeMatrix = afterMatrix;
+        beforeCoordinates = afterCoordinates;
+      }
+    }
+
+    [TestMethod]
+    public void TranslocationMoveEvaluatorTest() {
+      var evaluator = new TSPRoundedEuclideanPathEvaluator();
+      var moveEvaluator = new TSPTranslocationMoveRoundedEuclideanPathEvaluator();
+      double beforeMatrix = TSPDistanceMatrixEvaluator.Apply(distances, tour);
+      double beforeCoordinates = TSPCoordinatesPathEvaluator.Apply(evaluator, coordinates, tour);
+      Assert.IsTrue(beforeMatrix.IsAlmost(beforeCoordinates), "Evaluation differs between using the coordinates and using the distance matrix.");
+
+      for (int i = 0; i < 500; i++) {
+        var move = StochasticTranslocationSingleMoveGenerator.Apply(tour, random);
+
+        double moveMatrix = TSPTranslocationMovePathEvaluator.EvaluateByDistanceMatrix(tour, move, distances);
+        double moveCoordinates = TSPTranslocationMovePathEvaluator.EvaluateByCoordinates(tour, move, coordinates, moveEvaluator);
+        Assert.IsTrue(moveMatrix.IsAlmost(moveCoordinates), "Evaluation differs between using the coordinates and using the distance matrix.");
+
+        string failureString = string.Format(@"Translocation move is calculated with quality {0}, but actual difference is {5}.
+The move would move the segment between {1} and {2} in the tour {3} to the new index {4}.", moveMatrix.ToString(), tour[move.Index1].ToString(), tour[move.Index2].ToString(), tour.ToString(), move.Index3.ToString(), "{0}");
+        TranslocationManipulator.Apply(tour, move.Index1, move.Index2, move.Index3);
+
+        double afterMatrix = TSPDistanceMatrixEvaluator.Apply(distances, tour);
+        double afterCoordinates = TSPCoordinatesPathEvaluator.Apply(evaluator, coordinates, tour);
+        Assert.IsTrue(afterMatrix.IsAlmost(afterCoordinates), "Evaluation differs between using the coordinates and using the distance matrix.");
+
+        Assert.IsTrue(moveMatrix.IsAlmost(afterMatrix - beforeMatrix), string.Format(failureString, (afterMatrix - beforeMatrix).ToString()));
+
+        beforeMatrix = afterMatrix;
+        beforeCoordinates = afterCoordinates;
+      }
+    }
+
+  }
+}
Index: /trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 7742)
+++ /trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 7743)
@@ -288,4 +288,5 @@
     <Compile Include="HeuristicLab.Problems.TestFunctions-3.3\SumSquaresEvaluatorTest.cs" />
     <Compile Include="HeuristicLab.Problems.TestFunctions-3.3\ZakharovEvaluatorTest.cs" />
+    <Compile Include="HeuristicLab.Problems.TravelingSalesman-3.3\TSPMoveEvaluatorTest.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="TestRandom.cs" />
