Index: branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/DistanceMatrixToPointsTest.cs
===================================================================
--- branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/DistanceMatrixToPointsTest.cs	(revision 10109)
+++ branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/DistanceMatrixToPointsTest.cs	(revision 10118)
@@ -45,5 +45,5 @@
       CalculateDistanceMatrix(orgDm, orgPoints);
 
-      newPoints = DistanceMatrixToPoints.MetricMDS(orgDm);
+      newPoints = DistanceMatrixToPoints.MetricMDS(orgDm, dim, true);
 
       CalculateDistanceMatrix(newDm, newPoints);
@@ -156,6 +156,6 @@
     [TestMethod]
     public void TestMetricMDSForPermutations() {
-      int nrOfPoints = 30;
-      int dim = 20;
+      int nrOfPoints = 10;
+      int dim = 5;
       Permutation[] orgPoints = new Permutation[nrOfPoints];
       double[][] orgDm;
@@ -168,18 +168,139 @@
       orgDm = CalculateDistanceMatrixFromPermutations(orgPoints);
 
-      newPoints = DistanceMatrixToPoints.MetricMDS(orgDm, dim);
-
-      CalculateDistanceMatrix(newDm, newPoints);
-      Console.WriteLine("orgDm:");
-      PrintDM(orgDm);
-      Console.WriteLine("newDm:");
-      PrintDM(newDm);
-
-      for (int i = 0; i < orgDm.Length; i++) {
-        for (int j = 0; j < orgDm.Length; j++) {
-          double diff = orgDm[i][j] - newDm[i][j];
-          Assert.IsTrue(diff.IsAlmost(0.0));
-        }
-      }
+      newPoints = DistanceMatrixToPoints.MetricMDS(orgDm, dim, true);
+
+      CalculateDistanceMatrix(newDm, newPoints);
+      Console.WriteLine("orgDm:");
+      PrintDM(orgDm);
+      Console.WriteLine("newDm:");
+      PrintDM(newDm);
+
+      for (int i = 0; i < orgDm.Length; i++) {
+        for (int j = 0; j < orgDm.Length; j++) {
+          double diff = orgDm[i][j] - newDm[i][j];
+          Assert.IsTrue(diff.IsAlmost(0.0));
+        }
+      }
+    }
+
+    [TestMethod]
+    public void TestMetricMDSForPermutationsStatic() {
+      int nrOfPoints = 15;
+      int dim = 5;
+
+      double[][] orgDm = StaticPermutationDM();
+      double[][] newDm = new double[nrOfPoints][];
+      double[][] newPoints = null;
+
+      AllocArray(newDm, nrOfPoints);
+
+      newPoints = DistanceMatrixToPoints.MetricMDS(orgDm, dim, true);
+
+      CalculateDistanceMatrix(newDm, newPoints);
+      Console.WriteLine("orgDm:");
+      PrintDM(orgDm);
+      Console.WriteLine("newDm:");
+      PrintDM(newDm);
+
+      for (int i = 0; i < orgDm.Length; i++) {
+        for (int j = 0; j < orgDm.Length; j++) {
+          double diff = Math.Abs(orgDm[i][j] - newDm[i][j]);
+          if (diff < 0.000001) diff = 0.0;
+          Assert.IsTrue(diff.IsAlmost(0.0));
+        }
+      }
+    }
+
+    private static double[][] StaticPermutationDM() {
+      double[][] dm = new double[15][];
+      AllocArray(dm, 15);
+
+      dm[0] = new[] {
+        0, 1.09544511501033, 1.09544511501033, 0.894427190999916, 0.894427190999916, 1.4142135623731, 0.894427190999916,
+        0, 1.09544511501033, 1.09544511501033, 0, 1.09544511501033, 1.09544511501033,
+        1.4142135623731, 0.894427190999916 };
+      dm[1] = new[]
+      {
+        1.09544511501033, 0, 1.09544511501033, 0.894427190999916, 0.894427190999916, 0.894427190999916, 0.894427190999916,
+        1.09544511501033, 1.09544511501033, 1.09544511501033, 1.09544511501033, 1.09544511501033, 1.09544511501033,
+        0.894427190999916, 0.894427190999916
+      };
+      dm[2] = new[]
+      {
+        1.09544511501033, 1.09544511501033, 0, 0.894427190999916, 0.894427190999916, 0.894427190999916, 1.4142135623731,
+        1.09544511501033, 1.09544511501033, 1.09544511501033, 1.09544511501033, 0, 1.09544511501033, 0.894427190999916,
+        0.894427190999916
+      };
+      dm[3] = new[]
+      {
+        0.894427190999916, 0.894427190999916, 0.894427190999916, 0, 1.09544511501033, 1.09544511501033, 1.09544511501033,
+        0.894427190999916, 1.4142135623731, 0.894427190999916, 0.894427190999916, 0.894427190999916, 0.894427190999916,
+        1.09544511501033, 1.09544511501033
+      };
+      dm[4] = new[]
+      {
+        0.894427190999916, 0.894427190999916, 0.894427190999916, 1.09544511501033, 0, 1.09544511501033, 1.09544511501033,
+        0.894427190999916, 0.894427190999916, 1.4142135623731, 0.894427190999916, 0.894427190999916, 1.4142135623731,
+        1.09544511501033, 0
+      };
+      dm[5] = new[]
+      {
+        1.4142135623731, 0.894427190999916, 0.894427190999916, 1.09544511501033, 1.09544511501033, 0, 1.09544511501033,
+        1.4142135623731, 0.894427190999916, 0.894427190999916, 1.4142135623731, 0.894427190999916, 0.894427190999916, 0,
+        1.09544511501033
+      };
+      dm[6] = new[]
+      {
+        0.894427190999916, 0.894427190999916, 1.4142135623731, 1.09544511501033, 1.09544511501033, 1.09544511501033, 0,
+        0.894427190999916, 0.894427190999916, 0.894427190999916, 0.894427190999916, 1.4142135623731, 0.894427190999916,
+        1.09544511501033, 1.09544511501033
+      };
+      dm[7] = new[]
+      {
+        0, 1.09544511501033, 1.09544511501033, 0.894427190999916, 0.894427190999916, 1.4142135623731, 0.894427190999916,
+        0, 1.09544511501033, 1.09544511501033, 0, 1.09544511501033, 1.09544511501033, 1.4142135623731, 0.894427190999916
+      };
+      dm[8] = new[]
+      {
+        1.09544511501033, 1.09544511501033, 1.09544511501033, 1.4142135623731, 0.894427190999916, 0.894427190999916,
+        0.894427190999916, 1.09544511501033, 0, 1.09544511501033, 1.09544511501033, 1.09544511501033, 1.09544511501033,
+        0.894427190999916, 0.894427190999916
+      };
+      dm[9] = new[]
+      {
+        1.09544511501033, 1.09544511501033, 1.09544511501033, 0.894427190999916, 1.4142135623731, 0.894427190999916,
+        0.894427190999916, 1.09544511501033, 1.09544511501033, 0, 1.09544511501033, 1.09544511501033, 0,
+        0.894427190999916, 1.4142135623731
+      };
+      dm[10] = new[]
+      {
+        0, 1.09544511501033, 1.09544511501033, 0.894427190999916, 0.894427190999916, 1.4142135623731, 0.894427190999916,
+        0, 1.09544511501033, 1.09544511501033, 0, 1.09544511501033, 1.09544511501033, 1.4142135623731, 0.894427190999916
+      };
+      dm[11] = new[]
+      {
+        1.09544511501033, 1.09544511501033, 0, 0.894427190999916, 0.894427190999916, 0.894427190999916, 1.4142135623731,
+        1.09544511501033, 1.09544511501033, 1.09544511501033, 1.09544511501033, 0, 1.09544511501033, 0.894427190999916,
+        0.894427190999916
+      };
+      dm[12] = new[]
+      {
+        1.09544511501033, 1.09544511501033, 1.09544511501033, 0.894427190999916, 1.4142135623731, 0.894427190999916,
+        0.894427190999916, 1.09544511501033, 1.09544511501033, 0, 1.09544511501033, 1.09544511501033, 0,
+        0.894427190999916, 1.4142135623731
+      };
+      dm[13] = new[]
+      {
+        1.4142135623731, 0.894427190999916, 0.894427190999916, 1.09544511501033, 1.09544511501033, 0, 1.09544511501033,
+        1.4142135623731, 0.894427190999916, 0.894427190999916, 1.4142135623731, 0.894427190999916, 0.894427190999916, 0,
+        1.09544511501033
+      };
+      dm[14] = new[]
+      {
+        0.894427190999916, 0.894427190999916, 0.894427190999916, 1.09544511501033, 0, 1.09544511501033, 1.09544511501033,
+        0.894427190999916, 0.894427190999916, 1.4142135623731, 0.894427190999916, 0.894427190999916, 1.4142135623731,
+        1.09544511501033, 0
+      };
+      return dm;
     }
 
