Index: trunk/sources/HeuristicLab.Problems.TSP/3.3/Evaluators/TSPCoordinatesPathEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.TSP/3.3/Evaluators/TSPCoordinatesPathEvaluator.cs	(revision 3065)
+++ trunk/sources/HeuristicLab.Problems.TSP/3.3/Evaluators/TSPCoordinatesPathEvaluator.cs	(revision 3066)
@@ -39,4 +39,10 @@
       get { return (ILookupParameter<DoubleMatrix>)Parameters["Coordinates"]; }
     }
+    public ILookupParameter<DoubleMatrix> DistanceMatrixParameter {
+      get { return (ILookupParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
+    }
+    public ILookupParameter<BoolValue> UseDistanceMatrixParameter {
+      get { return (ILookupParameter<BoolValue>)Parameters["UseDistanceMatrix"]; }
+    }
 
     protected TSPCoordinatesPathEvaluator()
@@ -44,16 +50,39 @@
       Parameters.Add(new LookupParameter<Permutation>("Permutation", "The TSP solution given in path representation which should be evaluated."));
       Parameters.Add(new LookupParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the cities."));
+      Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
+      Parameters.Add(new LookupParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false."));
     }
 
     public sealed override IOperation Apply() {
-      Permutation p = PermutationParameter.ActualValue;
-      DoubleMatrix c = CoordinatesParameter.ActualValue;
+      if (UseDistanceMatrixParameter.ActualValue.Value) {
+        Permutation p = PermutationParameter.ActualValue;
+        DoubleMatrix dm = DistanceMatrixParameter.ActualValue;
 
-      double length = 0;
-      for (int i = 0; i < p.Length - 1; i++)
-        length += CalculateDistance(c[p[i], 0], c[p[i], 1], c[p[i + 1], 0], c[p[i + 1], 1]);
-      length += CalculateDistance(c[p[p.Length - 1], 0], c[p[p.Length - 1], 1], c[p[0], 0], c[p[0], 1]);
-      QualityParameter.ActualValue = new DoubleValue(length);
+        if (dm == null) {  // calculate distance matrix
+          DoubleMatrix c = CoordinatesParameter.ActualValue;
 
+          dm = new DoubleMatrix(c.Rows, c.Rows);
+          for (int i = 0; i < dm.Rows; i++) {
+            for (int j = 0; j < dm.Columns; j++)
+              dm[i, j] = CalculateDistance(c[i, 0], c[i, 1], c[j, 0], c[j, 1]);
+          }
+          DistanceMatrixParameter.ActualValue = dm;
+        }
+
+        double length = 0;
+        for (int i = 0; i < p.Length - 1; i++)
+          length += dm[p[i], p[i + 1]];
+        length += dm[p[p.Length - 1], p[0]];
+        QualityParameter.ActualValue = new DoubleValue(length);
+      } else {
+        Permutation p = PermutationParameter.ActualValue;
+        DoubleMatrix c = CoordinatesParameter.ActualValue;
+
+        double length = 0;
+        for (int i = 0; i < p.Length - 1; i++)
+          length += CalculateDistance(c[p[i], 0], c[p[i], 1], c[p[i + 1], 0], c[p[i + 1], 1]);
+        length += CalculateDistance(c[p[p.Length - 1], 0], c[p[p.Length - 1], 1], c[p[0], 0], c[p[0], 1]);
+        QualityParameter.ActualValue = new DoubleValue(length);
+      }
       return base.Apply();
     }
Index: trunk/sources/HeuristicLab.Problems.TSP/3.3/Evaluators/TSPDistanceMatrixPathEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.TSP/3.3/Evaluators/TSPDistanceMatrixPathEvaluator.cs	(revision 3065)
+++ 	(revision )
@@ -1,62 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2010 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 HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Encodings.PermutationEncoding;
-using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Problems.TSP {
-  /// <summary>
-  /// An operator which evaluates TSP solutions given in path representation using a distance matrix.
-  /// </summary>
-  [Item("TSPDistanceMatrixPathEvaluator", "An operator which evaluates TSP solutions given in path representation using a distance matrix.")]
-  [Creatable("Test")]
-  [StorableClass]
-  public sealed class TSPDistanceMatrixPathEvaluator : TSPEvaluator, ITSPDistanceMatrixPathEvaluator {
-    public ILookupParameter<Permutation> PermutationParameter {
-      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
-    }
-    public ILookupParameter<DoubleMatrix> DistanceMatrixParameter {
-      get { return (ILookupParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
-    }
-
-    public TSPDistanceMatrixPathEvaluator()
-      : base() {
-      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The TSP solution given in path representation which should be evaluated."));
-      Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The distance matrix of the cities."));
-    }
-
-    public sealed override IOperation Apply() {
-      Permutation p = PermutationParameter.ActualValue;
-      DoubleMatrix d = DistanceMatrixParameter.ActualValue;
-
-      double length = 0;
-      for (int i = 0; i < p.Length - 1; i++)
-        length += d[p[i], p[i + 1]];
-      length += d[p[p.Length - 1], p[0]];
-      QualityParameter.ActualValue = new DoubleValue(length);
-
-      return base.Apply();
-    }
-  }
-}
Index: trunk/sources/HeuristicLab.Problems.TSP/3.3/HeuristicLab.Problems.TSP-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Problems.TSP/3.3/HeuristicLab.Problems.TSP-3.3.csproj	(revision 3065)
+++ trunk/sources/HeuristicLab.Problems.TSP/3.3/HeuristicLab.Problems.TSP-3.3.csproj	(revision 3066)
@@ -85,9 +85,7 @@
   <ItemGroup>
     <Compile Include="Evaluators\TSPCoordinatesPathEvaluator.cs" />
-    <Compile Include="Evaluators\TSPDistanceMatrixPathEvaluator.cs" />
     <Compile Include="Evaluators\TSPEvaluator.cs" />
     <Compile Include="Evaluators\TSPRoundedEuclideanPathEvaluator.cs" />
     <Compile Include="Interfaces\ITSPCoordinatesPathEvaluator.cs" />
-    <Compile Include="Interfaces\ITSPDistanceMatrixPathEvaluator.cs" />
     <Compile Include="Interfaces\ITSPEvaluator.cs" />
     <Compile Include="Interfaces\ITSPPathEvaluator.cs" />
Index: trunk/sources/HeuristicLab.Problems.TSP/3.3/Interfaces/ITSPCoordinatesPathEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.TSP/3.3/Interfaces/ITSPCoordinatesPathEvaluator.cs	(revision 3065)
+++ trunk/sources/HeuristicLab.Problems.TSP/3.3/Interfaces/ITSPCoordinatesPathEvaluator.cs	(revision 3066)
@@ -29,4 +29,6 @@
   public interface ITSPCoordinatesPathEvaluator : ITSPPathEvaluator {
     ILookupParameter<DoubleMatrix> CoordinatesParameter { get; }
+    ILookupParameter<DoubleMatrix> DistanceMatrixParameter { get; }
+    ILookupParameter<BoolValue> UseDistanceMatrixParameter { get; }
   }
 }
Index: trunk/sources/HeuristicLab.Problems.TSP/3.3/Interfaces/ITSPDistanceMatrixPathEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.TSP/3.3/Interfaces/ITSPDistanceMatrixPathEvaluator.cs	(revision 3065)
+++ 	(revision )
@@ -1,32 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2010 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 HeuristicLab.Core;
-using HeuristicLab.Data;
-
-namespace HeuristicLab.Problems.TSP {
-  /// <summary>
-  /// An interface which represents an evaluation operator which evaluates TSP solutions given in path representation using a distance matrix.
-  /// </summary>
-  public interface ITSPDistanceMatrixPathEvaluator : ITSPPathEvaluator {
-    ILookupParameter<DoubleMatrix> DistanceMatrixParameter { get; }
-  }
-}
Index: trunk/sources/HeuristicLab.Problems.TSP/3.3/TSP.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.TSP/3.3/TSP.cs	(revision 3065)
+++ trunk/sources/HeuristicLab.Problems.TSP/3.3/TSP.cs	(revision 3066)
@@ -52,4 +52,10 @@
       get { return (ValueParameter<DoubleMatrix>)Parameters["Coordinates"]; }
     }
+    public OptionalValueParameter<DoubleMatrix> DistanceMatrixParameter {
+      get { return (OptionalValueParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
+    }
+    public ValueParameter<BoolValue> UseDistanceMatrixParameter {
+      get { return (ValueParameter<BoolValue>)Parameters["UseDistanceMatrix"]; }
+    }
     public ValueParameter<IPermutationCreator> SolutionCreatorParameter {
       get { return (ValueParameter<IPermutationCreator>)Parameters["SolutionCreator"]; }
@@ -74,4 +80,12 @@
       set { CoordinatesParameter.Value = value; }
     }
+    public DoubleMatrix DistanceMatrix {
+      get { return DistanceMatrixParameter.Value; }
+      set { DistanceMatrixParameter.Value = value; }
+    }
+    public BoolValue UseDistanceMatrix {
+      get { return UseDistanceMatrixParameter.Value; }
+      set { UseDistanceMatrixParameter.Value = value; }
+    }
     public IPermutationCreator SolutionCreator {
       get { return SolutionCreatorParameter.Value; }
@@ -108,4 +122,6 @@
       Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the Traveling Salesman Problem is a minimization problem.", new BoolValue(false)));
       Parameters.Add(new ValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the cities.", new DoubleMatrix(0, 0)));
+      Parameters.Add(new OptionalValueParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
+      Parameters.Add(new ValueParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false.", new BoolValue(true)));
       Parameters.Add(new ValueParameter<IPermutationCreator>("SolutionCreator", "The operator which should be used to create new TSP solutions.", creator));
       Parameters.Add(new ValueParameter<ITSPEvaluator>("Evaluator", "The operator which should be used to evaluate TSP solutions.", evaluator));
@@ -155,9 +171,12 @@
       Coordinates.Reset += new EventHandler(Coordinates_Reset);
       ParameterizeSolutionCreator();
+      ClearDistanceMatrix();
     }
     private void Coordinates_ItemChanged(object sender, EventArgs<int, int> e) {
+      ClearDistanceMatrix();
     }
     private void Coordinates_Reset(object sender, EventArgs e) {
       ParameterizeSolutionCreator();
+      ClearDistanceMatrix();
     }
     private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
@@ -174,4 +193,5 @@
     private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
       ParameterizeEvaluator();
+      ClearDistanceMatrix();
       OnEvaluatorChanged();
     }
@@ -195,6 +215,10 @@
       if (Evaluator is ITSPPathEvaluator)
         ((ITSPPathEvaluator)Evaluator).PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
-      if (Evaluator is ITSPCoordinatesPathEvaluator)
-        ((ITSPCoordinatesPathEvaluator)Evaluator).CoordinatesParameter.ActualName = CoordinatesParameter.Name;
+      if (Evaluator is ITSPCoordinatesPathEvaluator) {
+        ITSPCoordinatesPathEvaluator evaluator = (ITSPCoordinatesPathEvaluator)Evaluator;
+        evaluator.CoordinatesParameter.ActualName = CoordinatesParameter.Name;
+        evaluator.DistanceMatrixParameter.ActualName = DistanceMatrixParameter.Name;
+        evaluator.UseDistanceMatrixParameter.ActualName = UseDistanceMatrixParameter.Name;
+      }
     }
     private void InitializeOperators() {
@@ -214,4 +238,7 @@
       }
     }
+    private void ClearDistanceMatrix() {
+      DistanceMatrixParameter.Value = null;
+    }
     #endregion
   }
