Index: trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs	(revision 5933)
+++ trunk/sources/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs	(revision 6342)
@@ -61,4 +61,7 @@
       get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
     }
+    public LookupParameter<ItemList<Permutation>> BestKnownSolutionsParameter {
+      get { return (LookupParameter<ItemList<Permutation>>)Parameters["BestKnownSolutions"]; }
+    }
     public LookupParameter<Permutation> BestKnownSolutionParameter {
       get { return (LookupParameter<Permutation>)Parameters["BestKnownSolution"]; }
@@ -81,5 +84,16 @@
       Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best QAP solution should be stored."));
       Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this QAP instance."));
+      Parameters.Add(new LookupParameter<ItemList<Permutation>>("BestKnownSolutions", "The best known solutions (there may be multiple) of this QAP instance."));
       Parameters.Add(new LookupParameter<Permutation>("BestKnownSolution", "The best known solution of this QAP instance."));
+    }
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      // BackwardsCompatibility3.3
+      #region Backwards compatible code, remove with 3.4
+      if (!Parameters.ContainsKey("BestKnownSolutions")) {
+        Parameters.Add(new LookupParameter<ItemList<Permutation>>("BestKnownSolutions", "The best known solutions of this QAP instance."));
+      }
+      #endregion
     }
 
@@ -93,14 +107,38 @@
       DoubleValue bestKnownQuality = BestKnownQualityParameter.ActualValue;
 
-      int i = -1;
-      if (!max)
-        i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index;
-      else i = qualities.Select((x, index) => new { index, x.Value }).OrderByDescending(x => x.Value).First().index;
+      var sorted = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).ToArray();
+      if (max) sorted = sorted.Reverse().ToArray();
+      int i = sorted.First().index;
 
-      if (bestKnownQuality == null ||
-          max && qualities[i].Value > bestKnownQuality.Value ||
-          !max && qualities[i].Value < bestKnownQuality.Value) {
+      if (bestKnownQuality == null
+          || max && qualities[i].Value > bestKnownQuality.Value
+          || !max && qualities[i].Value < bestKnownQuality.Value) {
+        // if there isn't a best-known quality or we improved the best-known quality we'll add the current solution as best-known
         BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value);
         BestKnownSolutionParameter.ActualValue = (Permutation)permutations[i].Clone();
+        BestKnownSolutionsParameter.ActualValue = new ItemList<Permutation>();
+        BestKnownSolutionsParameter.ActualValue.Add((Permutation)permutations[i].Clone());
+      } else if (bestKnownQuality.Value == qualities[i].Value) {
+        // if we matched the best-known quality we'll try to set the best-known solution if it isn't null
+        // and try to add it to the pool of best solutions if it is different
+        if (BestKnownSolutionParameter.ActualValue == null)
+          BestKnownSolutionParameter.ActualValue = (Permutation)permutations[i].Clone();
+        if (BestKnownSolutionsParameter.ActualValue == null)
+          BestKnownSolutionsParameter.ActualValue = new ItemList<Permutation>();
+        PermutationEqualityComparer comparer = new PermutationEqualityComparer();
+        foreach (var k in sorted) { // for each solution that we found check if it is in the pool of best-knowns
+          if (!max && k.Value > qualities[i].Value
+            || max && k.Value < qualities[i].Value) break; // stop when we reached a solution worse than the best-known quality
+          Permutation p = permutations[k.index];
+          bool alreadyPresent = false;
+          foreach (Permutation p2 in BestKnownSolutionsParameter.ActualValue) {
+            if (comparer.Equals(p, p2)) {
+              alreadyPresent = true;
+              break;
+            }
+          }
+          if (!alreadyPresent)
+            BestKnownSolutionsParameter.ActualValue.Add((Permutation)permutations[k.index].Clone());
+        }
       }
 
