Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Algorithms/ExtremePointAlgorithm.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Algorithms/ExtremePointAlgorithm.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Algorithms/ExtremePointAlgorithm.cs	(revision 15989)
@@ -83,8 +83,8 @@
 
     [Storable]
-    private readonly IValueParameter<BoolValue> sortByMaterialParameter;
-
-    public IValueParameter<BoolValue> SortByMaterialParameter {
-      get { return sortByMaterialParameter; }
+    private readonly IValueParameter<BoolValue> sortBySequenceGroupParameter;
+
+    public IValueParameter<BoolValue> SortBySequenceGroupParameter {
+      get { return sortBySequenceGroupParameter; }
     }
 
@@ -116,6 +116,6 @@
         "Delta", "[1;100]% Clustered sorting methods use a delta parameter to determine the clusters.", new PercentValue(.1)));
 
-      Parameters.Add(sortByMaterialParameter = new ValueParameter<BoolValue>(
-        "SortByMaterial", "If this parameter is set, the items will be sorted by their material first", new BoolValue(true)));
+      Parameters.Add(sortBySequenceGroupParameter = new ValueParameter<BoolValue>(
+        "SortBySequenceGroup", "If this parameter is set, the items will be sorted by their sequence group first", new BoolValue(true)));
 
       Problem = new PermutationProblem();
@@ -209,4 +209,5 @@
                   ExtremePointCreationMethod[] epCreationMethods,
                   CancellationToken token) {
+
       SortingMethod? bestSorting = null;
       FittingMethod? bestFitting = null;
@@ -223,10 +224,6 @@
             Permutation sortedItems;
 
-            if (SortByMaterialParameter.Value.Value) {
-              sortedItems = SortItemsByMaterialAndSortingMethod(bin, items, sort, DeltaParameter.Value.Value);
-            } else {
-              sortedItems = SortItemsBySortingMethod(bin, items, sort, DeltaParameter.Value.Value);
-            }
-
+            sortedItems = SortItems(bin, items, sort, DeltaParameter.Value.Value, SortBySequenceGroupParameter.Value.Value);
+            
             var solution = Optimize(new OptimaizationParamters() {
               SortedItems = sortedItems,
@@ -265,5 +262,4 @@
     /// <returns></returns>
     private static Solution Optimize(OptimaizationParamters parameters) {
-
       var sol = parameters.Decoder.Decode(parameters.SortedItems, parameters.Bin, parameters.Items, parameters.StackingConstraints);
 
@@ -281,81 +277,24 @@
     }
     
-    /// <summary>
-    /// Returns a new permutation of the given items depending on the sorting method
-    /// </summary>
-    /// <param name="bin"></param>
-    /// <param name="items"></param>
-    /// <param name="sortingMethod"></param>
-    /// <param name="delta"></param>
-    /// <returns></returns>
-    private Permutation SortItemsByMaterialAndSortingMethod(PackingShape bin, IList<PackingItem> items, SortingMethod sortingMethod, double delta) {
-      Permutation sorted = null;
-
-      switch (sortingMethod) {
-        case SortingMethod.Given:
-          sorted = new Permutation(PermutationTypes.Absolute, Enumerable.Range(0, items.Count).ToArray());
-          break;
-        case SortingMethod.VolumeHeight:
-          sorted = items.SortByVolumeHeight();
-          break;
-        case SortingMethod.HeightVolume:
-          sorted = items.SortByMaterialHeightVolume();
-          break;
-        case SortingMethod.AreaHeight:
-          sorted = items.SortByMaterialAreaHeight();
-          break;
-        case SortingMethod.HeightArea:
-          sorted = items.SortByMaterialHeightArea();
-          break;
-        case SortingMethod.ClusteredAreaHeight:
-          sorted = items.SortByMaterialClusteredAreaHeight(bin, delta);
-          break;
-        case SortingMethod.ClusteredHeightArea:
-          sorted = items.SortByMaterialClusteredHeightArea(bin, delta);
-          break;
-        default:
-          throw new ArgumentException("Unknown sorting method: " + sortingMethod);
-      }
-      return sorted;
-    }
-
-    /// <summary>
-    /// Returns a new permutation of the given items depending on the material and sorting method
-    /// </summary>
-    /// <param name="bin"></param>
-    /// <param name="items"></param>
-    /// <param name="sortingMethod"></param>
-    /// <param name="delta"></param>
-    /// <returns></returns>
-    private Permutation SortItemsBySortingMethod(PackingShape bin, IList<PackingItem> items, SortingMethod sortingMethod, double delta) {
-      Permutation sorted = null;
-
-      switch (sortingMethod) {
-        case SortingMethod.Given:
-          sorted = new Permutation(PermutationTypes.Absolute, Enumerable.Range(0, items.Count).ToArray());
-          break;
-        case SortingMethod.VolumeHeight:
-          sorted = items.SortByVolumeHeight();
-          break;
-        case SortingMethod.HeightVolume:
-          sorted = items.SortByHeightVolume();
-          break;
-        case SortingMethod.AreaHeight:
-          sorted = items.SortByAreaHeight();
-          break;
-        case SortingMethod.HeightArea:
-          sorted = items.SortByHeightArea();
-          break;
-        case SortingMethod.ClusteredAreaHeight:
-          sorted = items.SortByClusteredAreaHeight(bin, delta);
-          break;
-        case SortingMethod.ClusteredHeightArea:
-          sorted = items.SortByClusteredHeightArea(bin, delta);
-          break;
-        default:
-          throw new ArgumentException("Unknown sorting method: " + sortingMethod);
-      }
-      return sorted;
-    }
+
+    private Permutation SortItems(PackingShape bin, IList<PackingItem> items, SortingMethod sortingMethod, double delta, bool sortBySequenceGroup) {
+      Permutation sortedItems;
+
+      var sorter = PackingItemSorterFactory.CreatePackingItemSorter(sortingMethod);
+      if (sorter is IPackingItemClusteredSorter) {
+        if (sortBySequenceGroup) {
+          sortedItems = (sorter as IPackingItemClusteredSorter).SortPackingItemsBySequenceGroup(items, bin, delta);
+        } else {
+          sortedItems = (sorter as IPackingItemClusteredSorter).SortPackingItems(items, bin, delta);
+        }
+      } else {
+        if (sortBySequenceGroup) {
+          sortedItems = sorter.SortPackingItemsBySequenceGroup(items, bin);
+        } else {
+          sortedItems = sorter.SortPackingItems(items, bin);
+        }
+      }
+      return sortedItems;
+    }    
   }
 }
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Instances/RandomInstanceProvider.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Instances/RandomInstanceProvider.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Instances/RandomInstanceProvider.cs	(revision 15989)
@@ -198,17 +198,7 @@
     protected virtual void SampleItemParameters(IRandom rand, out int w, out int h, out int d) {
       Contract.Assert(@class >= 1 && @class <= 5);
-      /*var weights = new double[] { 0.1, 0.1, 0.1, 0.1, 0.1 };
+      var weights = new double[] { 0.1, 0.1, 0.1, 0.1, 0.1 };
       weights[@class - 1] = 0.6;
       var type = Enumerable.Range(1, 5).SampleProportional(rand, 1, weights).First();
-      */
-
-      // as by Martello and Vigo
-      int type = @class;
-      if (type <= 5) {
-        var t = rand.Next(1, 10);
-        if (t <= 5) {
-          type = t;
-        }
-      }
 
       switch (type) {
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPackerResidualSpaceBestFit.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPackerResidualSpaceBestFit.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPackerResidualSpaceBestFit.cs	(revision 15989)
@@ -104,5 +104,5 @@
         foreach (var extremPoints in bp.ExtremePoints) {
           var ep = extremPoints.Key;
-          var residualSpaces = extremPoints.Value.Where(rs => rs.Width < item.Width || rs.Height < item.Height || rs.Depth < item.Depth);
+          var residualSpaces = extremPoints.Value.Where(rs => rs.Width >= item.Width && rs.Height >= item.Height && rs.Depth >= item.Depth);
           if (residualSpaces.Count() <= 0) {
             continue;
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/IPackingItemClusteredSorter.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/IPackingItemClusteredSorter.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/IPackingItemClusteredSorter.cs	(revision 15989)
@@ -31,5 +31,5 @@
     Permutation SortPackingItems(IList<PackingItem> items, PackingShape bin, double delta);
 
-    Permutation SortPackingItemsByMaterial(IList<PackingItem> items, PackingShape bin, double delta);
+    Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin, double delta);
     
   }
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/IPackingItemSorter.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/IPackingItemSorter.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/IPackingItemSorter.cs	(revision 15989)
@@ -32,5 +32,5 @@
     Permutation SortPackingItems(IList<PackingItem> items, PackingShape bin);
 
-    Permutation SortPackingItemsByMaterial(IList<PackingItem> items, PackingShape bin);
+    Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin);
   }
 }
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemAreaHeightSorter.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemAreaHeightSorter.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemAreaHeightSorter.cs	(revision 15989)
@@ -34,5 +34,5 @@
     }
     
-    public Permutation SortPackingItemsByMaterial(IList<PackingItem> items, PackingShape bin) {
+    public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) {
       return items.SortByMaterialAreaHeight();
     }    
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemClusterdHeightAreaSorter.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemClusterdHeightAreaSorter.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemClusterdHeightAreaSorter.cs	(revision 15989)
@@ -38,10 +38,10 @@
     }
 
-    public Permutation SortPackingItemsByMaterial(IList<PackingItem> items, PackingShape bin, double delta) {
+    public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin, double delta) {
       return items.SortByMaterialClusteredHeightArea(bin, delta);
     }
 
-    public Permutation SortPackingItemsByMaterial(IList<PackingItem> items, PackingShape bin) {
-      return SortPackingItemsByMaterial(items, bin, 10.0);
+    public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) {
+      return SortPackingItemsBySequenceGroup(items, bin, 10.0);
     }
   }
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemClusteredAreaHeightSorter.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemClusteredAreaHeightSorter.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemClusteredAreaHeightSorter.cs	(revision 15989)
@@ -38,10 +38,10 @@
     }
 
-    public Permutation SortPackingItemsByMaterial(IList<PackingItem> items, PackingShape bin, double delta) {
+    public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin, double delta) {
       return items.SortByMaterialClusteredAreaHeight(bin, delta);
     }
 
-    public Permutation SortPackingItemsByMaterial(IList<PackingItem> items, PackingShape bin) {
-      return SortPackingItemsByMaterial(items, bin, 10.0);
+    public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) {
+      return SortPackingItemsBySequenceGroup(items, bin, 10.0);
     }
   }
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemGivenSorter.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemGivenSorter.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemGivenSorter.cs	(revision 15989)
@@ -34,5 +34,5 @@
     }
 
-    public Permutation SortPackingItemsByMaterial(IList<PackingItem> items, PackingShape bin) {
+    public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) {
       return new Permutation(PermutationTypes.Absolute, Enumerable.Range(0, items.Count).ToArray());
     }
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemHeightAreaSorter.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemHeightAreaSorter.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemHeightAreaSorter.cs	(revision 15989)
@@ -34,5 +34,5 @@
     }
 
-    public Permutation SortPackingItemsByMaterial(IList<PackingItem> items, PackingShape bin) {
+    public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) {
       return items.SortByMaterialHeightArea();
     }
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemHeightVolumeSorter.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemHeightVolumeSorter.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemHeightVolumeSorter.cs	(revision 15989)
@@ -34,5 +34,5 @@
     }
 
-    public Permutation SortPackingItemsByMaterial(IList<PackingItem> items, PackingShape bin) {
+    public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) {
       return items.SortByMaterialHeightVolume();
     }    
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemVolumeHeightSorter.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemVolumeHeightSorter.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemVolumeHeightSorter.cs	(revision 15989)
@@ -34,5 +34,5 @@
     }
 
-    public Permutation SortPackingItemsByMaterial(IList<PackingItem> items, PackingShape bin) {
+    public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) {
       return items.SortByMaterialVolumeHeight();
     }
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Algorithms/ExtremePointAlgorithmTest.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Algorithms/ExtremePointAlgorithmTest.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Algorithms/ExtremePointAlgorithmTest.cs	(revision 15989)
@@ -83,5 +83,5 @@
       _extremPointAlgorithm.FittingMethodParameter.Value.Value = FittingMethod.FirstFit;
       _extremPointAlgorithm.ExtremePointCreationMethodParameter.Value.Value = ExtremePointCreationMethod.PointProjection;
-      _extremPointAlgorithm.SortByMaterialParameter.Value.Value = false;
+      _extremPointAlgorithm.SortBySequenceGroupParameter.Value.Value = false;
       var result = TestUtils.InvokeMethod(typeof(ExtremePointAlgorithm), _extremPointAlgorithm, "GetBest", parameters) as Tuple<Solution, double, SortingMethod?, FittingMethod?, ExtremePointCreationMethod?>;
 
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Instances/RandomInstanceProviderTest.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Instances/RandomInstanceProviderTest.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Instances/RandomInstanceProviderTest.cs	(revision 15989)
@@ -17,86 +17,5 @@
       public int Height { get; set; }
       public int Depth { get; set; }
-    }
-
-    #region TestRandomInstanceProvider
-
-
-    /// <summary>
-    /// Tests if the generated random instance equals to the references generated by david pisinger 
-    /// http://www.diku.dk/~pisinger/new3dbpp/test3dbpp.c
-    /// </summary>
-    [TestMethod]
-    [TestCategory("Problems.BinPacking.3D")]
-    [TestProperty("Time", "long")]
-    public void TestRandomInstanceProvider() {
-
-      var referenceItemLists = ReadReferenceItemLists();
-      TestRandomInstanceProviderByClass(new RandomInstanceClass1Provider(), referenceItemLists);
-      TestRandomInstanceProviderByClass(new RandomInstanceClass2Provider(), referenceItemLists);
-      TestRandomInstanceProviderByClass(new RandomInstanceClass3Provider(), referenceItemLists);
-      TestRandomInstanceProviderByClass(new RandomInstanceClass4Provider(), referenceItemLists);
-      TestRandomInstanceProviderByClass(new RandomInstanceClass5Provider(), referenceItemLists);
-      TestRandomInstanceProviderByClass(new RandomInstanceClass6Provider(), referenceItemLists);
-      TestRandomInstanceProviderByClass(new RandomInstanceClass7Provider(), referenceItemLists);
-      TestRandomInstanceProviderByClass(new RandomInstanceClass8Provider(), referenceItemLists);
-
-    }
-
-    private IDictionary<string, List<Dimension>> ReadReferenceItemLists() {
-      var itemList = new Dictionary<string, List<Dimension>>();
-      string path = @".\..\HeuristicLab.Tests\HeuristicLab.Problems.Bin-Packing-3.3\TestInstances\ReferenceInstances";
-
-      string[] files = Directory.GetFiles(path);
-      foreach (string filePath in files) {
-        string key = Path.GetFileNameWithoutExtension(filePath);
-
-        using (StreamReader reader = new StreamReader(filePath)) {
-          int lineNumber = 1;
-          List<Dimension> dimensionList = new List<Dimension>();
-          while (!reader.EndOfStream) {
-            string line = reader.ReadLine();
-            if (lineNumber > 2) {
-              string[] lineValues = line.Split('\t');
-              int id;
-              int depth;
-              int width;
-              int height;
-              Int32.TryParse(lineValues[0], out id);
-              Int32.TryParse(lineValues[1], out depth);
-              Int32.TryParse(lineValues[2], out width);
-              Int32.TryParse(lineValues[3], out height);
-              dimensionList.Add(new Dimension() {
-                Id = id,
-                Depth = depth,
-                Width = width,
-                Height = height
-              });
-            }
-            lineNumber++;
-          }
-          itemList.Add(key, dimensionList);
-        }
-      }
-      return itemList;
-    }
-
-    private void TestRandomInstanceProviderByClass(RandomInstanceProvider randomInstanceProvider, IDictionary<string, List<Dimension>> referenceItems) {
-
-      var dataDescriptors = randomInstanceProvider.GetDataDescriptors();
-      foreach (var dataDescriptor in dataDescriptors) {
-        List<Dimension> testItemDimensions = null;
-        if (referenceItems.TryGetValue(dataDescriptor.Name, out testItemDimensions)) {
-          var packingItems = randomInstanceProvider.LoadData(dataDescriptor).Items;
-          Assert.IsNotNull(packingItems);
-          Assert.AreEqual(testItemDimensions.Count, packingItems.Length);
-          for (int i = 0; i < packingItems.Length; i++) {
-            Assert.AreEqual(testItemDimensions[i].Width, packingItems[i].Width);
-            Assert.AreEqual(testItemDimensions[i].Height, packingItems[i].Height);
-            Assert.AreEqual(testItemDimensions[i].Depth, packingItems[i].Depth);
-          }
-        }
-      }
-    }
-    #endregion
+    }    
 
     #region TestExtremePointAlgorithm
@@ -198,5 +117,5 @@
             algorithm.FittingMethodParameter.Value.Value = fittingMethod;
             algorithm.ExtremePointCreationMethodParameter.Value.Value = epCreationMethod;
-            algorithm.SortByMaterialParameter.Value.Value = false;
+            algorithm.SortBySequenceGroupParameter.Value.Value = false;
 
             algorithm.Problem.UseStackingConstraintsParameter.Value.Value = false;
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Instances/ThreeDInstanceParserTest.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Instances/ThreeDInstanceParserTest.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Instances/ThreeDInstanceParserTest.cs	(revision 15989)
@@ -19,27 +19,27 @@
 
       _items1.Add(new PackingItem(8, 10, 10, _packingShape, 800, 1, 1)); // 0,  V = 800,  A =  80, h = 10
-      _items1.Add(new PackingItem(10, 8, 10, _packingShape, 800, 2, 1)); // 1,  V = 800,  A = 100, h =  8
-      _items1.Add(new PackingItem(10, 10, 8, _packingShape, 800, 3, 1)); // 2,  V = 800,  A =  80, h = 10
-      _items1.Add(new PackingItem(8, 8, 10,  _packingShape, 640, 4, 1)); // 3,   V = 640,  A =  80, h =  8
-      _items1.Add(new PackingItem(10, 8, 8,  _packingShape, 640, 0, 1)); // 4,   V = 640,  A =  80, h =  8
+      _items1.Add(new PackingItem(10, 8, 10, _packingShape, 800, 2, 2)); // 1,  V = 800,  A = 100, h =  8
+      _items1.Add(new PackingItem(10, 10, 8, _packingShape, 800, 3, 3)); // 2,  V = 800,  A =  80, h = 10
+      _items1.Add(new PackingItem(8, 8, 10,  _packingShape, 640, 4, 4)); // 3,   V = 640,  A =  80, h =  8
+      _items1.Add(new PackingItem(10, 8, 8,  _packingShape, 640, 0, 0)); // 4,   V = 640,  A =  80, h =  8
       _items1.Add(new PackingItem(8, 10, 8,  _packingShape, 640, 1, 1)); // 5,   V = 640,  A =  64, h = 10  
-      _items1.Add(new PackingItem(8, 8, 8,   _packingShape, 512, 2, 1)); // 6,    V = 512,  A =  64, h =  8
+      _items1.Add(new PackingItem(8, 8, 8,   _packingShape, 512, 2, 2)); // 6,    V = 512,  A =  64, h =  8
 
-      _items1.Add(new PackingItem(10, 10, 10, _packingShape,1000,3, 1)); // 7, V = 1000, A = 100, h = 10
+      _items1.Add(new PackingItem(10, 10, 10, _packingShape,1000,3, 3)); // 7, V = 1000, A = 100, h = 10
 
-      _items1.Add(new PackingItem(9, 10, 10, _packingShape, 900, 4, 1)); // 8,  V = 900,  A =  90, h = 10
-      _items1.Add(new PackingItem(10, 9, 10, _packingShape, 900, 0, 1)); // 9,  V = 900,  A = 100, h =  9
+      _items1.Add(new PackingItem(9, 10, 10, _packingShape, 900, 4, 4)); // 8,  V = 900,  A =  90, h = 10
+      _items1.Add(new PackingItem(10, 9, 10, _packingShape, 900, 0, 0)); // 9,  V = 900,  A = 100, h =  9
       _items1.Add(new PackingItem(10, 10, 9, _packingShape, 900, 1, 1)); // 10, V = 900,  A =  90, h = 10
-      _items1.Add(new PackingItem(9, 9, 10,  _packingShape, 810, 2, 1)); // 11,  V = 810,  A =  90, h =  9
-      _items1.Add(new PackingItem(10, 9, 9,  _packingShape, 810, 3, 1)); // 12,  V = 810,  A =  90, h =  9
-      _items1.Add(new PackingItem(9, 10, 9,  _packingShape, 810, 4, 1)); // 13,  V = 810,  A =  81, h = 10
-      _items1.Add(new PackingItem(9, 9, 9,   _packingShape, 729, 0, 1)); // 14,   V = 729,  A =  81, h =  9
+      _items1.Add(new PackingItem(9, 9, 10,  _packingShape, 810, 2, 2)); // 11,  V = 810,  A =  90, h =  9
+      _items1.Add(new PackingItem(10, 9, 9,  _packingShape, 810, 3, 3)); // 12,  V = 810,  A =  90, h =  9
+      _items1.Add(new PackingItem(9, 10, 9,  _packingShape, 810, 4, 4)); // 13,  V = 810,  A =  81, h = 10
+      _items1.Add(new PackingItem(9, 9, 9,   _packingShape, 729, 0, 0)); // 14,   V = 729,  A =  81, h =  9
 
       _items2 = new List<PackingItem>();
       _items2.Add(new PackingItem(8, 10, 10, _packingShape, 800, 1, 1)); // 0,  V = 800,  A =  80, h = 10
-      _items2.Add(new PackingItem(10, 8, 10, _packingShape, 800, 2, 1)); // 1,  V = 800,  A = 100, h =  8
-      _items2.Add(new PackingItem(10, 10, 8, _packingShape, 800, 3, 1)); // 2,  V = 800,  A =  80, h = 10
-      _items2.Add(new PackingItem(8, 8, 10, _packingShape, 640, 4, 1)); // 3,   V = 640,  A =  80, h =  8
-      _items2.Add(new PackingItem(10, 8, 8, _packingShape, 640, 0, 1)); // 4,   V = 640,  A =  80, h =  8
+      _items2.Add(new PackingItem(10, 8, 10, _packingShape, 800, 2, 2)); // 1,  V = 800,  A = 100, h =  8
+      _items2.Add(new PackingItem(10, 10, 8, _packingShape, 800, 3, 3)); // 2,  V = 800,  A =  80, h = 10
+      _items2.Add(new PackingItem(8, 8, 10, _packingShape, 640, 4, 4)); // 3,   V = 640,  A =  80, h =  8
+      _items2.Add(new PackingItem(10, 8, 8, _packingShape, 640, 0, 0)); // 4,   V = 640,  A =  80, h =  8
       _items2.Add(new PackingItem(8, 10, 8, _packingShape, 640, 1, 1)); // 5,   V = 640,  A =  64, h = 10  
     }
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Sorting/PermutationSortingTest.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Sorting/PermutationSortingTest.cs	(revision 15988)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Sorting/PermutationSortingTest.cs	(revision 15989)
@@ -18,20 +18,20 @@
 
       _items.Add(new PackingItem(8, 10, 10, _packingShape, 1000, 1, 1)); // 0,  V = 800,  A =  80, h = 10
-      _items.Add(new PackingItem(10, 8, 10, _packingShape, 1000, 2, 1)); // 1,  V = 800,  A = 100, h =  8
-      _items.Add(new PackingItem(10, 10, 8, _packingShape, 1000, 3, 1)); // 2,  V = 800,  A =  80, h = 10
-      _items.Add(new PackingItem(8, 8, 10, _packingShape, 1000, 4, 1)); // 3,   V = 640,  A =  80, h =  8
-      _items.Add(new PackingItem(10, 8, 8, _packingShape, 1000, 0, 1)); // 4,   V = 640,  A =  80, h =  8
+      _items.Add(new PackingItem(10, 8, 10, _packingShape, 1000, 2, 2)); // 1,  V = 800,  A = 100, h =  8
+      _items.Add(new PackingItem(10, 10, 8, _packingShape, 1000, 3, 3)); // 2,  V = 800,  A =  80, h = 10
+      _items.Add(new PackingItem(8, 8, 10, _packingShape, 1000, 4, 4)); // 3,   V = 640,  A =  80, h =  8
+      _items.Add(new PackingItem(10, 8, 8, _packingShape, 1000, 0, 0)); // 4,   V = 640,  A =  80, h =  8
       _items.Add(new PackingItem(8, 10, 8, _packingShape, 1000, 1, 1)); // 5,   V = 640,  A =  64, h = 10  
-      _items.Add(new PackingItem(8, 8, 8, _packingShape, 1000, 2, 1)); // 6,    V = 512,  A =  64, h =  8
+      _items.Add(new PackingItem(8, 8, 8, _packingShape, 1000, 2, 2)); // 6,    V = 512,  A =  64, h =  8
 
-      _items.Add(new PackingItem(10, 10, 10, _packingShape, 1000, 3, 1)); // 7, V = 1000, A = 100, h = 10
+      _items.Add(new PackingItem(10, 10, 10, _packingShape, 1000, 3, 3)); // 7, V = 1000, A = 100, h = 10
 
-      _items.Add(new PackingItem(9, 10, 10, _packingShape, 1000, 4, 1)); // 8,  V = 900,  A =  90, h = 10
-      _items.Add(new PackingItem(10, 9, 10, _packingShape, 1000, 0, 1)); // 9,  V = 900,  A = 100, h =  9
+      _items.Add(new PackingItem(9, 10, 10, _packingShape, 1000, 4, 4)); // 8,  V = 900,  A =  90, h = 10
+      _items.Add(new PackingItem(10, 9, 10, _packingShape, 1000, 0, 0)); // 9,  V = 900,  A = 100, h =  9
       _items.Add(new PackingItem(10, 10, 9, _packingShape, 1000, 1, 1)); // 10, V = 900,  A =  90, h = 10
-      _items.Add(new PackingItem(9, 9, 10, _packingShape, 1000, 2, 1)); // 11,  V = 810,  A =  90, h =  9
-      _items.Add(new PackingItem(10, 9, 9, _packingShape, 1000, 3, 1)); // 12,  V = 810,  A =  90, h =  9
-      _items.Add(new PackingItem(9, 10, 9, _packingShape, 1000, 4, 1)); // 13,  V = 810,  A =  81, h = 10
-      _items.Add(new PackingItem(9, 9, 9, _packingShape, 1000, 0, 1)); // 14,   V = 729,  A =  81, h =  9
+      _items.Add(new PackingItem(9, 9, 10, _packingShape, 1000, 2, 2)); // 11,  V = 810,  A =  90, h =  9
+      _items.Add(new PackingItem(10, 9, 9, _packingShape, 1000, 3, 3)); // 12,  V = 810,  A =  90, h =  9
+      _items.Add(new PackingItem(9, 10, 9, _packingShape, 1000, 4, 4)); // 13,  V = 810,  A =  81, h = 10
+      _items.Add(new PackingItem(9, 9, 9, _packingShape, 1000, 0, 0)); // 14,   V = 729,  A =  81, h =  9
     }
 
@@ -40,6 +40,6 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByVolumeHeightExtension() {
-      Permutation actual = _items.SortByVolumeHeight();
+    public void TestSortByVolumeHeight() {
+      Permutation actual =  PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.VolumeHeight).SortPackingItems(_items, _packingShape);
       Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7,  8, 10, 9, 13, 11, 12, 0, 2, 1, 14, 5, 3, 4, 6});
       for (int i = 0; i < expected.Length; i++) {
@@ -51,6 +51,6 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByHeightVolumeExtension() {
-      Permutation actual = _items.SortByHeightVolume();
+    public void TestSortByHeightVolume() {
+      Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.HeightVolume).SortPackingItems(_items, _packingShape);
       Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7, 8, 10, 13, 0, 2, 5, 9, 11, 12, 14, 1, 3, 4, 6 });
       for (int i = 0; i < expected.Length; i++) {
@@ -63,6 +63,6 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByAreaHeightExtension() {
-      Permutation actual = _items.SortByAreaHeight();
+    public void TestSortByAreaHeight() {
+      Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.AreaHeight).SortPackingItems(_items, _packingShape);
       Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7, 9, 1, 8, 10, 11, 12, 13, 14, 0, 2, 3, 4, 5, 6});
       for (int i = 0; i < expected.Length; i++) {
@@ -75,6 +75,6 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByHeightAreaExtension() {
-      Permutation actual = _items.SortByHeightArea();
+    public void TestSortByHeightArea() {
+      Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.HeightArea).SortPackingItems(_items, _packingShape);
       Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7, 8, 10, 13, 0, 2, 5, 9, 11, 12, 14, 1, 3, 4, 6});
       for (int i = 0; i < expected.Length; i++) {
@@ -86,6 +86,6 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByClusteredAreaHeightExtension() {
-      Permutation actual = _items.SortByClusteredAreaHeight(_packingShape, 1.0);
+    public void TestSortByClusteredAreaHeight() {
+      Permutation actual = ((IPackingItemClusteredSorter)PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.ClusteredAreaHeight)).SortPackingItems(_items, _packingShape, 1.0);
       Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 0, 2, 5, 7, 8, 10, 13, 9, 11, 12, 14, 1, 3, 4, 6 });
       for (int i = 0; i < expected.Length; i++) {
@@ -97,6 +97,6 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByClusteredHeightAreaExtension() {
-      Permutation actual = _items.SortByClusteredHeightArea(_packingShape, 1.0);
+    public void TestSortByClusteredHeightArea() {
+      Permutation actual = ((IPackingItemClusteredSorter)PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.ClusteredHeightArea)).SortPackingItems(_items, _packingShape, 1.0);
       Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 1, 7, 9, 8, 10, 11, 12, 13, 14, 0, 2, 3, 4, 5, 6 });
       for (int i = 0; i < expected.Length; i++) {
@@ -108,7 +108,7 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByMaterialVolumeHeightExtension() {
-      Permutation actual = _items.SortByMaterialVolumeHeight();
-      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 12, 2, 11, 1, 6, 10, 0, 5, 9, 14, 4 });
+    public void TestSortBySequenceGroupVolumeHeight() {
+      Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.VolumeHeight).SortPackingItemsBySequenceGroup(_items, _packingShape);
+      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 10, 0, 5, 11, 1, 6, 7, 12, 2, 8, 13, 3 });
       for (int i = 0; i < expected.Length; i++) {
         Assert.AreEqual(expected[i], actual[i]);
@@ -119,7 +119,7 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByMaterialHeightVolumeExtension() {
-      Permutation actual = _items.SortByMaterialHeightVolume();
-      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 2, 12, 11, 1, 6, 10, 0, 5, 9, 14, 4 });
+    public void TestSortByMaterialHeightVolume() {
+      Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.HeightVolume).SortPackingItemsBySequenceGroup(_items, _packingShape);
+      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 10, 0, 5, 11, 1, 6, 7, 2, 12, 8, 13, 3 });
       for (int i = 0; i < expected.Length; i++) {
         Assert.AreEqual(expected[i], actual[i]);
@@ -131,7 +131,7 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByMaterialAreaHeightExtension() {
-      Permutation actual = _items.SortByMaterialAreaHeight();
-      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 12, 2, 1, 11, 6, 10, 0, 5, 9, 14, 4 });
+    public void TestSortByMaterialAreaHeight() {
+      Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.AreaHeight).SortPackingItemsBySequenceGroup(_items, _packingShape);
+      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 10, 0, 5, 1, 11, 6, 7, 12, 2, 8, 13, 3 });
       for (int i = 0; i < expected.Length; i++) {
         Assert.AreEqual(expected[i], actual[i]);
@@ -143,7 +143,7 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByMaterialHeightAreaExtension() {
-      Permutation actual = _items.SortByMaterialHeightArea();
-      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 2, 12, 11, 1, 6, 10, 0, 5, 9, 14, 4 });
+    public void TestSortByMaterialHeightArea() {
+      Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.HeightArea).SortPackingItemsBySequenceGroup(_items, _packingShape);
+      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 10, 0, 5, 11, 1, 6, 7, 2, 12, 8, 13, 3 });
       for (int i = 0; i < expected.Length; i++) {
         Assert.AreEqual(expected[i], actual[i]);
@@ -154,7 +154,7 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByMaterialClusteredAreaHeightExtension() {
-      Permutation actual = _items.SortByMaterialClusteredAreaHeight(_packingShape, 1.0);
-      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 2, 7, 12, 11, 1, 6, 0, 5, 10, 9, 14, 4 });
+    public void TestSortByMaterialClusteredAreaHeight() {
+      Permutation actual = ((IPackingItemClusteredSorter)PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.ClusteredAreaHeight)).SortPackingItemsBySequenceGroup(_items, _packingShape, 1.0);
+      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 0, 5, 10, 11, 1, 6, 2, 7, 12, 8, 13, 3 });
       for (int i = 0; i < expected.Length; i++) {
         Assert.AreEqual(expected[i], actual[i]);
@@ -165,7 +165,7 @@
     [TestCategory("Problems.BinPacking.3D")]
     [TestProperty("Time", "short")]
-    public void TestSortByMaterialClusteredHeightAreaExtension() {
-      Permutation actual = _items.SortByClusteredHeightArea(_packingShape, 1.0);
-      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 1, 7, 9, 8, 10, 11, 12, 13, 14, 0, 2, 3, 4, 5, 6 });
+    public void TestSortByMaterialClusteredHeightArea() {
+      Permutation actual = ((IPackingItemClusteredSorter)PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.ClusteredHeightArea)).SortPackingItemsBySequenceGroup(_items, _packingShape, 1.0);
+      Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 10, 0, 5, 1, 11, 6, 7, 12, 2, 8, 13, 3});
       for (int i = 0; i < expected.Length; i++) {
         Assert.AreEqual(expected[i], actual[i]);
