Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/MultidimensionalScaling.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/MultidimensionalScaling.cs	(revision 5647)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/MultidimensionalScaling.cs	(revision 5648)
@@ -23,51 +23,6 @@
 using HeuristicLab.Data;
 
-namespace HeuristicLab.Problems.QuadraticAssignment {
+namespace HeuristicLab.Problems.QuadraticAssignment.Views {
   public static class MultidimensionalScaling {
-
-    public static DoubleMatrix Classic(DoubleMatrix distances, out double error) {
-      if (distances == null) throw new ArgumentNullException("distances");
-      if (distances.Rows != distances.Columns) throw new ArgumentException("Distance matrix must be a square matrix.", "distances");
-      error = 0.0;
-
-      int dimension = distances.Rows;
-      if (dimension == 1) return new DoubleMatrix(new double[,] { { 0, 0 } });
-      else if (dimension == 2) return new DoubleMatrix(new double[,] { { 0, distances[0, 1] } });
-
-      double[,] A = new double[dimension + 1, dimension + 1];
-      for (int i = 1; i < dimension; i++) {
-        for (int j = i + 1; j < dimension + 1; j++) {
-          A[i, j] = -0.5 * distances[i - 1, j - 1] * distances[i - 1, j - 1];
-          A[j, i] = A[i, j];
-          A[0, 0] += A[i, j] / (dimension * dimension);
-          double avg = A[i, j] / (double)dimension;
-          A[0, j] += avg;
-          A[0, i] += avg;
-          A[i, 0] += avg;
-          A[j, 0] += avg;
-        }
-      }
-      double[,] B = new double[dimension, dimension];
-      for (int i = 0; i < dimension - 1; i++) {
-        for (int j = i + 1; j < dimension; j++) {
-          B[i, j] = A[i + 1, j + 1] - A[0, j + 1] - A[i + 1, 0] + A[0, 0];
-        }
-      }
-      double[] eigenvalues;
-      double[,] eigenvectors;
-      alglib.smatrixevd(B, dimension, 1, true, out eigenvalues, out eigenvectors);
-
-      DoubleMatrix coordinates = new DoubleMatrix(dimension, 2);
-      for (int i = 0; i < dimension; i++) {
-        for (int j = 0; j < dimension; j++) {
-          coordinates[i, 0] += eigenvectors[eigenvectors.GetLength(0) - 1, j]
-                             * distances[i, j];
-          coordinates[i, 1] += eigenvectors[eigenvectors.GetLength(0) - 2, j]
-                             * distances[i, j];
-        }
-      }
-
-      return coordinates;
-    }
 
     /// <summary>
@@ -77,10 +32,10 @@
     /// </summary>
     /// <param name="distances">A symmetric NxN matrix that specifies the distances between each element i and j. Diagonal elements are ignored.</param>
-    /// <param name="error">Returns the error between the fit distances and the actual distances.</param>
+    /// <param name="stress">Returns the stress between the fit distances and the actual distances.</param>
     /// <returns>A Nx2 matrix where the first column represents the x- and the second column the y coordinates.</returns>
-    public static DoubleMatrix Metric(DoubleMatrix distances, out double error) {
+    public static DoubleMatrix MetricByDistance(DoubleMatrix distances, out double stress) {
       if (distances == null) throw new ArgumentNullException("distances");
       if (distances.Rows != distances.Columns) throw new ArgumentException("Distance matrix must be a square matrix.", "distances");
-      error = 0.0;
+      stress = 0.0;
 
       int dimension = distances.Rows;
@@ -94,12 +49,13 @@
         coordinates[i, 1] = 10 * Math.Sin(rad * i);
       }
-      double epsg = 0.0000000001;
+
+      double epsg = 1e-7;
       double epsf = 0;
       double epsx = 0;
-      int maxits = 1000;
+      int maxits = 0;
       alglib.mincgstate state = null;
       alglib.mincgreport rep;
 
-      for (int iterations = 0; iterations < 200; iterations++) {
+      for (int iterations = 0; iterations < 10; iterations++) {
         for (int i = 0; i < dimension; i++) {
           double[] c = new double[] { coordinates[i, 0], coordinates[i, 1] };
@@ -111,5 +67,5 @@
             alglib.mincgrestartfrom(state, c);
           }
-          alglib.mincgoptimize(state, func, null, new Info(coordinates, distances, i));
+          alglib.mincgoptimize(state, StressGradient, null, new Info(coordinates, distances, i));
           alglib.mincgresults(state, out c, out rep);
 
@@ -118,32 +74,44 @@
         }
       }
-      error = 0;
+      stress = CalculateNormalizedStress(dimension, distances, coordinates);
+      return coordinates;
+    }
+
+    private static void StressGradient(double[] x, ref double func, double[] grad, object obj) {
+      func = 0; grad[0] = 0; grad[1] = 0;
+      Info info = (obj as Info);
+      for (int i = 0; i < info.Coordinates.Rows; i++) {
+        double c = info.Distances[info.Row, i];
+        if (i != info.Row) {
+          double a = info.Coordinates[i, 0];
+          double b = info.Coordinates[i, 1];
+          func += Stress(x, c, a, b);
+          grad[0] += ((2 * x[0] - 2 * a) * Math.Sqrt(x[1] * x[1] - 2 * b * x[1] + x[0] * x[0] - 2 * a * x[0] + b * b + a * a) - 2 * c * x[0] + 2 * a * c) / Math.Sqrt(x[1] * x[1] - 2 * b * x[1] + x[0] * x[0] - 2 * a * x[0] + b * b + a * a);
+          grad[1] += ((2 * x[1] - 2 * b) * Math.Sqrt(x[1] * x[1] - 2 * b * x[1] + x[0] * x[0] - 2 * a * x[0] + b * b + a * a) - 2 * c * x[1] + 2 * b * c) / Math.Sqrt(x[1] * x[1] - 2 * b * x[1] + x[0] * x[0] - 2 * a * x[0] + b * b + a * a);
+        }
+      }
+    }
+
+    private static double Stress(double[] x, double distance, double xCoord, double yCoord) {
+      return Stress(x[0], x[1], distance, xCoord, yCoord);
+    }
+
+    private static double Stress(double x, double y, double distance, double otherX, double otherY) {
+      double d = Math.Sqrt((x - otherX) * (x - otherX)
+                         + (y - otherY) * (y - otherY));
+      return (d - distance) * (d - distance);
+    }
+
+    public static double CalculateNormalizedStress(int dimension, DoubleMatrix distances, DoubleMatrix coordinates) {
+      double stress = 0;
       for (int i = 0; i < dimension - 1; i++) {
         for (int j = i + 1; j < dimension; j++) {
           if (distances[i, j] != 0) {
-            double dx = coordinates[i, 0] - coordinates[j, 0];
-            double dy = coordinates[i, 1] - coordinates[j, 1];
-            double d = Math.Sqrt(dx * dx + dy * dy);
-            error += ((distances[i, j] - d) * (distances[i, j] - d)) / (distances[i, j] * distances[i, j]);
+            stress += Stress(coordinates[i, 0], coordinates[i, 1], distances[i, j], coordinates[j, 0], coordinates[j, 1])
+              / (distances[i, j] * distances[i, j]);
           }
         }
       }
-      return coordinates;
-    }
-
-    public static void func(double[] x, ref double func, double[] grad, object obj) {
-      func = 0; grad[0] = 0; grad[1] = 0;
-      Info info = (obj as Info);
-      for (int i = 0; i < x.Length; i++) {
-        if (i != info.Row) {
-          double d = (x[0] - info.Coordinates[i, 0])
-                   * (x[0] - info.Coordinates[i, 0])
-                   + (x[1] - info.Coordinates[i, 1])
-                   * (x[1] - info.Coordinates[i, 1]);
-          func += (d - info.Distances[info.Row, i]) * (d - info.Distances[info.Row, i]);
-          grad[0] += 2 * x[0] - 2 * info.Coordinates[i, 0];
-          grad[1] += 2 * x[1] - 2 * info.Coordinates[i, 1];
-        }
-      }
+      return stress;
     }
 
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.Designer.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.Designer.cs	(revision 5647)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.Designer.cs	(revision 5648)
@@ -50,11 +50,8 @@
       this.tabControl = new HeuristicLab.MainForm.WindowsForms.DragOverTabControl();
       this.visualizationTabPage = new System.Windows.Forms.TabPage();
-      this.distancesRadioButton = new System.Windows.Forms.RadioButton();
-      this.weightsRadioButton = new System.Windows.Forms.RadioButton();
-      this.pictureBox = new System.Windows.Forms.PictureBox();
       this.valueTabPage = new System.Windows.Forms.TabPage();
       this.assignmentGroupBox = new System.Windows.Forms.GroupBox();
       this.assignmentViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
-      this.redrawButton = new System.Windows.Forms.Button();
+      this.qapView = new HeuristicLab.Problems.QuadraticAssignment.Views.QAPView();
       ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
       this.splitContainer.Panel1.SuspendLayout();
@@ -64,5 +61,4 @@
       this.tabControl.SuspendLayout();
       this.visualizationTabPage.SuspendLayout();
-      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
       this.valueTabPage.SuspendLayout();
       this.assignmentGroupBox.SuspendLayout();
@@ -132,8 +128,5 @@
       // visualizationTabPage
       // 
-      this.visualizationTabPage.Controls.Add(this.redrawButton);
-      this.visualizationTabPage.Controls.Add(this.distancesRadioButton);
-      this.visualizationTabPage.Controls.Add(this.weightsRadioButton);
-      this.visualizationTabPage.Controls.Add(this.pictureBox);
+      this.visualizationTabPage.Controls.Add(this.qapView);
       this.visualizationTabPage.Location = new System.Drawing.Point(4, 22);
       this.visualizationTabPage.Name = "visualizationTabPage";
@@ -143,42 +136,4 @@
       this.visualizationTabPage.Text = "Visualization";
       this.visualizationTabPage.UseVisualStyleBackColor = true;
-      // 
-      // distancesRadioButton
-      // 
-      this.distancesRadioButton.AutoSize = true;
-      this.distancesRadioButton.Checked = true;
-      this.distancesRadioButton.Location = new System.Drawing.Point(6, 6);
-      this.distancesRadioButton.Name = "distancesRadioButton";
-      this.distancesRadioButton.Size = new System.Drawing.Size(72, 17);
-      this.distancesRadioButton.TabIndex = 2;
-      this.distancesRadioButton.TabStop = true;
-      this.distancesRadioButton.Text = "Distances";
-      this.distancesRadioButton.UseVisualStyleBackColor = true;
-      this.distancesRadioButton.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
-      // 
-      // weightsRadioButton
-      // 
-      this.weightsRadioButton.AutoSize = true;
-      this.weightsRadioButton.Location = new System.Drawing.Point(6, 29);
-      this.weightsRadioButton.Name = "weightsRadioButton";
-      this.weightsRadioButton.Size = new System.Drawing.Size(64, 17);
-      this.weightsRadioButton.TabIndex = 1;
-      this.weightsRadioButton.Text = "Weights";
-      this.weightsRadioButton.UseVisualStyleBackColor = true;
-      this.weightsRadioButton.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
-      // 
-      // pictureBox
-      // 
-      this.pictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
-                  | System.Windows.Forms.AnchorStyles.Left)
-                  | System.Windows.Forms.AnchorStyles.Right)));
-      this.pictureBox.BackColor = System.Drawing.Color.White;
-      this.pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
-      this.pictureBox.Location = new System.Drawing.Point(84, 6);
-      this.pictureBox.Name = "pictureBox";
-      this.pictureBox.Size = new System.Drawing.Size(438, 269);
-      this.pictureBox.TabIndex = 0;
-      this.pictureBox.TabStop = false;
-      this.pictureBox.SizeChanged += new System.EventHandler(this.pictureBox_SizeChanged);
       // 
       // valueTabPage
@@ -222,13 +177,16 @@
       this.assignmentViewHost.ViewType = null;
       // 
-      // redrawButton
-      // 
-      this.redrawButton.Location = new System.Drawing.Point(4, 53);
-      this.redrawButton.Name = "redrawButton";
-      this.redrawButton.Size = new System.Drawing.Size(74, 23);
-      this.redrawButton.TabIndex = 3;
-      this.redrawButton.Text = "Redraw";
-      this.redrawButton.UseVisualStyleBackColor = true;
-      this.redrawButton.Click += new System.EventHandler(this.redrawButton_Click);
+      // qapView
+      // 
+      this.qapView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+                  | System.Windows.Forms.AnchorStyles.Left)
+                  | System.Windows.Forms.AnchorStyles.Right)));
+      this.qapView.Assignment = null;
+      this.qapView.Distances = null;
+      this.qapView.Location = new System.Drawing.Point(0, 3);
+      this.qapView.Name = "qapView";
+      this.qapView.Size = new System.Drawing.Size(526, 278);
+      this.qapView.TabIndex = 0;
+      this.qapView.Weights = null;
       // 
       // QAPAssignmentView
@@ -246,6 +204,4 @@
       this.tabControl.ResumeLayout(false);
       this.visualizationTabPage.ResumeLayout(false);
-      this.visualizationTabPage.PerformLayout();
-      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
       this.valueTabPage.ResumeLayout(false);
       this.assignmentGroupBox.ResumeLayout(false);
@@ -261,11 +217,8 @@
     private MainForm.WindowsForms.DragOverTabControl tabControl;
     private System.Windows.Forms.TabPage visualizationTabPage;
-    private System.Windows.Forms.PictureBox pictureBox;
     private System.Windows.Forms.TabPage valueTabPage;
     private System.Windows.Forms.GroupBox assignmentGroupBox;
     private MainForm.WindowsForms.ViewHost assignmentViewHost;
-    private System.Windows.Forms.RadioButton distancesRadioButton;
-    private System.Windows.Forms.RadioButton weightsRadioButton;
-    private System.Windows.Forms.Button redrawButton;
+    private QAPView qapView;
   }
 }
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs	(revision 5647)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs	(revision 5648)
@@ -20,12 +20,7 @@
 #endregion
 
-using System;
 using System.ComponentModel;
-using System.Drawing;
-using System.Globalization;
 using System.Windows.Forms;
 using HeuristicLab.Core.Views;
-using HeuristicLab.Data;
-using HeuristicLab.Encodings.PermutationEncoding;
 using HeuristicLab.MainForm;
 
@@ -37,6 +32,4 @@
   [Content(typeof(QAPAssignment), true)]
   public sealed partial class QAPAssignmentView : ItemView {
-    private Bitmap bitmap;
-
     public new QAPAssignment Content {
       get { return (QAPAssignment)base.Content; }
@@ -64,10 +57,14 @@
       if (Content == null) {
         qualityViewHost.Content = null;
-        pictureBox.Image = null;
         assignmentViewHost.Content = null;
+        qapView.Distances = null;
+        qapView.Weights = null;
+        qapView.Assignment = null;
       } else {
         qualityViewHost.Content = Content.Quality;
-        GenerateImage();
         assignmentViewHost.Content = Content.Assignment;
+        qapView.Distances = Content.Distances;
+        qapView.Weights = Content.Weights;
+        qapView.Assignment = Content.Assignment;
       }
     }
@@ -76,165 +73,6 @@
       base.SetEnabledStateOfControls();
       qualityGroupBox.Enabled = Content != null;
-      pictureBox.Enabled = Content != null;
       assignmentGroupBox.Enabled = Content != null;
-      distancesRadioButton.Enabled = Content != null;
-      weightsRadioButton.Enabled = Content != null;
-      redrawButton.Enabled = Content != null;
-    }
-
-    private void GenerateImage() {
-      if ((pictureBox.Width > 0) && (pictureBox.Height > 0)) {
-        if (Content == null) {
-          pictureBox.Image = null;
-          if (bitmap != null) bitmap.Dispose();
-          bitmap = null;
-        } else {
-          bool drawDistances = distancesRadioButton.Checked;
-          DoubleMatrix coordinates = Content.Coordinates;
-          DoubleMatrix distances = Content.Distances;
-
-          if ((coordinates == null || coordinates.Rows == 0)
-            && (distances == null || distances.Rows == 0)) {
-            Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
-            using (Graphics g = Graphics.FromImage(newBitmap)) {
-              string str = "No coordinates and no distance matrix specified.";
-              SizeF strSize = g.MeasureString(str, Font);
-              g.DrawString(str, Font, Brushes.Black, (float)(newBitmap.Width - strSize.Width) / 2.0f, (float)(newBitmap.Height - strSize.Height) / 2.0f);
-            }
-            pictureBox.Image = newBitmap;
-            if (bitmap != null) bitmap.Dispose();
-            bitmap = newBitmap;
-          } else {
-            if ((coordinates == null || coordinates.Rows == 0)
-              && Content.ViewCoordinates == null) {
-              coordinates = GetCoordinatesByMDS(distances);
-              Content.ViewCoordinates = coordinates;
-            } else if ((coordinates == null || coordinates.Rows == 0)
-              && Content.ViewCoordinates != null) {
-              coordinates = Content.ViewCoordinates;
-            }
-
-            DoubleMatrix weights = Content.Weights;
-            Permutation assignment = Content.Assignment;
-
-            GenerateImage(drawDistances, coordinates, distances, weights, assignment);
-          }
-        }
-      }
-    }
-
-    private void GenerateImage(bool drawDistances, DoubleMatrix coordinates, DoubleMatrix distances, DoubleMatrix weights, Permutation assignment) {
-      Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
-      double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
-      double maxWeight = double.MinValue, maxDistance = double.MinValue;
-      for (int i = 0; i < coordinates.Rows; i++) {
-        if (xMin > coordinates[i, 0]) xMin = coordinates[i, 0];
-        if (yMin > coordinates[i, 1]) yMin = coordinates[i, 1];
-        if (xMax < coordinates[i, 0]) xMax = coordinates[i, 0];
-        if (yMax < coordinates[i, 1]) yMax = coordinates[i, 1];
-
-        for (int j = i + 1; j < coordinates.Rows; j++) {
-          if (weights[i, j] + weights[j, i] > maxWeight)
-            maxWeight = weights[i, j] + weights[j, i];
-
-          if (distances[i, j] > maxDistance)
-            maxDistance = distances[i, j];
-          else if (distances[j, i] > maxDistance)
-            maxDistance = distances[j, i];
-        }
-      }
-
-      int border = 20;
-      double xStep = xMax != xMin ? (pictureBox.Width - 2 * border) / (xMax - xMin) : 1;
-      double yStep = yMax != yMin ? (pictureBox.Height - 2 * border) / (yMax - yMin) : 1;
-
-      Point[] points = new Point[coordinates.Rows];
-      for (int i = 0; i < coordinates.Rows; i++)
-        points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)),
-                              newBitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep))));
-
-      Random rand = new Random();
-      using (Graphics graphics = Graphics.FromImage(newBitmap)) {
-        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
-        graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
-        if ((assignment != null) && (assignment.Length == coordinates.Rows) && (assignment.Validate())) {
-          for (int i = 0; i < assignment.Length - 1; i++) {
-            for (int j = i + 1; j < assignment.Length; j++) {
-              Point start, end;
-              string caption = String.Empty;
-              double d = Math.Max(distances[i, j], distances[j, i]);
-              if (drawDistances) {
-                start = points[i];
-                end = points[j];
-                float width = (float)Math.Ceiling(5.0 * d / maxDistance);
-                graphics.DrawLine(new Pen(Color.IndianRed, width), start, end);
-                if (distances[i, j] != distances[j, i])
-                  caption = distances[i, j].ToString(CultureInfo.InvariantCulture.NumberFormat)
-                    + " / " + distances[j, i].ToString(CultureInfo.InvariantCulture.NumberFormat);
-                else
-                  caption = distances[i, j].ToString(CultureInfo.InvariantCulture.NumberFormat);
-              } else {
-                start = points[assignment[i]];
-                end = points[assignment[j]];
-                double w = weights[i, j] + weights[j, i];
-                if (w > 0) {
-                  float width = (float)Math.Ceiling(5.0 * w / maxWeight);
-                  graphics.DrawLine(new Pen(Color.MediumBlue, width), start, end);
-                  caption = w.ToString(CultureInfo.InvariantCulture.NumberFormat);
-                }
-                if (!String.IsNullOrEmpty(caption)) {
-                  double r = rand.NextDouble();
-                  while (r < 0.2 || r > 0.8) r = rand.NextDouble();
-                  float x = (float)(start.X + (end.X - start.X) * r + 5);
-                  float y = (float)(start.Y + (end.Y - start.Y) * r + 5);
-                  graphics.DrawString(caption, Font, Brushes.Black, x, y);
-                }
-              }
-            }
-          }
-        }
-        for (int i = 0; i < points.Length; i++) {
-          Point p = new Point(points[assignment[i]].X - 3, points[assignment[i]].Y - 3);
-          graphics.FillRectangle(Brushes.Black, p.X, p.Y, 8, 8);
-          graphics.DrawString(i.ToString(), Font, Brushes.Black, p.X, p.Y + 10);
-        }
-      }
-      pictureBox.Image = newBitmap;
-      if (bitmap != null) bitmap.Dispose();
-      bitmap = newBitmap;
-    }
-
-    private DoubleMatrix GetCoordinatesByMDS(DoubleMatrix distances) {
-      /*Random random = new Random();
-      int points = distances.Rows;
-      DoubleMatrix coordinates = new DoubleMatrix(points, 2);
-      double rad = (2 * Math.PI) / coordinates.Rows;
-      for (int i = 0; i < coordinates.Rows; i++) {
-        coordinates[i, 0] = 10 * Math.Cos(rad * i);
-        coordinates[i, 1] = 10 * Math.Sin(rad * i);
-      }
-      for (int iterations = 0; iterations < 1000; iterations++) {
-        for (int i = 0; i < points; i++) {
-          double x = coordinates[i, 0], y = coordinates[i, 1];
-          for (int j = 0; j < points; j++) {
-            if (i != j) {
-              double dx = coordinates[i, 0] - coordinates[j, 0];
-              double dy = coordinates[i, 1] - coordinates[j, 1];
-              double l = Math.Sqrt(dx * dx + dy * dy);
-              double dl = distances[i, j];
-              if (Math.Abs(dx) < double.Epsilon) dx = random.NextDouble() + 1;
-              if (Math.Abs(dy) < double.Epsilon) dy = random.NextDouble() + 1;
-              x += random.NextDouble() * ((coordinates[j, 0] + (dx / l) * dl) - x);
-              y += random.NextDouble() * ((coordinates[j, 1] + (dy / l) * dl) - y);
-            }
-          }
-          coordinates[i, 0] = x;
-          coordinates[i, 1] = y;
-        }
-        Content.ViewCoordinates = coordinates;
-      }
-      return coordinates;*/
-      double error;
-      return MultidimensionalScaling.Classic(distances, out error);
+      qapView.Enabled = Content != null;
     }
 
@@ -245,17 +83,16 @@
         switch (e.PropertyName) {
           case "Coordinates":
+            break;
           case "Distances":
+            qapView.Distances = Content.Distances;
+            break;
           case "Weights":
-            GenerateImage();
-            break;
-          case "Assignment":
-            GenerateImage();
-            assignmentViewHost.Content = Content.Assignment;
+            qapView.Weights = Content.Weights;
             break;
           case "Quality":
             break;
-          case "ViewCoordinates":
-            if (Content.ViewCoordinates != null)
-              GenerateImage(distancesRadioButton.Checked, Content.ViewCoordinates, Content.Distances, Content.Weights, Content.Assignment);
+          case "Assignment":
+            assignmentViewHost.Content = Content.Assignment;
+            qapView.Assignment = Content.Assignment;
             break;
           default:
@@ -264,17 +101,4 @@
       }
     }
-
-    private void pictureBox_SizeChanged(object sender, EventArgs e) {
-      GenerateImage();
-    }
-
-    private void radioButton_CheckedChanged(object sender, EventArgs e) {
-      GenerateImage();
-    }
-
-    private void redrawButton_Click(object sender, EventArgs e) {
-      Content.ViewCoordinates = null;
-      GenerateImage();
-    }
   }
 }
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.Designer.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.Designer.cs	(revision 5647)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.Designer.cs	(revision 5648)
@@ -50,6 +50,7 @@
       this.weightsRadioButton = new System.Windows.Forms.RadioButton();
       this.pictureBox = new System.Windows.Forms.PictureBox();
-      this.errorLabel = new System.Windows.Forms.Label();
+      this.stressLabel = new System.Windows.Forms.Label();
       this.assignmentRadioButton = new System.Windows.Forms.RadioButton();
+      this.label1 = new System.Windows.Forms.Label();
       ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
       this.SuspendLayout();
@@ -101,14 +102,14 @@
       this.pictureBox.TabIndex = 4;
       this.pictureBox.TabStop = false;
+      this.pictureBox.SizeChanged += new System.EventHandler(this.pictureBox_SizeChanged);
       // 
-      // errorLabel
+      // stressLabel
       // 
-      this.errorLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-      this.errorLabel.AutoSize = true;
-      this.errorLabel.Location = new System.Drawing.Point(323, 10);
-      this.errorLabel.Name = "errorLabel";
-      this.errorLabel.Size = new System.Drawing.Size(38, 13);
-      this.errorLabel.TabIndex = 8;
-      this.errorLabel.Text = "Error: -";
+      this.stressLabel.AutoSize = true;
+      this.stressLabel.Location = new System.Drawing.Point(423, 8);
+      this.stressLabel.Name = "stressLabel";
+      this.stressLabel.Size = new System.Drawing.Size(10, 13);
+      this.stressLabel.TabIndex = 8;
+      this.stressLabel.Text = "-";
       // 
       // assignmentRadioButton
@@ -123,9 +124,19 @@
       this.assignmentRadioButton.CheckedChanged += new System.EventHandler(this.Redraw);
       // 
+      // label1
+      // 
+      this.label1.AutoSize = true;
+      this.label1.Location = new System.Drawing.Point(323, 8);
+      this.label1.Name = "label1";
+      this.label1.Size = new System.Drawing.Size(94, 13);
+      this.label1.TabIndex = 8;
+      this.label1.Text = "Normalized Stress:";
+      // 
       // QAPView
       // 
       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-      this.Controls.Add(this.errorLabel);
+      this.Controls.Add(this.label1);
+      this.Controls.Add(this.stressLabel);
       this.Controls.Add(this.redrawButton);
       this.Controls.Add(this.distancesRadioButton);
@@ -147,6 +158,7 @@
     private System.Windows.Forms.RadioButton weightsRadioButton;
     private System.Windows.Forms.PictureBox pictureBox;
-    private System.Windows.Forms.Label errorLabel;
+    private System.Windows.Forms.Label stressLabel;
     private System.Windows.Forms.RadioButton assignmentRadioButton;
+    private System.Windows.Forms.Label label1;
 
   }
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.cs	(revision 5647)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.cs	(revision 5648)
@@ -35,4 +35,5 @@
     private Bitmap defaultBitmap;
 
+    #region Properties
     private DoubleMatrix distances;
     public DoubleMatrix Distances {
@@ -67,5 +68,7 @@
       }
     }
-
+    #endregion
+
+    #region Event Handling
     private void DeregisterDistancesEvents() {
       if (Distances != null) {
@@ -128,12 +131,13 @@
     }
 
+    private void pictureBox_SizeChanged(object sender, EventArgs e) {
+      SetupDefaultBitmap();
+      OnRedraw();
+    }
+    #endregion
+
     public QAPView() {
       InitializeComponent();
       SetupDefaultBitmap();
-      pictureBox.Resize += new EventHandler(pictureBox_Resize);
-    }
-
-    private void pictureBox_Resize(object sender, EventArgs e) {
-      SetupDefaultBitmap();
     }
 
@@ -141,11 +145,14 @@
       if (defaultBitmap != null) defaultBitmap.Dispose();
       defaultBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
-      using (Graphics g = Graphics.FromImage(defaultBitmap)) {
+      WriteCenteredTextToBitmap(ref defaultBitmap, "No visualization available");
+    }
+
+    private void WriteCenteredTextToBitmap(ref Bitmap bitmap, string text) {
+      using (Graphics g = Graphics.FromImage(bitmap)) {
         g.TextRenderingHint = TextRenderingHint.AntiAlias;
         g.SmoothingMode = SmoothingMode.AntiAlias;
 
-        string msg = "No visualization available";
-        SizeF strSize = g.MeasureString(msg, Font);
-        g.DrawString(msg, Font, Brushes.Black, (float)(pictureBox.Width - strSize.Width) / 2.0f, (float)(pictureBox.Height - strSize.Height) / 2.0f);
+        SizeF strSize = g.MeasureString(text, Font);
+        g.DrawString(text, Font, Brushes.Black, (float)(pictureBox.Width - strSize.Width) / 2.0f, (float)(pictureBox.Height - strSize.Height) / 2.0f);
       }
     }
@@ -161,11 +168,17 @@
     private void GenerateImage() {
       Bitmap newBitmap = null;
-      errorLabel.Text = "Error: -";
+      stressLabel.Text = "-";
       if (distancesRadioButton.Checked && Distances != null && Distances.Rows > 0
         && Distances.Rows == Distances.Columns) {
-        newBitmap = GenerateDistanceImage();
+        if (Distances.Rows > 30) {
+          newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
+          WriteCenteredTextToBitmap(ref newBitmap, "Problem dimension too large for visualization.");
+        } else newBitmap = GenerateDistanceImage();
       } else if (weightsRadioButton.Checked && Weights != null && Weights.Rows > 0
         && Weights.Rows == Weights.Columns) {
-        newBitmap = GenerateWeightsImage();
+        if (Weights.Rows > 30) {
+          newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
+          WriteCenteredTextToBitmap(ref newBitmap, "Problem dimension too large for visualization.");
+        } else newBitmap = GenerateWeightsImage();
       } else if (assignmentRadioButton.Checked
         && Assignment != null && Assignment.Length > 0
@@ -175,5 +188,6 @@
         && Distances.Rows == Distances.Columns
         && Assignment.Length == Weights.Rows
-        && Assignment.Length == Distances.Rows) {
+        && Assignment.Length == Distances.Rows
+        && Assignment.Validate()) {
         newBitmap = GenerateAssignmentImage();
       }
@@ -181,14 +195,24 @@
       pictureBox.Image = newBitmap != null ? newBitmap : defaultBitmap;
       if (bitmap != null) bitmap.Dispose();
-      bitmap = newBitmap;
-    }
-
+      if (newBitmap != null) bitmap = newBitmap;
+      else bitmap = null;
+    }
+
+    #region Draw distances
     private Bitmap GenerateDistanceImage() {
       if ((pictureBox.Width > 0) && (pictureBox.Height > 0)) {
         Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
 
-        double error;
-        DoubleMatrix coordinates = MultidimensionalScaling.Metric(distances, out error);
-        errorLabel.Text = "Error: " + error.ToString(CultureInfo.CurrentCulture.NumberFormat);
+        for (int i = 0; i < distances.Rows; i++) {
+          for (int j = i + 1; j < distances.Rows; j++)
+            if (distances[i, j] != distances[j, i]) {
+              WriteCenteredTextToBitmap(ref newBitmap, "Distance matrix is not symmetric");
+              return newBitmap;
+            }
+        }
+
+        double stress;
+        DoubleMatrix coordinates = MultidimensionalScaling.MetricByDistance(distances, out stress);
+        stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat);
         double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
         double maxDistance = double.MinValue;
@@ -214,8 +238,9 @@
                                 newBitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep))));
 
+        Random rand = new Random();
         using (Graphics graphics = Graphics.FromImage(newBitmap)) {
           graphics.SmoothingMode = SmoothingMode.AntiAlias;
           graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
-          graphics.DrawString("Showing Locations spaced out according to their distances", Font, Brushes.Black, 5, 2);
+          graphics.DrawString("Showing locations spaced out according to their distances", Font, Brushes.Black, 5, 2);
 
           for (int i = 0; i < coordinates.Rows - 1; i++) {
@@ -233,4 +258,11 @@
                   caption = distances[i, j].ToString(CultureInfo.InvariantCulture.NumberFormat);
               }
+              if (!String.IsNullOrEmpty(caption)) {
+                double r = rand.NextDouble();
+                while (r < 0.2 || r > 0.8) r = rand.NextDouble();
+                float x = (float)(start.X + (end.X - start.X) * r + 5);
+                float y = (float)(start.Y + (end.Y - start.Y) * r + 5);
+                graphics.DrawString(caption, Font, Brushes.Black, x, y);
+              }
             }
           }
@@ -246,12 +278,107 @@
       return null;
     }
-
+    #endregion
+
+    #region Draw weights
     private Bitmap GenerateWeightsImage() {
       if ((pictureBox.Width > 0) && (pictureBox.Height > 0)) {
         Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
 
-        double error;
-        DoubleMatrix coordinates = MultidimensionalScaling.Classic(weights, out error);
-        errorLabel.Text = "Error: " + error.ToString(CultureInfo.CurrentCulture.NumberFormat);
+        double maxWeight = double.MinValue;
+        for (int i = 0; i < weights.Rows; i++)
+          for (int j = i + 1; j < weights.Rows; j++) {
+            if (weights[i, j] > maxWeight)
+              maxWeight = weights[i, j] + weights[j, i];
+
+            if (weights[i, j] != weights[j, i]) {
+              WriteCenteredTextToBitmap(ref newBitmap, "Weights matrix is not symmetric");
+              return newBitmap;
+            }
+          }
+
+        DoubleMatrix distances = new DoubleMatrix(weights.Rows, weights.Columns);
+        for (int i = 0; i < distances.Rows; i++)
+          for (int j = 0; j < distances.Columns; j++) {
+            distances[i, j] = maxWeight + 1 - weights[i, j];
+          }
+
+        double stress;
+        DoubleMatrix coordinates = MultidimensionalScaling.MetricByDistance(distances, out stress);
+        stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat);
+        double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
+        for (int i = 0; i < coordinates.Rows; i++) {
+          if (xMin > coordinates[i, 0]) xMin = coordinates[i, 0];
+          if (yMin > coordinates[i, 1]) yMin = coordinates[i, 1];
+          if (xMax < coordinates[i, 0]) xMax = coordinates[i, 0];
+          if (yMax < coordinates[i, 1]) yMax = coordinates[i, 1];
+        }
+
+        int border = 20;
+        double xStep = xMax != xMin ? (pictureBox.Width - 2 * border) / (xMax - xMin) : 1;
+        double yStep = yMax != yMin ? (pictureBox.Height - 2 * border) / (yMax - yMin) : 1;
+
+        Point[] points = new Point[coordinates.Rows];
+        for (int i = 0; i < coordinates.Rows; i++)
+          points[i] = new Point(border + ((int)((coordinates[i, 0] - xMin) * xStep)),
+                                newBitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep))));
+
+        Random rand = new Random();
+        using (Graphics graphics = Graphics.FromImage(newBitmap)) {
+          graphics.SmoothingMode = SmoothingMode.AntiAlias;
+          graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
+          graphics.DrawString("Showing facilities spaced out according to their weights", Font, Brushes.Black, 5, 2);
+
+          for (int i = 0; i < coordinates.Rows - 1; i++) {
+            for (int j = i + 1; j < coordinates.Rows; j++) {
+              Point start = points[i], end = points[j];
+              string caption = String.Empty;
+              double d = Math.Max(distances[i, j], distances[j, i]);
+              double w = weights[i, j];
+              if (w > 0) {
+                float width = (float)Math.Ceiling(3.0 * w / maxWeight);
+                graphics.DrawLine(new Pen(Color.MediumBlue, width), start, end);
+                caption = w.ToString(CultureInfo.InvariantCulture.NumberFormat);
+              }
+              if (!String.IsNullOrEmpty(caption)) {
+                double r = rand.NextDouble();
+                while (r < 0.2 || r > 0.8) r = rand.NextDouble();
+                float x = (float)(start.X + (end.X - start.X) * r + 5);
+                float y = (float)(start.Y + (end.Y - start.Y) * r + 5);
+                graphics.DrawString(caption, Font, Brushes.Black, x, y);
+              }
+            }
+          }
+          for (int i = 0; i < points.Length; i++) {
+            Point p = new Point(points[i].X - 3, points[i].Y - 3);
+            graphics.FillRectangle(Brushes.Black, p.X, p.Y, 8, 8);
+            graphics.DrawString(i.ToString(), Font, Brushes.Black, p.X, p.Y + 10);
+          }
+        }
+        return newBitmap;
+      }
+      return null;
+    }
+    #endregion
+
+    #region Draw assignment
+    private Bitmap GenerateAssignmentImage() {
+      if ((pictureBox.Width > 0) && (pictureBox.Height > 0)) {
+        Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
+
+        for (int i = 0; i < distances.Rows; i++) {
+          for (int j = i + 1; j < distances.Rows; j++) {
+            if (distances[i, j] != distances[j, i]) {
+              WriteCenteredTextToBitmap(ref newBitmap, "Distance matrix is not symmetric");
+              return newBitmap;
+            }
+            if (weights[i, j] != weights[j, i]) {
+              WriteCenteredTextToBitmap(ref newBitmap, "Weights matrix is not symmetric");
+            }
+          }
+        }
+
+        double stress;
+        DoubleMatrix coordinates = MultidimensionalScaling.MetricByDistance(distances, out stress);
+        stressLabel.Text = stress.ToString("0.00", CultureInfo.CurrentCulture.NumberFormat);
         double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
         double maxWeight = double.MinValue;
@@ -263,6 +390,5 @@
 
           for (int j = i + 1; j < coordinates.Rows; j++) {
-            if (weights[i, j] + weights[j, i] > maxWeight)
-              maxWeight = weights[i, j] + weights[j, i];
+            if (weights[i, j] > maxWeight) maxWeight = weights[i, j];
           }
         }
@@ -279,16 +405,17 @@
         Random rand = new Random();
         using (Graphics graphics = Graphics.FromImage(newBitmap)) {
-          graphics.SmoothingMode = SmoothingMode.AntiAlias;
-          graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
-          graphics.DrawString("Showing Facilities spaced out according to their weights", Font, Brushes.Black, 5, 2);
-
-          for (int i = 0; i < coordinates.Rows - 1; i++) {
-            for (int j = i + 1; j < coordinates.Rows; j++) {
-              Point start = points[i], end = points[j];
+          graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+          graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
+
+          for (int i = 0; i < assignment.Length - 1; i++) {
+            for (int j = i + 1; j < assignment.Length; j++) {
+              Point start, end;
               string caption = String.Empty;
-              double d = Math.Max(distances[i, j], distances[j, i]);
-              double w = weights[i, j] + weights[j, i];
+              double d = distances[i, j];
+              start = points[assignment[i]];
+              end = points[assignment[j]];
+              double w = weights[i, j];
               if (w > 0) {
-                float width = (float)Math.Ceiling(3.0 * w / maxWeight);
+                float width = (float)Math.Ceiling(4.0 * w / maxWeight);
                 graphics.DrawLine(new Pen(Color.MediumBlue, width), start, end);
                 caption = w.ToString(CultureInfo.InvariantCulture.NumberFormat);
@@ -303,4 +430,5 @@
             }
           }
+
           for (int i = 0; i < points.Length; i++) {
             Point p = new Point(points[i].X - 3, points[i].Y - 3);
@@ -313,8 +441,5 @@
       return null;
     }
-
-    private Bitmap GenerateAssignmentImage() {
-      return null;
-    }
+    #endregion
 
     private void CustomDispose(bool disposing) {
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Parsers/QAPLIBParser.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Parsers/QAPLIBParser.cs	(revision 5647)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Parsers/QAPLIBParser.cs	(revision 5648)
@@ -41,8 +41,9 @@
         Distances = new double[Size, Size];
         Weights = new double[Size, Size];
-        reader.ReadLine();
+        string valLine = reader.ReadLine();
         char[] delim = new char[] { ' ' };
         for (int i = 0; i < Size; i++) {
-          string valLine = reader.ReadLine();
+          if (i > 0 || String.IsNullOrWhiteSpace(valLine))
+            valLine = reader.ReadLine();
           string[] vals = new string[Size];
           string[] partVals = valLine.Split(delim, StringSplitOptions.RemoveEmptyEntries);
@@ -59,9 +60,10 @@
           }
         }
-        reader.ReadLine();
+        valLine = reader.ReadLine();
         int read = 0;
         int k = 0;
         while (!reader.EndOfStream) {
-          string valLine = reader.ReadLine();
+          if (read > 0 || String.IsNullOrWhiteSpace(valLine))
+            valLine = reader.ReadLine();
           string[] vals = valLine.Split(delim, StringSplitOptions.RemoveEmptyEntries);
           for (int j = 0; j < vals.Length; j++) {
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Parsers/QAPLIBSolutionParser.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Parsers/QAPLIBSolutionParser.cs	(revision 5647)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Parsers/QAPLIBSolutionParser.cs	(revision 5648)
@@ -38,5 +38,5 @@
       try {
         StreamReader reader = new StreamReader(stream);
-        char[] delim = new char[] { ' ' };
+        char[] delim = new char[] { ' ', ',' }; // comma is added for nug30.sln which is the only file that separates the permutation with commas
         string[] firstline = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries);
         Size = int.Parse(firstline[0]);
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs	(revision 5647)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs	(revision 5648)
@@ -18,15 +18,4 @@
         coordinates = value;
         if (changed) OnPropertyChanged("Coordinates");
-      }
-    }
-
-    [Storable]
-    private DoubleMatrix viewCoordinates;
-    public DoubleMatrix ViewCoordinates {
-      get { return viewCoordinates; }
-      set {
-        bool changed = (viewCoordinates != value);
-        viewCoordinates = value;
-        if (changed) OnPropertyChanged("ViewCoordinates");
       }
     }
@@ -85,5 +74,4 @@
       assignment = cloner.Clone(original.assignment);
       quality = cloner.Clone(original.quality);
-      viewCoordinates = cloner.Clone(original.viewCoordinates);
     }
     public QAPAssignment(DoubleMatrix weights, Permutation assignment) {
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs	(revision 5647)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs	(revision 5648)
@@ -103,5 +103,5 @@
     public QuadraticAssignmentProblem()
       : base() {
-      Parameters.Add(new ValueParameter<Permutation>("BestKnownSolution", "The best known solution which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null));
+      Parameters.Add(new OptionalValueParameter<Permutation>("BestKnownSolution", "The best known solution which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null));
       Parameters.Add(new ValueParameter<DoubleMatrix>("Coordinates", "The coordinates of the locations. If this is changed the distance matrix is calculated automatically using the euclidean distance."));
       Parameters.Add(new ValueParameter<DoubleMatrix>("Weights", "The strength of the connection between the facilities.", new DoubleMatrix(5, 5)));
@@ -272,13 +272,14 @@
     private void UpdateDistanceMatrix() {
       if (Coordinates != null && Coordinates.Columns == 2 && Coordinates.Rows > 1) {
-        DistanceMatrix = new DoubleMatrix(Coordinates.Rows, Coordinates.Rows);
+        DoubleMatrix distance = new DoubleMatrix(Coordinates.Rows, Coordinates.Rows);
         for (int i = 0; i < Coordinates.Rows - 1; i++) {
           for (int j = i + 1; j < Coordinates.Rows; j++) {
             double dx = Coordinates[i, 0] - Coordinates[j, 0];
             double dy = Coordinates[i, 1] - Coordinates[j, 1];
-            DistanceMatrix[i, j] = Math.Sqrt(dx * dx + dy * dy);
-            DistanceMatrix[j, i] = DistanceMatrix[i, j];
+            distance[i, j] = Math.Sqrt(dx * dx + dy * dy);
+            distance[j, i] = DistanceMatrix[i, j];
           }
         }
+        DistanceMatrix = distance;
       }
     }
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/HeuristicLab.Problems.QuadraticAssignment.Tests-3.3.csproj
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/HeuristicLab.Problems.QuadraticAssignment.Tests-3.3.csproj	(revision 5648)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/HeuristicLab.Problems.QuadraticAssignment.Tests-3.3.csproj	(revision 5648)
@@ -0,0 +1,145 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>
+    </ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{00E73394-D41B-4C4F-963F-A59341FA1791}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>HeuristicLab.Problems.QuadraticAssignment.Tests_33</RootNamespace>
+    <AssemblyName>HeuristicLab.Problems.QuadraticAssignment.Tests-3.3</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisLogFile>bin\Debug\HeuristicLab.Problems.QuadraticAssignment.Tests-3.3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+    <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
+    <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+    <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisLogFile>bin\Release\HeuristicLab.Problems.QuadraticAssignment.Tests-3.3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+    <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
+    <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <CodeAnalysisLogFile>bin\Debug\HeuristicLab.Problems.QuadraticAssignment.Tests-3.3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+    <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
+    <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+    <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <CodeAnalysisLogFile>bin\Release\HeuristicLab.Problems.QuadraticAssignment.Tests-3.3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+    <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="HeuristicLab.Common-3.3">
+      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Core-3.3">
+      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Optimization-3.3">
+      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Optimization-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+    <Reference Include="System" />
+    <Reference Include="System.Core">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <None Include="Properties\AssemblyInfo.frame" />
+    <Compile Include="QAPLIBInstancesTest.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\HeuristicLab.Problems.QuadraticAssignment-3.3.csproj">
+      <Project>{79271BC8-4446-40E2-BB89-9BE4E17174FE}</Project>
+      <Name>HeuristicLab.Problems.QuadraticAssignment-3.3</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+set ProjectDir=$(ProjectDir)
+set SolutionDir=$(SolutionDir)
+set Outdir=$(Outdir)
+
+call PreBuildEvent.cmd
+SubWCRev "%25ProjectDir%25\" "%25ProjectDir%25\Properties\AssemblyInfo.frame" "%25ProjectDir%25\Properties\AssemblyInfo.cs"</PreBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/Properties/AssemblyInfo.frame
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/Properties/AssemblyInfo.frame	(revision 5648)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/Properties/AssemblyInfo.frame	(revision 5648)
@@ -0,0 +1,55 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2011 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.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HeuristicLab.Problems.QuadraticAssignment.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("HEAL")]
+[assembly: AssemblyProduct("HeuristicLab")]
+[assembly: AssemblyCopyright("(c) 2002-2011 HEAL")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("67263025-2123-432c-bd79-69ee125bcaaa")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("3.3.0.0")]
+[assembly: AssemblyFileVersion("3.3.3.$WCREV$")]
Index: branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/QAPLIBInstancesTest.cs
===================================================================
--- branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/QAPLIBInstancesTest.cs	(revision 5648)
+++ branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests/QAPLIBInstancesTest.cs	(revision 5648)
@@ -0,0 +1,23 @@
+﻿using System;
+using System.Text;
+using HeuristicLab.Problems.QuadraticAssignment;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Tests {
+  [TestClass]
+  public class QAPLIBInstancesTest {
+    [TestMethod]
+    public void LoadAllEmbeddedInstances() {
+      QuadraticAssignmentProblem qap = new QuadraticAssignmentProblem();
+      StringBuilder failedInstances = new StringBuilder();
+      foreach (string instance in qap.EmbeddedInstances) {
+        try {
+          qap.LoadEmbeddedInstance(instance);
+        } catch (Exception ex) {
+          failedInstances.AppendLine(instance + ": " + ex.Message);
+        }
+      }
+      Assert.IsTrue(failedInstances.Length == 0, "Following instances failed to load: " + Environment.NewLine + failedInstances.ToString());
+    }
+  }
+}
Index: branches/QAP/QAP.sln
===================================================================
--- branches/QAP/QAP.sln	(revision 5647)
+++ branches/QAP/QAP.sln	(revision 5648)
@@ -6,5 +6,15 @@
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.QuadraticAssignment.Views-3.3", "HeuristicLab.Problems.QuadraticAssignment.Views\3.3\HeuristicLab.Problems.QuadraticAssignment.Views-3.3.csproj", "{997F018D-AEA2-4F21-9301-82FAF6A5612D}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.QuadraticAssignment.Tests-3.3", "HeuristicLab.Problems.QuadraticAssignment\3.3\Tests\HeuristicLab.Problems.QuadraticAssignment.Tests-3.3.csproj", "{00E73394-D41B-4C4F-963F-A59341FA1791}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2179B537-87D1-4AD9-B5FF-75447F08BDBD}"
+	ProjectSection(SolutionItems) = preProject
+		QAP.vsmdi = QAP.vsmdi
+	EndProjectSection
+EndProject
 Global
+	GlobalSection(TestCaseManagementSettings) = postSolution
+		CategoryFile = QAP.vsmdi
+	EndGlobalSection
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -40,4 +50,16 @@
 		{997F018D-AEA2-4F21-9301-82FAF6A5612D}.Release|x86.ActiveCfg = Release|x86
 		{997F018D-AEA2-4F21-9301-82FAF6A5612D}.Release|x86.Build.0 = Release|x86
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Debug|x64.ActiveCfg = Debug|x64
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Debug|x64.Build.0 = Debug|x64
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Debug|x86.ActiveCfg = Debug|x86
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Debug|x86.Build.0 = Debug|x86
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Release|Any CPU.Build.0 = Release|Any CPU
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Release|x64.ActiveCfg = Release|x64
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Release|x64.Build.0 = Release|x64
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Release|x86.ActiveCfg = Release|x86
+		{00E73394-D41B-4C4F-963F-A59341FA1791}.Release|x86.Build.0 = Release|x86
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
Index: branches/QAP/QAP.vsmdi
===================================================================
--- branches/QAP/QAP.vsmdi	(revision 5648)
+++ branches/QAP/QAP.vsmdi	(revision 5648)
@@ -0,0 +1,6 @@
+﻿<?xml version="1.0" encoding="UTF-8"?>
+<TestLists xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
+  <TestList name="Lists of Tests" id="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
+    <RunConfiguration id="61dff98b-e5a1-4d2d-824e-d1f43f5ea4e3" name="Local" storage="local.testsettings" type="Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration, Microsoft.VisualStudio.QualityTools.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  </TestList>
+</TestLists>
