Index: /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/HeuristicLab.Problems.QuadraticAssignment.Views-3.3.csproj
===================================================================
--- /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/HeuristicLab.Problems.QuadraticAssignment.Views-3.3.csproj	(revision 5640)
+++ /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/HeuristicLab.Problems.QuadraticAssignment.Views-3.3.csproj	(revision 5641)
@@ -102,6 +102,9 @@
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="HeuristicLab.Common-3.3">
-      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
+    <Reference Include="ALGLIB-3.1.0, Version=3.1.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86">
+      <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\ALGLIB-3.1.0.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
     </Reference>
     <Reference Include="HeuristicLab.Common.Resources-3.3">
@@ -143,4 +146,5 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="MultidimensionalScaling.cs" />
     <Compile Include="QAPAssignmentView.cs">
       <SubType>UserControl</SubType>
@@ -148,4 +152,10 @@
     <Compile Include="QAPAssignmentView.Designer.cs">
       <DependentUpon>QAPAssignmentView.cs</DependentUpon>
+    </Compile>
+    <Compile Include="QAPView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="QAPView.Designer.cs">
+      <DependentUpon>QAPView.cs</DependentUpon>
     </Compile>
     <Compile Include="QuadraticAssignmentProblemView.cs">
@@ -172,4 +182,7 @@
     <EmbeddedResource Include="QAPAssignmentView.resx">
       <DependentUpon>QAPAssignmentView.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="QAPView.resx">
+      <DependentUpon>QAPView.cs</DependentUpon>
     </EmbeddedResource>
     <EmbeddedResource Include="QuadraticAssignmentProblemView.resx">
Index: /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/MultidimensionalScaling.cs
===================================================================
--- /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/MultidimensionalScaling.cs	(revision 5641)
+++ /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/MultidimensionalScaling.cs	(revision 5641)
@@ -0,0 +1,162 @@
+﻿#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;
+using HeuristicLab.Data;
+
+namespace HeuristicLab.Problems.QuadraticAssignment {
+  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>
+    /// Performs the Kruskal-Shepard algorithm and applies a gradient descent method
+    /// to fit the coordinates such that the difference between the fit distances
+    /// and the actual distances is minimal.
+    /// </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>
+    /// <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) {
+      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] } });
+
+      DoubleMatrix coordinates = new DoubleMatrix(dimension, 2);
+      double rad = (2 * Math.PI) / coordinates.Rows;
+      for (int i = 0; i < dimension; i++) {
+        coordinates[i, 0] = 10 * Math.Cos(rad * i);
+        coordinates[i, 1] = 10 * Math.Sin(rad * i);
+      }
+      double epsg = 0.0000000001;
+      double epsf = 0;
+      double epsx = 0;
+      int maxits = 1000;
+      alglib.mincgstate state = null;
+      alglib.mincgreport rep;
+
+      for (int iterations = 0; iterations < 200; iterations++) {
+        for (int i = 0; i < dimension; i++) {
+          double[] c = new double[] { coordinates[i, 0], coordinates[i, 1] };
+
+          if (iterations == 0 && i == 0) {
+            alglib.mincgcreate(c, out state);
+            alglib.mincgsetcond(state, epsg, epsf, epsx, maxits);
+          } else {
+            alglib.mincgrestartfrom(state, c);
+          }
+          alglib.mincgoptimize(state, func, null, new Info(coordinates, distances, i));
+          alglib.mincgresults(state, out c, out rep);
+
+          coordinates[i, 0] = c[0];
+          coordinates[i, 1] = c[1];
+        }
+      }
+      error = 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]);
+          }
+        }
+      }
+      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];
+        }
+      }
+    }
+
+    private class Info {
+      public DoubleMatrix Coordinates { get; set; }
+      public DoubleMatrix Distances { get; set; }
+      public int Row { get; set; }
+
+      public Info(DoubleMatrix c, DoubleMatrix d, int r) {
+        Coordinates = c;
+        Distances = d;
+        Row = r;
+      }
+    }
+  }
+}
Index: /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.Designer.cs
===================================================================
--- /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.Designer.cs	(revision 5640)
+++ /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.Designer.cs	(revision 5641)
@@ -1,3 +1,24 @@
-﻿namespace HeuristicLab.Problems.QuadraticAssignment.Views {
+﻿#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
+
+namespace HeuristicLab.Problems.QuadraticAssignment.Views {
   partial class QAPAssignmentView {
     /// <summary> 
@@ -29,10 +50,11 @@
       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.weightsRadioButton = new System.Windows.Forms.RadioButton();
-      this.distancesRadioButton = new System.Windows.Forms.RadioButton();
+      this.redrawButton = new System.Windows.Forms.Button();
       ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
       this.splitContainer.Panel1.SuspendLayout();
@@ -110,4 +132,5 @@
       // visualizationTabPage
       // 
+      this.visualizationTabPage.Controls.Add(this.redrawButton);
       this.visualizationTabPage.Controls.Add(this.distancesRadioButton);
       this.visualizationTabPage.Controls.Add(this.weightsRadioButton);
@@ -121,4 +144,28 @@
       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
       // 
@@ -175,27 +222,13 @@
       this.assignmentViewHost.ViewType = null;
       // 
-      // 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);
-      // 
-      // 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);
+      // 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);
       // 
       // QAPAssignmentView
@@ -234,4 +267,5 @@
     private System.Windows.Forms.RadioButton distancesRadioButton;
     private System.Windows.Forms.RadioButton weightsRadioButton;
+    private System.Windows.Forms.Button redrawButton;
   }
 }
Index: /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs
===================================================================
--- /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs	(revision 5640)
+++ /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs	(revision 5641)
@@ -78,4 +78,7 @@
       pictureBox.Enabled = Content != null;
       assignmentGroupBox.Enabled = Content != null;
+      distancesRadioButton.Enabled = Content != null;
+      weightsRadioButton.Enabled = Content != null;
+      redrawButton.Enabled = Content != null;
     }
 
@@ -87,5 +90,4 @@
           bitmap = null;
         } else {
-          Bitmap newBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
           bool drawDistances = distancesRadioButton.Checked;
           DoubleMatrix coordinates = Content.Coordinates;
@@ -94,4 +96,5 @@
           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.";
@@ -99,13 +102,11 @@
               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 = new DoubleMatrix(distances.Rows, 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);
-              }
+              coordinates = GetCoordinatesByMDS(distances);
               Content.ViewCoordinates = coordinates;
             } else if ((coordinates == null || coordinates.Rows == 0)
@@ -117,80 +118,123 @@
             Permutation assignment = Content.Assignment;
 
-            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 = points[assignment[i]], end = points[assignment[j]];
-                    string caption = String.Empty;
-                    double d = Math.Max(distances[i, j], distances[j, i]);
-                    if (drawDistances) {
-                      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 {
-                      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);
-                      }
-                    }
-                  }
+            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;
-        }
-      }
+        }
+        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);
     }
 
@@ -211,4 +255,8 @@
           case "Quality":
             break;
+          case "ViewCoordinates":
+            if (Content.ViewCoordinates != null)
+              GenerateImage(distancesRadioButton.Checked, Content.ViewCoordinates, Content.Distances, Content.Weights, Content.Assignment);
+            break;
           default:
             break;
@@ -224,4 +272,9 @@
       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 5641)
+++ /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.Designer.cs	(revision 5641)
@@ -0,0 +1,153 @@
+﻿#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
+
+namespace HeuristicLab.Problems.QuadraticAssignment.Views {
+  partial class QAPView {
+    /// <summary> 
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary> 
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      CustomDispose(disposing);
+      if (disposing && (components != null)) {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Component Designer generated code
+
+    /// <summary> 
+    /// Required method for Designer support - do not modify 
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.redrawButton = new System.Windows.Forms.Button();
+      this.distancesRadioButton = new System.Windows.Forms.RadioButton();
+      this.weightsRadioButton = new System.Windows.Forms.RadioButton();
+      this.pictureBox = new System.Windows.Forms.PictureBox();
+      this.errorLabel = new System.Windows.Forms.Label();
+      this.assignmentRadioButton = new System.Windows.Forms.RadioButton();
+      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
+      this.SuspendLayout();
+      // 
+      // redrawButton
+      // 
+      this.redrawButton.Location = new System.Drawing.Point(243, 3);
+      this.redrawButton.Name = "redrawButton";
+      this.redrawButton.Size = new System.Drawing.Size(74, 23);
+      this.redrawButton.TabIndex = 7;
+      this.redrawButton.Text = "Redraw";
+      this.redrawButton.UseVisualStyleBackColor = true;
+      this.redrawButton.Click += new System.EventHandler(this.Redraw);
+      // 
+      // distancesRadioButton
+      // 
+      this.distancesRadioButton.AutoSize = true;
+      this.distancesRadioButton.Checked = true;
+      this.distancesRadioButton.Location = new System.Drawing.Point(3, 6);
+      this.distancesRadioButton.Name = "distancesRadioButton";
+      this.distancesRadioButton.Size = new System.Drawing.Size(72, 17);
+      this.distancesRadioButton.TabIndex = 6;
+      this.distancesRadioButton.TabStop = true;
+      this.distancesRadioButton.Text = "Distances";
+      this.distancesRadioButton.UseVisualStyleBackColor = true;
+      this.distancesRadioButton.CheckedChanged += new System.EventHandler(this.Redraw);
+      // 
+      // weightsRadioButton
+      // 
+      this.weightsRadioButton.AutoSize = true;
+      this.weightsRadioButton.Location = new System.Drawing.Point(81, 6);
+      this.weightsRadioButton.Name = "weightsRadioButton";
+      this.weightsRadioButton.Size = new System.Drawing.Size(64, 17);
+      this.weightsRadioButton.TabIndex = 5;
+      this.weightsRadioButton.Text = "Weights";
+      this.weightsRadioButton.UseVisualStyleBackColor = true;
+      this.weightsRadioButton.CheckedChanged += new System.EventHandler(this.Redraw);
+      // 
+      // 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(0, 32);
+      this.pictureBox.Name = "pictureBox";
+      this.pictureBox.Size = new System.Drawing.Size(574, 422);
+      this.pictureBox.TabIndex = 4;
+      this.pictureBox.TabStop = false;
+      // 
+      // errorLabel
+      // 
+      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: -";
+      // 
+      // assignmentRadioButton
+      // 
+      this.assignmentRadioButton.AutoSize = true;
+      this.assignmentRadioButton.Location = new System.Drawing.Point(151, 6);
+      this.assignmentRadioButton.Name = "assignmentRadioButton";
+      this.assignmentRadioButton.Size = new System.Drawing.Size(79, 17);
+      this.assignmentRadioButton.TabIndex = 5;
+      this.assignmentRadioButton.Text = "Assignment";
+      this.assignmentRadioButton.UseVisualStyleBackColor = true;
+      this.assignmentRadioButton.CheckedChanged += new System.EventHandler(this.Redraw);
+      // 
+      // 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.redrawButton);
+      this.Controls.Add(this.distancesRadioButton);
+      this.Controls.Add(this.assignmentRadioButton);
+      this.Controls.Add(this.weightsRadioButton);
+      this.Controls.Add(this.pictureBox);
+      this.Name = "QAPView";
+      this.Size = new System.Drawing.Size(574, 454);
+      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+      this.ResumeLayout(false);
+      this.PerformLayout();
+
+    }
+
+    #endregion
+
+    private System.Windows.Forms.Button redrawButton;
+    private System.Windows.Forms.RadioButton distancesRadioButton;
+    private System.Windows.Forms.RadioButton weightsRadioButton;
+    private System.Windows.Forms.PictureBox pictureBox;
+    private System.Windows.Forms.Label errorLabel;
+    private System.Windows.Forms.RadioButton assignmentRadioButton;
+
+  }
+}
Index: /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.cs
===================================================================
--- /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.cs	(revision 5641)
+++ /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.cs	(revision 5641)
@@ -0,0 +1,330 @@
+﻿#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;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+using System.Globalization;
+using System.Windows.Forms;
+using HeuristicLab.Common;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.PermutationEncoding;
+
+namespace HeuristicLab.Problems.QuadraticAssignment.Views {
+  public partial class QAPView : UserControl {
+    private Bitmap bitmap;
+    private Bitmap defaultBitmap;
+
+    private DoubleMatrix distances;
+    public DoubleMatrix Distances {
+      get { return distances; }
+      set {
+        DeregisterDistancesEvents();
+        distances = value;
+        RegisterDistancesEvents();
+        OnRedraw();
+      }
+    }
+
+    private DoubleMatrix weights;
+    public DoubleMatrix Weights {
+      get { return weights; }
+      set {
+        DeregisterWeightsEvents();
+        weights = value;
+        RegisterWeightsEvents();
+        OnRedraw();
+      }
+    }
+
+    private Permutation assignment;
+    public Permutation Assignment {
+      get { return assignment; }
+      set {
+        DeregisterAssignmentEvents();
+        assignment = value;
+        RegisterAssignmentEvents();
+        OnRedraw();
+      }
+    }
+
+    private void DeregisterDistancesEvents() {
+      if (Distances != null) {
+        Distances.Reset -= new EventHandler(Redraw);
+        Distances.RowsChanged -= new EventHandler(Redraw);
+        Distances.ColumnsChanged -= new EventHandler(Redraw);
+        Distances.ItemChanged -= new EventHandler<EventArgs<int, int>>(Redraw);
+      }
+    }
+
+    private void RegisterDistancesEvents() {
+      if (Distances != null) {
+        Distances.Reset += new EventHandler(Redraw);
+        Distances.RowsChanged += new EventHandler(Redraw);
+        Distances.ColumnsChanged += new EventHandler(Redraw);
+        Distances.ItemChanged += new EventHandler<EventArgs<int, int>>(Redraw);
+      }
+    }
+
+    private void DeregisterWeightsEvents() {
+      if (Weights != null) {
+        Weights.Reset -= new EventHandler(Redraw);
+        Weights.RowsChanged -= new EventHandler(Redraw);
+        Weights.ColumnsChanged -= new EventHandler(Redraw);
+        Weights.ItemChanged -= new EventHandler<EventArgs<int, int>>(Redraw);
+      }
+    }
+
+    private void RegisterWeightsEvents() {
+      if (Weights != null) {
+        Weights.Reset += new EventHandler(Redraw);
+        Weights.RowsChanged += new EventHandler(Redraw);
+        Weights.ColumnsChanged += new EventHandler(Redraw);
+        Weights.ItemChanged += new EventHandler<EventArgs<int, int>>(Redraw);
+      }
+    }
+
+    private void DeregisterAssignmentEvents() {
+      if (Assignment != null) {
+        Assignment.Reset -= new EventHandler(Redraw);
+        Assignment.ItemChanged -= new EventHandler<EventArgs<int>>(Redraw);
+      }
+    }
+
+    private void RegisterAssignmentEvents() {
+      if (Assignment != null) {
+        Assignment.Reset += new EventHandler(Redraw);
+        Assignment.ItemChanged += new EventHandler<EventArgs<int>>(Redraw);
+      }
+    }
+
+    private void Redraw(object sender, EventArgs e) {
+      if (sender is RadioButton && !((RadioButton)sender).Checked)
+        return;
+      OnRedraw();
+    }
+
+    private void Redraw(object sender, EventArgs<int, int> e) {
+      OnRedraw();
+    }
+
+    public QAPView() {
+      InitializeComponent();
+      SetupDefaultBitmap();
+      pictureBox.Resize += new EventHandler(pictureBox_Resize);
+    }
+
+    private void pictureBox_Resize(object sender, EventArgs e) {
+      SetupDefaultBitmap();
+    }
+
+    private void SetupDefaultBitmap() {
+      if (defaultBitmap != null) defaultBitmap.Dispose();
+      defaultBitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
+      using (Graphics g = Graphics.FromImage(defaultBitmap)) {
+        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);
+      }
+    }
+
+    private void OnRedraw() {
+      if (InvokeRequired) {
+        Invoke((Action)OnRedraw, null);
+      } else {
+        GenerateImage();
+      }
+    }
+
+    private void GenerateImage() {
+      Bitmap newBitmap = null;
+      errorLabel.Text = "Error: -";
+      if (distancesRadioButton.Checked && Distances != null && Distances.Rows > 0
+        && Distances.Rows == Distances.Columns) {
+        newBitmap = GenerateDistanceImage();
+      } else if (weightsRadioButton.Checked && Weights != null && Weights.Rows > 0
+        && Weights.Rows == Weights.Columns) {
+        newBitmap = GenerateWeightsImage();
+      } else if (assignmentRadioButton.Checked
+        && Assignment != null && Assignment.Length > 0
+        && Weights != null && Weights.Rows > 0
+        && Distances != null && Distances.Rows > 0
+        && Weights.Rows == Weights.Columns
+        && Distances.Rows == Distances.Columns
+        && Assignment.Length == Weights.Rows
+        && Assignment.Length == Distances.Rows) {
+        newBitmap = GenerateAssignmentImage();
+      }
+
+      pictureBox.Image = newBitmap != null ? newBitmap : defaultBitmap;
+      if (bitmap != null) bitmap.Dispose();
+      bitmap = newBitmap;
+    }
+
+    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);
+        double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
+        double 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 (distances[i, j] > maxDistance) maxDistance = distances[i, j];
+            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))));
+
+        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);
+
+          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]);
+              float width = (float)Math.Ceiling(5.0 * d / maxDistance);
+              if (d > 0) {
+                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);
+              }
+            }
+          }
+
+          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;
+    }
+
+    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 xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
+        double maxWeight = 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];
+          }
+        }
+
+        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] + weights[j, i];
+              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;
+    }
+
+    private Bitmap GenerateAssignmentImage() {
+      return null;
+    }
+
+    private void CustomDispose(bool disposing) {
+      DeregisterDistancesEvents();
+      DeregisterWeightsEvents();
+      DeregisterAssignmentEvents();
+      if (bitmap != null) bitmap.Dispose();
+      bitmap = null;
+      defaultBitmap.Dispose();
+      defaultBitmap = null;
+    }
+  }
+}
Index: /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.resx
===================================================================
--- /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.resx	(revision 5641)
+++ /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPView.resx	(revision 5641)
@@ -0,0 +1,120 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>
Index: /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.Designer.cs
===================================================================
--- /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.Designer.cs	(revision 5640)
+++ /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.Designer.cs	(revision 5641)
@@ -50,11 +50,17 @@
       this.instancesComboBox = new System.Windows.Forms.ComboBox();
       this.loadInstanceButton = new System.Windows.Forms.Button();
+      this.tabControl = new System.Windows.Forms.TabControl();
+      this.problemTabPage = new System.Windows.Forms.TabPage();
+      this.visualizationTabPage = new System.Windows.Forms.TabPage();
+      this.qapView = new HeuristicLab.Problems.QuadraticAssignment.Views.QAPView();
       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+      this.tabControl.SuspendLayout();
+      this.visualizationTabPage.SuspendLayout();
       this.SuspendLayout();
       // 
       // parameterCollectionView
       // 
-      this.parameterCollectionView.Location = new System.Drawing.Point(0, 81);
-      this.parameterCollectionView.Size = new System.Drawing.Size(490, 272);
+      this.parameterCollectionView.Location = new System.Drawing.Point(8, 107);
+      this.parameterCollectionView.Size = new System.Drawing.Size(629, 375);
       // 
       // nameTextBox
@@ -63,5 +69,5 @@
       this.errorProvider.SetIconPadding(this.nameTextBox, 2);
       this.nameTextBox.Location = new System.Drawing.Point(86, 29);
-      this.nameTextBox.Size = new System.Drawing.Size(404, 20);
+      this.nameTextBox.Size = new System.Drawing.Size(561, 20);
       // 
       // nameLabel
@@ -76,10 +82,10 @@
       // 
       this.descriptionTextBox.Location = new System.Drawing.Point(86, 55);
-      this.descriptionTextBox.Size = new System.Drawing.Size(404, 20);
+      this.descriptionTextBox.Size = new System.Drawing.Size(561, 20);
       // 
       // importInstanceButton
       // 
       this.importInstanceButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-      this.importInstanceButton.Location = new System.Drawing.Point(391, 0);
+      this.importInstanceButton.Location = new System.Drawing.Point(548, 0);
       this.importInstanceButton.Name = "importInstanceButton";
       this.importInstanceButton.Size = new System.Drawing.Size(99, 23);
@@ -117,5 +123,5 @@
       this.instancesComboBox.Location = new System.Drawing.Point(105, 2);
       this.instancesComboBox.Name = "instancesComboBox";
-      this.instancesComboBox.Size = new System.Drawing.Size(201, 21);
+      this.instancesComboBox.Size = new System.Drawing.Size(358, 21);
       this.instancesComboBox.TabIndex = 7;
       this.instancesComboBox.SelectedValueChanged += new System.EventHandler(this.instancesComboBox_SelectedValueChanged);
@@ -124,5 +130,5 @@
       // 
       this.loadInstanceButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-      this.loadInstanceButton.Location = new System.Drawing.Point(312, 0);
+      this.loadInstanceButton.Location = new System.Drawing.Point(469, 0);
       this.loadInstanceButton.Name = "loadInstanceButton";
       this.loadInstanceButton.Size = new System.Drawing.Size(73, 23);
@@ -134,4 +140,49 @@
       this.loadInstanceButton.Click += new System.EventHandler(this.loadInstanceButton_Click);
       // 
+      // tabControl
+      // 
+      this.tabControl.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.tabControl.Controls.Add(this.problemTabPage);
+      this.tabControl.Controls.Add(this.visualizationTabPage);
+      this.tabControl.Location = new System.Drawing.Point(0, 81);
+      this.tabControl.Name = "tabControl";
+      this.tabControl.SelectedIndex = 0;
+      this.tabControl.Size = new System.Drawing.Size(647, 411);
+      this.tabControl.TabIndex = 8;
+      // 
+      // problemTabPage
+      // 
+      this.problemTabPage.Location = new System.Drawing.Point(4, 22);
+      this.problemTabPage.Name = "problemTabPage";
+      this.problemTabPage.Padding = new System.Windows.Forms.Padding(3);
+      this.problemTabPage.Size = new System.Drawing.Size(639, 385);
+      this.problemTabPage.TabIndex = 0;
+      this.problemTabPage.Text = "Problem";
+      this.problemTabPage.UseVisualStyleBackColor = true;
+      // 
+      // visualizationTabPage
+      // 
+      this.visualizationTabPage.Controls.Add(this.qapView);
+      this.visualizationTabPage.Location = new System.Drawing.Point(4, 22);
+      this.visualizationTabPage.Name = "visualizationTabPage";
+      this.visualizationTabPage.Padding = new System.Windows.Forms.Padding(3);
+      this.visualizationTabPage.Size = new System.Drawing.Size(639, 385);
+      this.visualizationTabPage.TabIndex = 1;
+      this.visualizationTabPage.Text = "Visualization";
+      this.visualizationTabPage.UseVisualStyleBackColor = true;
+      // 
+      // qapView
+      // 
+      this.qapView.Assignment = null;
+      this.qapView.Distances = null;
+      this.qapView.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.qapView.Location = new System.Drawing.Point(3, 3);
+      this.qapView.Name = "qapView";
+      this.qapView.Size = new System.Drawing.Size(633, 379);
+      this.qapView.TabIndex = 0;
+      this.qapView.Weights = null;
+      // 
       // QuadraticAssignmentProblemView
       // 
@@ -139,8 +190,11 @@
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
       this.Controls.Add(this.instancesComboBox);
+      this.Controls.Add(this.tabControl);
       this.Controls.Add(this.importInstanceButton);
       this.Controls.Add(this.loadInstanceButton);
       this.Controls.Add(this.QAPLIBInstancesLabel);
       this.Name = "QuadraticAssignmentProblemView";
+      this.Size = new System.Drawing.Size(647, 492);
+      this.Controls.SetChildIndex(this.parameterCollectionView, 0);
       this.Controls.SetChildIndex(this.descriptionLabel, 0);
       this.Controls.SetChildIndex(this.nameLabel, 0);
@@ -150,7 +204,9 @@
       this.Controls.SetChildIndex(this.loadInstanceButton, 0);
       this.Controls.SetChildIndex(this.importInstanceButton, 0);
+      this.Controls.SetChildIndex(this.tabControl, 0);
       this.Controls.SetChildIndex(this.instancesComboBox, 0);
-      this.Controls.SetChildIndex(this.parameterCollectionView, 0);
       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
+      this.tabControl.ResumeLayout(false);
+      this.visualizationTabPage.ResumeLayout(false);
       this.ResumeLayout(false);
       this.PerformLayout();
@@ -165,4 +221,8 @@
     private System.Windows.Forms.ComboBox instancesComboBox;
     private System.Windows.Forms.Button loadInstanceButton;
+    private System.Windows.Forms.TabControl tabControl;
+    private System.Windows.Forms.TabPage problemTabPage;
+    private System.Windows.Forms.TabPage visualizationTabPage;
+    private QAPView qapView;
   }
 }
Index: /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.cs
===================================================================
--- /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.cs	(revision 5640)
+++ /branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.cs	(revision 5641)
@@ -20,4 +20,5 @@
 #endregion
 
+using System;
 using System.Windows.Forms;
 using HeuristicLab.Common.Resources;
@@ -38,4 +39,33 @@
       InitializeComponent();
       importInstanceButton.Image = VSImageLibrary.Open;
+      Controls.Remove(parameterCollectionView);
+      parameterCollectionView.Dock = DockStyle.Fill;
+      problemTabPage.Controls.Add(parameterCollectionView);
+    }
+
+    protected override void RegisterContentEvents() {
+      base.RegisterContentEvents();
+      Content.DistanceMatrixParameter.ValueChanged += new EventHandler(DistanceMatrixParameter_ValueChanged);
+      Content.WeightsParameter.ValueChanged += new EventHandler(WeightsParameter_ValueChanged);
+      Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged);
+    }
+
+    protected override void DeregisterContentEvents() {
+      Content.DistanceMatrixParameter.ValueChanged -= new EventHandler(DistanceMatrixParameter_ValueChanged);
+      Content.WeightsParameter.ValueChanged -= new EventHandler(WeightsParameter_ValueChanged);
+      Content.BestKnownSolutionParameter.ValueChanged -= new EventHandler(BestKnownSolutionParameter_ValueChanged);
+      base.DeregisterContentEvents();
+    }
+
+    private void DistanceMatrixParameter_ValueChanged(object sender, System.EventArgs e) {
+      qapView.Distances = Content.DistanceMatrix;
+    }
+
+    private void WeightsParameter_ValueChanged(object sender, System.EventArgs e) {
+      qapView.Weights = Content.Weights;
+    }
+
+    private void BestKnownSolutionParameter_ValueChanged(object sender, System.EventArgs e) {
+      qapView.Assignment = Content.BestKnownSolution;
     }
 
@@ -47,4 +77,11 @@
           instancesComboBox.Items.Add(instance);
         }
+        qapView.Distances = Content.DistanceMatrix;
+        qapView.Weights = Content.Weights;
+        qapView.Assignment = Content.BestKnownSolution;
+      } else {
+        qapView.Distances = null;
+        qapView.Weights = null;
+        qapView.Assignment = null;
       }
     }
@@ -63,10 +100,18 @@
     private void loadInstanceButton_Click(object sender, System.EventArgs e) {
       string instance = instancesComboBox.SelectedItem as string;
-      Content.LoadEmbeddedInstance(instance);
+      try {
+        Content.LoadEmbeddedInstance(instance);
+      } catch (Exception ex) {
+        PluginInfrastructure.ErrorHandling.ShowErrorDialog(ex);
+      }
     }
 
     private void importInstanceButton_Click(object sender, System.EventArgs e) {
       if (openFileDialog.ShowDialog() == DialogResult.OK) {
-        Content.ImportFileInstance(openFileDialog.FileName);
+        try {
+          Content.ImportFileInstance(openFileDialog.FileName);
+        } catch (Exception ex) {
+          PluginInfrastructure.ErrorHandling.ShowErrorDialog(ex);
+        }
       }
     }
Index: /branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs
===================================================================
--- /branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs	(revision 5640)
+++ /branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPAssignment.cs	(revision 5641)
@@ -21,5 +21,14 @@
     }
 
-    public DoubleMatrix ViewCoordinates { get; set; }
+    [Storable]
+    private DoubleMatrix viewCoordinates;
+    public DoubleMatrix ViewCoordinates {
+      get { return viewCoordinates; }
+      set {
+        bool changed = (viewCoordinates != value);
+        viewCoordinates = value;
+        if (changed) OnPropertyChanged("ViewCoordinates");
+      }
+    }
 
     [Storable]
@@ -76,4 +85,5 @@
       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 5640)
+++ /branches/QAP/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs	(revision 5641)
@@ -47,15 +47,15 @@
 
     #region Parameter Properties
-    public ValueParameter<Permutation> BestKnownSolutionParameter {
-      get { return (ValueParameter<Permutation>)Parameters["BestKnownSolution"]; }
-    }
-    public ValueParameter<DoubleMatrix> CoordinatesParameter {
-      get { return (ValueParameter<DoubleMatrix>)Parameters["Coordinates"]; }
-    }
-    public ValueParameter<DoubleMatrix> WeightsParameter {
-      get { return (ValueParameter<DoubleMatrix>)Parameters["Weights"]; }
-    }
-    public ValueParameter<DoubleMatrix> DistanceMatrixParameter {
-      get { return (ValueParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
+    public IValueParameter<Permutation> BestKnownSolutionParameter {
+      get { return (IValueParameter<Permutation>)Parameters["BestKnownSolution"]; }
+    }
+    public IValueParameter<DoubleMatrix> CoordinatesParameter {
+      get { return (IValueParameter<DoubleMatrix>)Parameters["Coordinates"]; }
+    }
+    public IValueParameter<DoubleMatrix> WeightsParameter {
+      get { return (IValueParameter<DoubleMatrix>)Parameters["Weights"]; }
+    }
+    public IValueParameter<DoubleMatrix> DistanceMatrixParameter {
+      get { return (IValueParameter<DoubleMatrix>)Parameters["DistanceMatrix"]; }
     }
     #endregion
@@ -288,4 +288,5 @@
       QAPLIBParser parser = new QAPLIBParser();
       parser.Parse(filename);
+      if (parser.Error != null) throw parser.Error;
       Coordinates = new DoubleMatrix();
       DistanceMatrix = new DoubleMatrix(parser.Distances);
@@ -303,4 +304,5 @@
         QAPLIBParser parser = new QAPLIBParser();
         parser.Parse(stream);
+        if (parser.Error != null) throw parser.Error;
         Coordinates = new DoubleMatrix();
         DistanceMatrix = new DoubleMatrix(parser.Distances);
@@ -319,4 +321,5 @@
           QAPLIBSolutionParser solParser = new QAPLIBSolutionParser();
           solParser.Parse(solStream);
+          if (solParser.Error != null) throw solParser.Error;
           BestKnownQuality = new DoubleValue(solParser.Qualiy);
           BestKnownSolution = new Permutation(PermutationTypes.Absolute, solParser.Assignment);
