Index: branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPAlleleFrequencyAnalyzer.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPAlleleFrequencyAnalyzer.cs	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPAlleleFrequencyAnalyzer.cs	(revision 6416)
@@ -20,4 +20,5 @@
 #endregion
 
+using System.Collections.Generic;
 using HeuristicLab.Analysis;
 using HeuristicLab.Common;
@@ -56,17 +57,19 @@
 
     protected override Allele[] CalculateAlleles(Permutation solution) {
-      Allele[] alleles = new Allele[solution.Length];
+      Allele[] alleles = new Allele[solution.Length * solution.Length];
+      Dictionary<string, int> allelesDict = new Dictionary<string, int>();
       DoubleMatrix weights = WeightsParameter.ActualValue;
       DoubleMatrix distances = DistancesParameter.ActualValue;
-      int source, target;
       double impact;
 
-      for (int i = 0; i < solution.Length; i++) {
-        source = i;
-        target = solution[i];
-        impact = 0;
-        for (int j = 0; j < solution.Length; j++)
-          impact += weights[source, j] * distances[target, solution[j]];
-        alleles[i] = new Allele(source.ToString() + "->" + target.ToString(), impact);
+      for (int x = 0; x < solution.Length; x++) {
+        for (int y = 0; y < solution.Length; y++) {
+          string allele = weights[x, y].ToString() + ">" + distances[solution[x], solution[y]].ToString();
+          int repetition = 1;
+          if (allelesDict.ContainsKey(allele)) repetition += allelesDict[allele];
+          allelesDict[allele] = repetition;
+          impact = weights[x, y] * distances[solution[x], solution[y]];
+          alleles[x * solution.Length + y] = new Allele(allele + "/" + repetition, impact);
+        }
       }
 
Index: branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPPopulationDiversityAnalyzer.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPPopulationDiversityAnalyzer.cs	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPPopulationDiversityAnalyzer.cs	(revision 6416)
@@ -23,5 +23,7 @@
 using HeuristicLab.Common;
 using HeuristicLab.Core;
+using HeuristicLab.Data;
 using HeuristicLab.Encodings.PermutationEncoding;
+using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 
@@ -33,8 +35,23 @@
   [StorableClass]
   public sealed class QAPPopulationDiversityAnalyzer : PopulationDiversityAnalyzer<Permutation> {
+    public IValueParameter<BoolValue> UsePhenotypeSimilarityParameter {
+      get { return (IValueParameter<BoolValue>)Parameters["UsePhenotypeSimilarity"]; }
+    }
+    public ILookupParameter<DoubleMatrix> WeightsParameter {
+      get { return (ILookupParameter<DoubleMatrix>)Parameters["Weights"]; }
+    }
+    public ILookupParameter<DoubleMatrix> DistancesParameter {
+      get { return (ILookupParameter<DoubleMatrix>)Parameters["Distances"]; }
+    }
+
     [StorableConstructor]
     private QAPPopulationDiversityAnalyzer(bool deserializing) : base(deserializing) { }
     private QAPPopulationDiversityAnalyzer(QAPPopulationDiversityAnalyzer original, Cloner cloner) : base(original, cloner) { }
-    public QAPPopulationDiversityAnalyzer() : base() { }
+    public QAPPopulationDiversityAnalyzer()
+      : base() {
+      Parameters.Add(new ValueParameter<BoolValue>("UsePhenotypeSimilarity", "True if the similarity should be measured a level closer to the phenotype (the number of similar assignments of individual weights to distances). Set to false if the number of equal assignments (facility to location) should be counted.", new BoolValue(false)));
+      Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", "The weights matrix."));
+      Parameters.Add(new LookupParameter<DoubleMatrix>("Distances", "The distances matrix."));
+    }
 
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -42,5 +59,20 @@
     }
 
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      // BackwardsCompatibility3.3
+      #region Backwards compatible code, remove with 3.4
+      if (!Parameters.ContainsKey("UsePhenotypeSimilarity"))
+        Parameters.Add(new ValueParameter<BoolValue>("UsePhenotypeSimilarity", "True if the similarity should be measured a level closer to the phenotype (the number of similar assignments of individual weights to distances). Set to false if the number of equal assignments (facility to location) should be counted.", new BoolValue(false)));
+      if (!Parameters.ContainsKey("Weights"))
+        Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", "The weights matrix."));
+      if (!Parameters.ContainsKey("Distances"))
+        Parameters.Add(new LookupParameter<DoubleMatrix>("Distances", "The distances matrix."));
+      #endregion
+    }
+
     protected override double[,] CalculateSimilarities(Permutation[] solutions) {
+      DoubleMatrix weights = WeightsParameter.ActualValue, distances = DistancesParameter.ActualValue;
+      bool phenotypeSimilarity = UsePhenotypeSimilarityParameter.Value.Value;
       int count = solutions.Length;
       double[,] similarities = new double[count, count];
@@ -49,5 +81,7 @@
         similarities[i, i] = 1;
         for (int j = i + 1; j < count; j++) {
-          similarities[i, j] = CalculateSimilarity(solutions[i], solutions[j]);
+          if (phenotypeSimilarity)
+            similarities[i, j] = QAPPermutationProximityCalculator.CalculatePhenotypeSimilarity(solutions[i], solutions[j], weights, distances);
+          else similarities[i, j] = QAPPermutationProximityCalculator.CalculateGenotypeSimilarity(solutions[i], solutions[j]);
           similarities[j, i] = similarities[i, j];
         }
@@ -55,13 +89,4 @@
       return similarities;
     }
-
-    private double CalculateSimilarity(Permutation assignment1, Permutation assignment2) {
-      int identicalAssignments = 0;
-      for (int i = 0; i < assignment1.Length; i++) {
-        if (assignment1[i] == assignment2[i])
-          identicalAssignments++;
-      }
-      return ((double)identicalAssignments) / assignment1.Length;
-    }
   }
 }
Index: branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/HeuristicLab.Problems.QuadraticAssignment-3.3.csproj
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/HeuristicLab.Problems.QuadraticAssignment-3.3.csproj	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/HeuristicLab.Problems.QuadraticAssignment-3.3.csproj	(revision 6416)
@@ -124,4 +124,5 @@
     <Compile Include="Parsers\QAPLIBParser.cs" />
     <Compile Include="QAPAssignment.cs" />
+    <Compile Include="QAPPermutationProximityCalculator.cs" />
     <Compile Include="QuadraticAssignmentProblem.cs" />
     <EmbeddedResource Include="Data\bur26a.dat" />
Index: branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPPermutationProximityCalculator.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPPermutationProximityCalculator.cs	(revision 6416)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/QAPPermutationProximityCalculator.cs	(revision 6416)
@@ -0,0 +1,70 @@
+﻿#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.Collections.Generic;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.PermutationEncoding;
+
+namespace HeuristicLab.Problems.QuadraticAssignment {
+  public static class QAPPermutationProximityCalculator {
+
+    public static double CalculateGenotypeSimilarity(Permutation a, Permutation b) {
+      int similar = 0;
+      for (int i = 0; i < a.Length; i++) {
+        if (a[i] == b[i]) similar++;
+      }
+      return similar / (double)a.Length;
+    }
+
+    public static double CalculateGenotypeDistance(Permutation a, Permutation b) {
+      return 1.0 - CalculateGenotypeSimilarity(a, b);
+    }
+
+    public static double CalculatePhenotypeSimilarity(Permutation a, Permutation b, DoubleMatrix weights, DoubleMatrix distances) {
+      return 1.0 - CalculatePhenotypeDistance(a, b, weights, distances);
+    }
+
+    public static double CalculatePhenotypeDistance(Permutation a, Permutation b, DoubleMatrix weights, DoubleMatrix distances) {
+      Dictionary<string, int> alleles = new Dictionary<string, int>();
+      int distance = 0;
+      for (int x = 0; x < a.Length; x++) {
+        for (int y = 0; y < a.Length; y++) {
+          string alleleA = weights[x, y].ToString() + ">" + distances[a[x], a[y]].ToString();
+          string alleleB = weights[x, y].ToString() + ">" + distances[b[x], b[y]].ToString();
+          if (alleleA == alleleB) continue;
+
+          int countA = 1, countB = -1;
+          if (alleles.ContainsKey(alleleA)) countA += alleles[alleleA];
+          if (alleles.ContainsKey(alleleB)) countB += alleles[alleleB];
+
+          if (countA <= 0) distance--; // we've found in A an allele that was present in B
+          else distance++; // we've found in A a new allele
+          alleles[alleleA] = countA;
+
+          if (countB >= 0) distance--; // we've found in B an allele that was present in A
+          else distance++; // we've found in B a new allele
+          alleles[alleleB] = countB;
+        }
+      }
+      return distance / (double)(2 * a.Length * a.Length);
+    }
+  }
+}
Index: branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
===================================================================
--- branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs	(revision 6350)
+++ branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs	(revision 6416)
@@ -390,6 +390,6 @@
         Distances = new DoubleMatrix(parser.Distances);
         Weights = new DoubleMatrix(parser.Weights);
-        Name = "Quadratic Assignment Problem (loaded instance " + instance + ")";
-        Description = "Loaded embedded problem data of instance " + instance + ".";
+        Name = instance;
+        Description = "Loaded embedded QAPLIB problem data of instance " + instance + ".";
         OnReset();
       }
