Index: branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPCoordinatesPathEvaluator.cs
===================================================================
--- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPCoordinatesPathEvaluator.cs	(revision 7460)
+++ branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPCoordinatesPathEvaluator.cs	(revision 7615)
@@ -73,4 +73,14 @@
     }
 
+    public static double Apply(TSPCoordinatesPathEvaluator evaluator, DoubleMatrix coordinates, Permutation tour) {
+      DoubleMatrix c = coordinates;
+      Permutation p = tour;
+      double length = 0;
+      for (int i = 0; i < p.Length - 1; i++)
+        length += evaluator.CalculateDistance(c[p[i], 0], c[p[i], 1], c[p[i + 1], 0], c[p[i + 1], 1]);
+      length += evaluator.CalculateDistance(c[p[p.Length - 1], 0], c[p[p.Length - 1], 1], c[p[0], 0], c[p[0], 1]);
+      return length;
+    }
+
     public sealed override IOperation Apply() {
       if (UseDistanceMatrixParameter.ActualValue.Value) {
Index: branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPDistanceMatrixEvaluator.cs
===================================================================
--- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPDistanceMatrixEvaluator.cs	(revision 7615)
+++ branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPDistanceMatrixEvaluator.cs	(revision 7615)
@@ -0,0 +1,79 @@
+#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.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.PermutationEncoding;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.TravelingSalesman {
+  /// <summary>
+  /// A base class for operators which evaluate TSP solutions given in path representation using a distance matrix.
+  /// </summary>
+  [Item("TSPDistanceMatrixEvaluator", "Evaluate TSP solutions given in path representation using the distance matrix.")]
+  [StorableClass]
+  public sealed class TSPDistanceMatrixEvaluator : TSPEvaluator, ITSPDistanceMatrixEvaluator {
+
+    public ILookupParameter<Permutation> PermutationParameter {
+      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
+    }
+    public ILookupParameter<DistanceMatrix> DistanceMatrixParameter {
+      get { return (ILookupParameter<DistanceMatrix>)Parameters["DistanceMatrix"]; }
+    }
+
+    [StorableConstructor]
+    private TSPDistanceMatrixEvaluator(bool deserializing) : base(deserializing) { }
+    private TSPDistanceMatrixEvaluator(TSPDistanceMatrixEvaluator original, Cloner cloner) : base(original, cloner) { }
+    public TSPDistanceMatrixEvaluator()
+      : base() {
+      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The TSP solution given in path representation which should be evaluated."));
+      Parameters.Add(new LookupParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new TSPDistanceMatrixEvaluator(this, cloner);
+    }
+
+    public static double Apply(DistanceMatrix distances, Permutation tour) {
+      if (distances == null || distances.Rows == 0 || distances.Columns == 0
+        || distances.Rows != distances.Columns)
+        throw new InvalidOperationException("The distance matrix is empty or not square");
+      if (tour == null) throw new ArgumentNullException("tour", "No tour is given.");
+      Permutation p = tour;
+      double length = 0;
+      for (int i = 0; i < p.Length - 1; i++)
+        length += distances[p[i], p[i + 1]];
+      length += distances[p[p.Length - 1], p[0]];
+      return length;
+    }
+
+    public override IOperation Apply() {
+      Permutation p = PermutationParameter.ActualValue;
+      DistanceMatrix dm = DistanceMatrixParameter.ActualValue;
+
+      QualityParameter.ActualValue = new DoubleValue(Apply(dm, p));
+      return base.Apply();
+    }
+  }
+}
Index: branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/HeuristicLab.Problems.TravelingSalesman-3.3.csproj
===================================================================
--- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/HeuristicLab.Problems.TravelingSalesman-3.3.csproj	(revision 7460)
+++ branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/HeuristicLab.Problems.TravelingSalesman-3.3.csproj	(revision 7615)
@@ -115,6 +115,8 @@
     <Compile Include="Analyzers\TSPAlleleFrequencyAnalyzer.cs" />
     <Compile Include="DistanceMatrix.cs" />
+    <Compile Include="Evaluators\TSPDistanceMatrixEvaluator.cs" />
     <Compile Include="Evaluators\TSPEuclideanPathEvaluator.cs" />
     <Compile Include="Evaluators\TSPGeoPathEvaluator.cs" />
+    <Compile Include="Interfaces\ITSPDistanceMatrixEvaluator.cs" />
     <Compile Include="MoveEvaluators\ThreeOpt\TSPTranslocationMoveEuclideanPathEvaluator.cs" />
     <Compile Include="MoveEvaluators\ThreeOpt\TSPTranslocationMoveGeoPathEvaluator.cs" />
@@ -127,5 +129,4 @@
     <Compile Include="Plugin.cs" />
     <Compile Include="TravelingSalesmanProblem.cs" />
-    <Compile Include="TSPLIBTourParser.cs" />
     <Compile Include="PathTSPTour.cs" />
     <Compile Include="Evaluators\TSPCoordinatesPathEvaluator.cs" />
@@ -139,5 +140,4 @@
     <Compile Include="MoveEvaluators\TSPPathMoveEvaluator.cs" />
     <Compile Include="MoveEvaluators\TSPMoveEvaluator.cs" />
-    <Compile Include="TSPLIBParser.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
@@ -203,4 +203,8 @@
       <Private>False</Private>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj">
+      <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project>
+      <Name>HeuristicLab.Problems.Instances-3.3</Name>
+    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
@@ -208,9 +212,4 @@
     <None Include="Plugin.cs.frame" />
     <None Include="Properties\AssemblyInfo.cs.frame" />
-    <None Include="TSPLIB Sample Problems\ch130.opt.tour" />
-    <None Include="TSPLIB Sample Problems\ch130.tsp" />
-    <None Include="TSPLIB Sample Problems\fl1400.tsp" />
-    <None Include="TSPLIB Sample Problems\gr666.opt.tour" />
-    <None Include="TSPLIB Sample Problems\gr666.tsp" />
   </ItemGroup>
   <ItemGroup>
Index: branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Interfaces/ITSPDistanceMatrixEvaluator.cs
===================================================================
--- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Interfaces/ITSPDistanceMatrixEvaluator.cs	(revision 7615)
+++ branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Interfaces/ITSPDistanceMatrixEvaluator.cs	(revision 7615)
@@ -0,0 +1,31 @@
+#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 HeuristicLab.Core;
+
+namespace HeuristicLab.Problems.TravelingSalesman {
+  /// <summary>
+  /// An interface which represents an evaluation operator which evaluates TSP solutions given in path representation using a distance matrix.
+  /// </summary>
+  public interface ITSPDistanceMatrixEvaluator : ITSPPathEvaluator {
+    ILookupParameter<DistanceMatrix> DistanceMatrixParameter { get; }
+  }
+}
Index: branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Plugin.cs.frame
===================================================================
--- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Plugin.cs.frame	(revision 7460)
+++ branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/Plugin.cs.frame	(revision 7615)
@@ -39,4 +39,5 @@
   [PluginDependency("HeuristicLab.Parameters", "3.3")]
   [PluginDependency("HeuristicLab.Persistence", "3.3")]
+  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
   public class HeuristicLabProblemsTravelingSalesmanPlugin : PluginBase {
   }
Index: branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/TSPLIBParser.cs
===================================================================
--- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/TSPLIBParser.cs	(revision 7460)
+++ 	(revision )
@@ -1,235 +1,0 @@
-#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 System.Globalization;
-using System.IO;
-
-namespace HeuristicLab.Problems.TravelingSalesman {
-  /// <summary>
-  /// Parses a *.tsp file in TSPLIB format and extracts its information about a TSP.
-  /// </summary>
-  public class TSPLIBParser {
-    #region Inner Enum TSPLIBEdgeWeightType
-    public enum TSPLIBEdgeWeightType {
-      UNDEFINED,
-      EUC_2D,
-      GEO
-    }
-    #endregion
-
-    private const int EOF = 0;
-    private const int NAME = 1;
-    private const int TYPE = 2;
-    private const int COMMENT = 3;
-    private const int DIM = 4;
-    private const int WEIGHTTYPE = 5;
-    private const int NODETYPE = 6;
-    private const int NODESECTION = 7;
-
-    private StreamReader source;
-
-    private string name;
-    /// <summary>
-    /// Gets the name of the parsed TSP.
-    /// </summary>
-    public string Name {
-      get { return name; }
-    }
-    private string comment;
-    /// <summary>
-    /// Gets the comment of the parsed TSP.
-    /// </summary>
-    public string Comment {
-      get { return comment; }
-    }
-    private double[,] vertices;
-    /// <summary>
-    /// Gets the vertices of the parsed TSP.
-    /// </summary>
-    public double[,] Vertices {
-      get { return vertices; }
-    }
-    private TSPLIBEdgeWeightType weightType;
-    /// <summary>
-    /// Gets the weight type of the parsed TSP.
-    /// </summary>
-    public TSPLIBEdgeWeightType WeightType {
-      get { return weightType; }
-    }
-
-    /// <summary>
-    /// Initializes a new instance of <see cref="TSPLIBParser"/> with the given <paramref name="path"/>.
-    /// </summary>
-    /// <exception cref="ArgumentException">Thrown if the input file is not a TSPLIB TSP file (*.tsp)
-    /// </exception>
-    /// <param name="path">The path where the TSP is stored.</param>
-    public TSPLIBParser(String path) {
-      if (!path.EndsWith(".tsp"))
-        throw new ArgumentException("Input file has to be a TSPLIB TSP file (*.tsp).");
-
-      source = new StreamReader(path);
-      name = path;
-      comment = string.Empty;
-      vertices = null;
-      weightType = TSPLIBEdgeWeightType.UNDEFINED;
-    }
-
-    /// <summary>
-    /// Reads the TSPLIB TSP file and parses the elements.
-    /// </summary>
-    /// <exception cref="InvalidDataException">Thrown if the file has an invalid format or contains invalid data.</exception>
-    public void Parse() {
-      int section = -1;
-      string str = null;
-      bool typeIsChecked = false;
-      bool weightTypeIsChecked = false;
-
-      do {
-        str = source.ReadLine();
-        section = GetSection(str);
-
-        if (section != -1) {
-          switch (section) {
-            case NAME:
-              ReadName(str);
-              break;
-            case TYPE:
-              CheckType(str);
-              typeIsChecked = true;
-              break;
-            case COMMENT:
-              ReadComment(str);
-              break;
-            case DIM:
-              InitVerticesArray(str);
-              break;
-            case WEIGHTTYPE:
-              ReadWeightType(str);
-              weightTypeIsChecked = true;
-              break;
-            case NODETYPE:
-              CheckNodeType(str);
-              break;
-            case NODESECTION:
-              ReadVertices();
-              break;
-          }
-        }
-      } while (!((section == EOF) || (str == null)));
-
-      if (!(typeIsChecked && weightTypeIsChecked))
-        throw new InvalidDataException("Input file does not contain type or edge weight type information.");
-    }
-
-    private int GetSection(string str) {
-      if (str == null)
-        return EOF;
-
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-      if (tokens.Length == 0)
-        return -1;
-
-      string token = tokens[0].Trim();
-      if (token.Equals("eof", StringComparison.OrdinalIgnoreCase))
-        return EOF;
-      if (token.Equals("name", StringComparison.OrdinalIgnoreCase))
-        return NAME;
-      if (token.Equals("type", StringComparison.OrdinalIgnoreCase))
-        return TYPE;
-      if (token.Equals("comment", StringComparison.OrdinalIgnoreCase))
-        return COMMENT;
-      if (token.Equals("dimension", StringComparison.OrdinalIgnoreCase))
-        return DIM;
-      if (token.Equals("edge_weight_type", StringComparison.OrdinalIgnoreCase))
-        return WEIGHTTYPE;
-      if (token.Equals("node_coord_type", StringComparison.OrdinalIgnoreCase))
-        return NODETYPE;
-      if (token.Equals("node_coord_section", StringComparison.OrdinalIgnoreCase))
-        return NODESECTION;
-
-      return -1;
-    }
-
-    private void ReadName(string str) {
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-      name = tokens[tokens.Length - 1].Trim();
-    }
-
-    private void CheckType(string str) {
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-
-      string type = tokens[tokens.Length - 1].Trim();
-      if (!type.Equals("tsp", StringComparison.OrdinalIgnoreCase))
-        throw new InvalidDataException("Input file type is not \"TSP\"");
-    }
-
-    private void ReadComment(string str) {
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-      comment = tokens[tokens.Length - 1].Trim();
-    }
-
-    private void InitVerticesArray(string str) {
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-      string dimension = tokens[tokens.Length - 1].Trim();
-
-      int dim = Int32.Parse(dimension);
-      vertices = new double[dim, 2];
-    }
-
-    private void ReadWeightType(string str) {
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-      string type = tokens[tokens.Length - 1].Trim();
-
-      if (type.Equals("euc_2d", StringComparison.OrdinalIgnoreCase))
-        weightType = TSPLIBEdgeWeightType.EUC_2D;
-      else if (type.Equals("geo", StringComparison.OrdinalIgnoreCase))
-        weightType = TSPLIBEdgeWeightType.GEO;
-      else
-        throw new InvalidDataException("Input file contains an unsupported edge weight type (only \"EUC_2D\" and \"GEO\" are supported).");
-    }
-
-    private void CheckNodeType(string str) {
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-      string type = tokens[tokens.Length - 1].Trim();
-
-      if (!type.Equals("twod_coords", StringComparison.OrdinalIgnoreCase))
-        throw new InvalidDataException("Input file contains an unsupported node coordinates type (only \"TWOD_COORDS\" is supported).");
-    }
-
-    private void ReadVertices() {
-      if (vertices == null)
-        throw new InvalidDataException("Input file does not contain dimension information.");
-
-      for (int i = 0; i < (vertices.Length / 2); i++) {
-        string str = source.ReadLine();
-        string[] tokens = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
-
-        if (tokens.Length != 3)
-          throw new InvalidDataException("Input file contains invalid node coordinates.");
-
-        CultureInfo culture = new CultureInfo("en-US");
-        vertices[i, 0] = double.Parse(tokens[1], culture.NumberFormat);
-        vertices[i, 1] = double.Parse(tokens[2], culture.NumberFormat);
-      }
-    }
-  }
-}
Index: branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/TSPLIBTourParser.cs
===================================================================
--- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/TSPLIBTourParser.cs	(revision 7460)
+++ 	(revision )
@@ -1,180 +1,0 @@
-#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 System.Globalization;
-using System.IO;
-
-namespace HeuristicLab.Problems.TravelingSalesman {
-  /// <summary>
-  /// Parses a *.opt.tour file in TSPLIB format and extracts its information about an optimal tour of a TSP.
-  /// </summary>
-  public class TSPLIBTourParser {
-    private const int EOF = 0;
-    private const int NAME = 1;
-    private const int TYPE = 2;
-    private const int COMMENT = 3;
-    private const int DIM = 4;
-    private const int TOURSECTION = 5;
-
-    private StreamReader source;
-
-    private string name;
-    /// <summary>
-    /// Gets the name of the parsed tour.
-    /// </summary>
-    public string Name {
-      get { return name; }
-    }
-    private string comment;
-    /// <summary>
-    /// Gets the comment of the parsed tour.
-    /// </summary>
-    public string Comment {
-      get { return comment; }
-    }
-    private int[] tour;
-    /// <summary>
-    /// Gets the parsed tour.
-    /// </summary>
-    public int[] Tour {
-      get { return tour; }
-    }
-
-    /// <summary>
-    /// Initializes a new instance of <see cref="TSPLIBTourParser"/> with the given <paramref name="path"/>.
-    /// </summary>
-    /// <exception cref="ArgumentException">Thrown if the input file is not a TSPLIB optimal tour file (*.opt.tour)
-    /// </exception>
-    /// <param name="path">The path where the optimal tour is stored.</param>
-    public TSPLIBTourParser(String path) {
-      if (!path.EndsWith(".opt.tour"))
-        throw new ArgumentException("Input file has to be a TSPLIB optimal tour file (*.opt.tour).");
-
-      source = new StreamReader(path);
-      name = path;
-      comment = string.Empty;
-      tour = null;
-    }
-
-    /// <summary>
-    /// Reads the TSPLIB optimal tour file and parses its elements.
-    /// </summary>
-    /// <exception cref="InvalidDataException">Thrown if the file has an invalid format or contains invalid data.</exception>
-    public void Parse() {
-      int section = -1;
-      string str = null;
-      bool typeIsChecked = false;
-
-      do {
-        str = source.ReadLine();
-        section = GetSection(str);
-
-        if (section != -1) {
-          switch (section) {
-            case NAME:
-              ReadName(str);
-              break;
-            case TYPE:
-              CheckType(str);
-              typeIsChecked = true;
-              break;
-            case COMMENT:
-              ReadComment(str);
-              break;
-            case DIM:
-              InitTour(str);
-              break;
-            case TOURSECTION:
-              ReadTour();
-              break;
-          }
-        }
-      } while (!((section == EOF) || (str == null)));
-
-      if (!typeIsChecked)
-        throw new InvalidDataException("Input file does not contain type information.");
-    }
-
-    private int GetSection(string str) {
-      if (str == null)
-        return EOF;
-
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-      if (tokens.Length == 0)
-        return -1;
-
-      string token = tokens[0].Trim();
-      if (token.Equals("eof", StringComparison.OrdinalIgnoreCase))
-        return EOF;
-      if (token.Equals("name", StringComparison.OrdinalIgnoreCase))
-        return NAME;
-      if (token.Equals("type", StringComparison.OrdinalIgnoreCase))
-        return TYPE;
-      if (token.Equals("comment", StringComparison.OrdinalIgnoreCase))
-        return COMMENT;
-      if (token.Equals("dimension", StringComparison.OrdinalIgnoreCase))
-        return DIM;
-      if (token.Equals("tour_section", StringComparison.OrdinalIgnoreCase))
-        return TOURSECTION;
-
-      return -1;
-    }
-
-    private void ReadName(string str) {
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-      name = tokens[tokens.Length - 1].Trim();
-    }
-
-    private void CheckType(string str) {
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-
-      string type = tokens[tokens.Length - 1].Trim();
-      if (!type.Equals("tour", StringComparison.OrdinalIgnoreCase))
-        throw new InvalidDataException("Input data format is not \"TOUR\"");
-    }
-
-    private void ReadComment(string str) {
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-      comment = tokens[tokens.Length - 1].Trim();
-    }
-
-    private void InitTour(string str) {
-      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-      string dimension = tokens[tokens.Length - 1].Trim();
-
-      int dim = Int32.Parse(dimension);
-      tour = new int[dim];
-    }
-
-    private void ReadTour() {
-      if (tour == null)
-        throw new InvalidDataException("Input file does not contain dimension information.");
-
-      for (int i = 0; i < (tour.Length); i++) {
-        string str = source.ReadLine();
-
-        CultureInfo culture = new CultureInfo("en-US");
-        tour[i] = int.Parse(str, culture.NumberFormat) - 1;
-      }
-    }
-  }
-}
Index: branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
===================================================================
--- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs	(revision 7460)
+++ branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs	(revision 7615)
@@ -32,4 +32,5 @@
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.Instances;
 
 namespace HeuristicLab.Problems.TravelingSalesman {
@@ -37,5 +38,7 @@
   [Creatable("Problems")]
   [StorableClass]
-  public sealed class TravelingSalesmanProblem : SingleObjectiveHeuristicOptimizationProblem<ITSPEvaluator, IPermutationCreator>, IStorableContent {
+  public sealed class TravelingSalesmanProblem : SingleObjectiveHeuristicOptimizationProblem<ITSPEvaluator, IPermutationCreator>, IStorableContent,
+    IProblemInstanceConsumer<TSPData> {
+    private static readonly int DistanceMatrixSizeLimit = 1000;
     public string Filename { get; set; }
 
@@ -107,5 +110,4 @@
     public TravelingSalesmanProblem()
       : base(new TSPRoundedEuclideanPathEvaluator(), new RandomPermutationCreator()) {
-
       Parameters.Add(new ValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the cities."));
       Parameters.Add(new OptionalValueParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
@@ -247,4 +249,9 @@
         evaluator.UseDistanceMatrixParameter.Hidden = true;
       }
+      if (Evaluator is ITSPDistanceMatrixEvaluator) {
+        var evaluator = (ITSPDistanceMatrixEvaluator)Evaluator;
+        evaluator.DistanceMatrixParameter.ActualName = DistanceMatrixParameter.Name;
+        evaluator.DistanceMatrixParameter.Hidden = true;
+      }
     }
     private void ParameterizeAnalyzers() {
@@ -310,37 +317,87 @@
 
     private void ClearDistanceMatrix() {
-      DistanceMatrixParameter.Value = null;
+      if (!(Evaluator is ITSPDistanceMatrixEvaluator))
+        DistanceMatrixParameter.Value = null;
     }
     #endregion
 
-    public void ImportFromTSPLIB(string tspFileName, string optimalTourFileName) {
-      TSPLIBParser tspParser = new TSPLIBParser(tspFileName);
-      tspParser.Parse();
-      Name = tspParser.Name + " TSP (imported from TSPLIB)";
-      if (!string.IsNullOrEmpty(tspParser.Comment)) Description = tspParser.Comment;
-      Coordinates = new DoubleMatrix(tspParser.Vertices);
-      if (tspParser.WeightType == TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D) {
-        TSPRoundedEuclideanPathEvaluator evaluator = new TSPRoundedEuclideanPathEvaluator();
-        evaluator.QualityParameter.ActualName = "TSPTourLength";
-        Evaluator = evaluator;
-      } else if (tspParser.WeightType == TSPLIBParser.TSPLIBEdgeWeightType.GEO) {
-        TSPGeoPathEvaluator evaluator = new TSPGeoPathEvaluator();
-        evaluator.QualityParameter.ActualName = "TSPTourLength";
-        Evaluator = evaluator;
-      }
+    public void Load(TSPData data) {
+      if (data.Coordinates == null && data.Distances == null)
+        throw new System.IO.InvalidDataException("The given instance does not specify neither coordinates or distances!");
+      if (data.Dimension > DistanceMatrixSizeLimit && (data.DistanceMeasure == TSPDistanceMeasure.Att
+        || data.DistanceMeasure == TSPDistanceMeasure.Manhattan
+        || data.DistanceMeasure == TSPDistanceMeasure.Maximum
+        || data.DistanceMeasure == TSPDistanceMeasure.UpperEuclidean))
+        throw new System.IO.InvalidDataException("The given instance uses an unsupported distance measure and is too large for using a distance matrix.");
+      if (data.Coordinates != null && data.Coordinates.GetLength(1) != 2)
+        throw new System.IO.InvalidDataException("The coordinates of the given instance are not in the right format, there need to be one row for each customer and two columns for the x and y coordinates.");
+
+      Name = data.Name;
+      Description = data.Description;
+
+      if (data.Coordinates != null && data.Coordinates.GetLength(0) > 0)
+        Coordinates = new DoubleMatrix(data.Coordinates);
+
+      TSPEvaluator evaluator;
+      if (data.DistanceMeasure == TSPDistanceMeasure.Att
+        || data.DistanceMeasure == TSPDistanceMeasure.Manhattan
+        || data.DistanceMeasure == TSPDistanceMeasure.Maximum
+        || data.DistanceMeasure == TSPDistanceMeasure.UpperEuclidean) {
+        evaluator = new TSPDistanceMatrixEvaluator();
+        UseDistanceMatrix = new BoolValue(true);
+        DistanceMatrix = new DistanceMatrix(data.GetDistanceMatrix());
+      } else if (data.DistanceMeasure == TSPDistanceMeasure.Direct && data.Distances != null) {
+        evaluator = new TSPDistanceMatrixEvaluator();
+        UseDistanceMatrix = new BoolValue(true);
+        DistanceMatrix = new DistanceMatrix(data.Distances);
+      } else {
+        DistanceMatrix = null;
+        UseDistanceMatrix = new BoolValue(data.Dimension <= DistanceMatrixSizeLimit);
+        switch (data.DistanceMeasure) {
+          case TSPDistanceMeasure.Euclidean:
+            evaluator = new TSPEuclideanPathEvaluator();
+            break;
+          case TSPDistanceMeasure.RoundedEuclidean:
+            evaluator = new TSPRoundedEuclideanPathEvaluator();
+            break;
+          case TSPDistanceMeasure.Geo:
+            evaluator = new TSPGeoPathEvaluator();
+            break;
+          default:
+            throw new InvalidDataException("An unknown distance measure is given in the instance!");
+        }
+      }
+      evaluator.QualityParameter.ActualName = "TSPTourLength";
+      Evaluator = evaluator;
+
+      BestKnownSolution = null;
       BestKnownQuality = null;
-      BestKnownSolution = null;
-
-      if (!string.IsNullOrEmpty(optimalTourFileName)) {
-        TSPLIBTourParser tourParser = new TSPLIBTourParser(optimalTourFileName);
-        tourParser.Parse();
-        if (tourParser.Tour.Length != Coordinates.Rows) throw new InvalidDataException("Length of optimal tour is not equal to number of cities.");
-        BestKnownSolution = new Permutation(PermutationTypes.RelativeUndirected, tourParser.Tour);
+
+      if (data.BestKnownTour != null) {
+        try {
+          EvaluateAndLoadTour(data.BestKnownTour);
+        } catch (InvalidOperationException) {
+          if (data.BestKnownQuality.HasValue)
+            BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value);
+        }
+      } else if (data.BestKnownQuality.HasValue) {
+        BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value);
       }
       OnReset();
     }
-    public void ImportFromTSPLIB(string tspFileName, string optimalTourFileName, double bestKnownQuality) {
-      ImportFromTSPLIB(tspFileName, optimalTourFileName);
-      BestKnownQuality = new DoubleValue(bestKnownQuality);
+
+    public void EvaluateAndLoadTour(int[] tour) {
+      var route = new Permutation(PermutationTypes.RelativeUndirected, tour);
+      BestKnownSolution = route;
+
+      double quality;
+      if (Evaluator is TSPDistanceMatrixEvaluator) {
+        quality = TSPDistanceMatrixEvaluator.Apply(DistanceMatrix, route);
+      } else if (Evaluator is TSPCoordinatesPathEvaluator) {
+        quality = TSPCoordinatesPathEvaluator.Apply((TSPCoordinatesPathEvaluator)Evaluator, Coordinates, route);
+      } else {
+        throw new InvalidOperationException("Cannot calculate solution quality, evaluator type is unknown.");
+      }
+      BestKnownQuality = new DoubleValue(quality);
     }
   }
