Index: branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs
===================================================================
--- branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs	(revision 6046)
+++ branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs	(revision 6086)
@@ -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,20 @@
       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 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("BestKnownSolution")) {
+        Parameters.Remove("BestKnownSolution");
+        Parameters.Add(new LookupParameter<ItemList<Permutation>>("BestKnownSolutions", "The best known solutions of this QAP instance."));
+      }*/
+      if (!Parameters.ContainsKey("BestKnownSolutions")) {
+        Parameters.Add(new LookupParameter<ItemList<Permutation>>("BestKnownSolutions", "The best known solutions of this QAP instance."));
+      }
+      #endregion
     }
 
@@ -93,14 +111,33 @@
       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
+          || bestKnownQuality.Value == qualities[i].Value
+            && (BestKnownSolutionsParameter.ActualValue == null || BestKnownSolutionsParameter.ActualValue.Count == 0)) {
         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 != null && qualities[i].Value == bestKnownQuality.Value) {
+        PermutationEqualityComparer comparer = new PermutationEqualityComparer();
+        foreach (var k in sorted) {
+          if (!max && k.Value > qualities[i].Value
+            || max && k.Value < qualities[i].Value) break;
+          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());
+        }
       }
 
Index: branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Evaluators/QAPEvaluator.cs
===================================================================
--- branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Evaluators/QAPEvaluator.cs	(revision 6046)
+++ branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Evaluators/QAPEvaluator.cs	(revision 6086)
@@ -69,4 +69,13 @@
     }
 
+    public static double Impact(int facility, Permutation assignment, DoubleMatrix weights, DoubleMatrix distances) {
+      double impact = 0;
+      for (int i = 0; i < assignment.Length; i++) {
+        impact += weights[facility, i] * distances[assignment[facility], assignment[i]];
+        impact += weights[i, facility] * distances[assignment[i], assignment[facility]];
+      }
+      return impact;
+    }
+
     public override IOperation Apply() {
       Permutation assignment = PermutationParameter.ActualValue;
Index: branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/HeuristicLab.Problems.QuadraticAssignment-3.3.csproj
===================================================================
--- branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/HeuristicLab.Problems.QuadraticAssignment-3.3.csproj	(revision 6046)
+++ branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/HeuristicLab.Problems.QuadraticAssignment-3.3.csproj	(revision 6086)
@@ -120,4 +120,5 @@
     <Compile Include="Interfaces\IQAPEvaluator.cs" />
     <Compile Include="Interfaces\IQAPMoveEvaluator.cs" />
+    <Compile Include="LocalImprovement\QAPExhaustiveSwap2LocalImprovement.cs" />
     <Compile Include="Parsers\QAPLIBSolutionParser.cs" />
     <Compile Include="Parsers\QAPLIBParser.cs" />
Index: branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveSwap2LocalImprovement.cs
===================================================================
--- branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveSwap2LocalImprovement.cs	(revision 6086)
+++ branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveSwap2LocalImprovement.cs	(revision 6086)
@@ -0,0 +1,132 @@
+﻿#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.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.PermutationEncoding;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.QuadraticAssignment {
+  [Item("QAPExhaustiveSwap2LocalImprovement", "Takes a solution and finds the local optimum with respect to the swap2 neighborhood by decending along the steepest gradient.")]
+  [StorableClass]
+  public class QAPExhaustiveSwap2LocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator {
+
+    public Type ProblemType {
+      get { return typeof(QuadraticAssignmentProblem); }
+    }
+
+    [Storable]
+    private QuadraticAssignmentProblem problem;
+    public IProblem Problem {
+      get { return problem; }
+      set { problem = (QuadraticAssignmentProblem)value; }
+    }
+
+    public IValueLookupParameter<IntValue> MaximumIterationsParameter {
+      get { return (IValueLookupParameter<IntValue>)Parameters["MaximumIterations"]; }
+    }
+
+    public ILookupParameter<IntValue> EvaluatedSolutionsParameter {
+      get { return (ILookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
+    }
+
+    public ILookupParameter<ResultCollection> ResultsParameter {
+      get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; }
+    }
+
+    public ILookupParameter<Permutation> AssignmentParameter {
+      get { return (ILookupParameter<Permutation>)Parameters["Assignment"]; }
+    }
+
+    public ILookupParameter<DoubleValue> QualityParameter {
+      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
+    }
+
+    public ILookupParameter<BoolValue> MaximizationParameter {
+      get { return (ILookupParameter<BoolValue>)Parameters["Maximization"]; }
+    }
+
+    public ILookupParameter<DoubleMatrix> WeightsParameter {
+      get { return (ILookupParameter<DoubleMatrix>)Parameters["Weights"]; }
+    }
+
+    public ILookupParameter<DoubleMatrix> DistancesParameter {
+      get { return (ILookupParameter<DoubleMatrix>)Parameters["Distances"]; }
+    }
+
+    [StorableConstructor]
+    protected QAPExhaustiveSwap2LocalImprovement(bool deserializing) : base(deserializing) { }
+    protected QAPExhaustiveSwap2LocalImprovement(QAPExhaustiveSwap2LocalImprovement original, Cloner cloner)
+      : base(original, cloner) {
+      this.problem = cloner.Clone(original.problem);
+    }
+    public QAPExhaustiveSwap2LocalImprovement()
+      : base() {
+      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum amount of iterations that should be performed (note that this operator will abort earlier when a local optimum is reached.", new IntValue(10000)));
+      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The amount of evaluated solutions (here a move is counted only as 4/n evaluated solutions with n being the length of the permutation)."));
+      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The collection where to store results."));
+      Parameters.Add(new LookupParameter<Permutation>("Assignment", "The permutation that is to be locally optimized."));
+      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value of the assignment."));
+      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem should be maximized or minimized."));
+      Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", "The weights matrix."));
+      Parameters.Add(new LookupParameter<DoubleMatrix>("Distances", "The distances matrix."));
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new QAPExhaustiveSwap2LocalImprovement(this, cloner);
+    }
+
+    public override IOperation Apply() {
+      int maxIterations = MaximumIterationsParameter.ActualValue.Value;
+      Permutation assignment = AssignmentParameter.ActualValue;
+      bool maximization = MaximizationParameter.ActualValue.Value;
+      DoubleMatrix weights = WeightsParameter.ActualValue;
+      DoubleMatrix distances = DistancesParameter.ActualValue;
+
+      double evaluatedSolutions = 0.0;
+      double evalSolPerMove = 4.0 / assignment.Length;
+
+      for (int i = 0; i < maxIterations; i++) {
+        Swap2Move bestMove = null;
+        double bestQuality = 0; // we have to make an improvement, so 0 is the baseline
+        foreach (Swap2Move move in ExhaustiveSwap2MoveGenerator.Generate(assignment)) {
+          double moveQuality = QAPSwap2MoveEvaluator.Apply(assignment, move, weights, distances);
+          evaluatedSolutions += evalSolPerMove;
+          if (maximization && moveQuality > bestQuality
+            || !maximization && moveQuality < bestQuality) {
+            bestQuality = moveQuality;
+            bestMove = move;
+          }
+        }
+        if (bestMove == null) break;
+        Swap2Manipulator.Apply(assignment, bestMove.Index1, bestMove.Index2);
+        QualityParameter.ActualValue.Value += bestQuality;
+      }
+      EvaluatedSolutionsParameter.ActualValue.Value += (int)Math.Ceiling(evaluatedSolutions);
+      return base.Apply();
+    }
+  }
+}
Index: branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
===================================================================
--- branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs	(revision 6046)
+++ branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs	(revision 6086)
@@ -49,4 +49,7 @@
 
     #region Parameter Properties
+    public IValueParameter<ItemList<Permutation>> BestKnownSolutionsParameter {
+      get { return (IValueParameter<ItemList<Permutation>>)Parameters["BestKnownSolutions"]; }
+    }
     public IValueParameter<Permutation> BestKnownSolutionParameter {
       get { return (IValueParameter<Permutation>)Parameters["BestKnownSolution"]; }
@@ -61,4 +64,8 @@
 
     #region Properties
+    public ItemList<Permutation> BestKnownSolutions {
+      get { return BestKnownSolutionsParameter.Value; }
+      set { BestKnownSolutionsParameter.Value = value; }
+    }
     public Permutation BestKnownSolution {
       get { return BestKnownSolutionParameter.Value; }
@@ -106,4 +113,5 @@
     public QuadraticAssignmentProblem()
       : base(new QAPEvaluator(), new RandomPermutationCreator()) {
+      Parameters.Add(new OptionalValueParameter<ItemList<Permutation>>("BestKnownSolutions", "The list of best known solutions 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>("Weights", "The strength of the connection between the facilities.", new DoubleMatrix(5, 5)));
@@ -138,4 +146,23 @@
     public override IDeepCloneable Clone(Cloner cloner) {
       return new QuadraticAssignmentProblem(this, cloner);
+    }
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      // BackwardsCompatibility3.3
+      #region Backwards compatible code, remove with 3.4
+      /*if (Parameters.ContainsKey("BestKnownSolution")) {
+        Permutation solution = ((IValueParameter<Permutation>)Parameters["BestKnownSolution"]).Value;
+        Parameters.Remove("BestKnownSolution");
+        Parameters.Add(new OptionalValueParameter<ItemList<Permutation>>("BestKnownSolutions", "The list of best known solutions which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null));
+        if (solution != null) {
+          BestKnownSolutions = new ItemList<Permutation>();
+          BestKnownSolutions.Add(solution);
+        }
+      }*/
+      if (!Parameters.ContainsKey("BestKnownSolutions")) {
+        Parameters.Add(new OptionalValueParameter<ItemList<Permutation>>("BestKnownSolutions", "The list of best known solutions which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null));
+      }
+      #endregion
     }
 
@@ -246,4 +273,5 @@
       Operators.Add(new QAPAlleleFrequencyAnalyzer());
       Operators.Add(new QAPPopulationDiversityAnalyzer());
+      Operators.Add(new QAPExhaustiveSwap2LocalImprovement());
       ParameterizeAnalyzers();
       ParameterizeOperators();
@@ -270,5 +298,5 @@
         BestQAPSolutionAnalyzer.ResultsParameter.ActualName = "Results";
         BestQAPSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
-        BestQAPSolutionAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
+        BestQAPSolutionAnalyzer.BestKnownSolutionsParameter.ActualName = BestKnownSolutionsParameter.Name;
         BestQAPSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
       }
@@ -314,4 +342,13 @@
       foreach (var op in Operators.OfType<IPermutationMultiNeighborhoodShakingOperator>())
         op.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
+
+      QAPExhaustiveSwap2LocalImprovement localOpt = Operators.OfType<QAPExhaustiveSwap2LocalImprovement>().SingleOrDefault();
+      if (localOpt != null) {
+        localOpt.AssignmentParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
+        localOpt.DistancesParameter.ActualName = DistancesParameter.Name;
+        localOpt.MaximizationParameter.ActualName = MaximizationParameter.Name;
+        localOpt.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
+        localOpt.WeightsParameter.ActualName = WeightsParameter.Name;
+      }
     }
 
@@ -338,5 +375,5 @@
       Description = "Imported problem data using QAPLIBParser " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().FirstOrDefault().Version + ".";
       BestKnownQuality = null;
-      BestKnownSolution = null;
+      BestKnownSolutions = null;
       OnReset();
     }
@@ -371,11 +408,14 @@
             if (solParser.Quality.IsAlmost(QAPEvaluator.Apply(new Permutation(PermutationTypes.Absolute, solParser.Assignment), Weights, Distances))) {
               BestKnownQuality = new DoubleValue(solParser.Quality);
+              BestKnownSolutions = new ItemList<Permutation>(new Permutation[] { new Permutation(PermutationTypes.Absolute, solParser.Assignment) });
               BestKnownSolution = new Permutation(PermutationTypes.Absolute, solParser.Assignment);
             } else {
               BestKnownQuality = new DoubleValue(solParser.Quality);
+              BestKnownSolutions = null;
               BestKnownSolution = null;
             }
           } else {
             BestKnownQuality = new DoubleValue(solParser.Quality);
+            BestKnownSolutions = new ItemList<Permutation>(new Permutation[] { new Permutation(PermutationTypes.Absolute, solParser.Assignment) });
             BestKnownSolution = new Permutation(PermutationTypes.Absolute, solParser.Assignment);
           }
@@ -383,4 +423,5 @@
       } else {
         BestKnownQuality = null;
+        BestKnownSolutions = null;
         BestKnownSolution = null;
       }
