Changeset 15989 for branches/2817-BinPackingSpeedup
- Timestamp:
- 07/09/18 12:59:38 (6 years ago)
- Location:
- branches/2817-BinPackingSpeedup
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Algorithms/ExtremePointAlgorithm.cs
r15959 r15989 83 83 84 84 [Storable] 85 private readonly IValueParameter<BoolValue> sortBy MaterialParameter;86 87 public IValueParameter<BoolValue> SortBy MaterialParameter {88 get { return sortBy MaterialParameter; }85 private readonly IValueParameter<BoolValue> sortBySequenceGroupParameter; 86 87 public IValueParameter<BoolValue> SortBySequenceGroupParameter { 88 get { return sortBySequenceGroupParameter; } 89 89 } 90 90 … … 116 116 "Delta", "[1;100]% Clustered sorting methods use a delta parameter to determine the clusters.", new PercentValue(.1))); 117 117 118 Parameters.Add(sortBy MaterialParameter = new ValueParameter<BoolValue>(119 "SortBy Material", "If this parameter is set, the items will be sorted by their materialfirst", new BoolValue(true)));118 Parameters.Add(sortBySequenceGroupParameter = new ValueParameter<BoolValue>( 119 "SortBySequenceGroup", "If this parameter is set, the items will be sorted by their sequence group first", new BoolValue(true))); 120 120 121 121 Problem = new PermutationProblem(); … … 209 209 ExtremePointCreationMethod[] epCreationMethods, 210 210 CancellationToken token) { 211 211 212 SortingMethod? bestSorting = null; 212 213 FittingMethod? bestFitting = null; … … 223 224 Permutation sortedItems; 224 225 225 if (SortByMaterialParameter.Value.Value) { 226 sortedItems = SortItemsByMaterialAndSortingMethod(bin, items, sort, DeltaParameter.Value.Value); 227 } else { 228 sortedItems = SortItemsBySortingMethod(bin, items, sort, DeltaParameter.Value.Value); 229 } 230 226 sortedItems = SortItems(bin, items, sort, DeltaParameter.Value.Value, SortBySequenceGroupParameter.Value.Value); 227 231 228 var solution = Optimize(new OptimaizationParamters() { 232 229 SortedItems = sortedItems, … … 265 262 /// <returns></returns> 266 263 private static Solution Optimize(OptimaizationParamters parameters) { 267 268 264 var sol = parameters.Decoder.Decode(parameters.SortedItems, parameters.Bin, parameters.Items, parameters.StackingConstraints); 269 265 … … 281 277 } 282 278 283 /// <summary> 284 /// Returns a new permutation of the given items depending on the sorting method 285 /// </summary> 286 /// <param name="bin"></param> 287 /// <param name="items"></param> 288 /// <param name="sortingMethod"></param> 289 /// <param name="delta"></param> 290 /// <returns></returns> 291 private Permutation SortItemsByMaterialAndSortingMethod(PackingShape bin, IList<PackingItem> items, SortingMethod sortingMethod, double delta) { 292 Permutation sorted = null; 293 294 switch (sortingMethod) { 295 case SortingMethod.Given: 296 sorted = new Permutation(PermutationTypes.Absolute, Enumerable.Range(0, items.Count).ToArray()); 297 break; 298 case SortingMethod.VolumeHeight: 299 sorted = items.SortByVolumeHeight(); 300 break; 301 case SortingMethod.HeightVolume: 302 sorted = items.SortByMaterialHeightVolume(); 303 break; 304 case SortingMethod.AreaHeight: 305 sorted = items.SortByMaterialAreaHeight(); 306 break; 307 case SortingMethod.HeightArea: 308 sorted = items.SortByMaterialHeightArea(); 309 break; 310 case SortingMethod.ClusteredAreaHeight: 311 sorted = items.SortByMaterialClusteredAreaHeight(bin, delta); 312 break; 313 case SortingMethod.ClusteredHeightArea: 314 sorted = items.SortByMaterialClusteredHeightArea(bin, delta); 315 break; 316 default: 317 throw new ArgumentException("Unknown sorting method: " + sortingMethod); 318 } 319 return sorted; 320 } 321 322 /// <summary> 323 /// Returns a new permutation of the given items depending on the material and sorting method 324 /// </summary> 325 /// <param name="bin"></param> 326 /// <param name="items"></param> 327 /// <param name="sortingMethod"></param> 328 /// <param name="delta"></param> 329 /// <returns></returns> 330 private Permutation SortItemsBySortingMethod(PackingShape bin, IList<PackingItem> items, SortingMethod sortingMethod, double delta) { 331 Permutation sorted = null; 332 333 switch (sortingMethod) { 334 case SortingMethod.Given: 335 sorted = new Permutation(PermutationTypes.Absolute, Enumerable.Range(0, items.Count).ToArray()); 336 break; 337 case SortingMethod.VolumeHeight: 338 sorted = items.SortByVolumeHeight(); 339 break; 340 case SortingMethod.HeightVolume: 341 sorted = items.SortByHeightVolume(); 342 break; 343 case SortingMethod.AreaHeight: 344 sorted = items.SortByAreaHeight(); 345 break; 346 case SortingMethod.HeightArea: 347 sorted = items.SortByHeightArea(); 348 break; 349 case SortingMethod.ClusteredAreaHeight: 350 sorted = items.SortByClusteredAreaHeight(bin, delta); 351 break; 352 case SortingMethod.ClusteredHeightArea: 353 sorted = items.SortByClusteredHeightArea(bin, delta); 354 break; 355 default: 356 throw new ArgumentException("Unknown sorting method: " + sortingMethod); 357 } 358 return sorted; 359 } 279 280 private Permutation SortItems(PackingShape bin, IList<PackingItem> items, SortingMethod sortingMethod, double delta, bool sortBySequenceGroup) { 281 Permutation sortedItems; 282 283 var sorter = PackingItemSorterFactory.CreatePackingItemSorter(sortingMethod); 284 if (sorter is IPackingItemClusteredSorter) { 285 if (sortBySequenceGroup) { 286 sortedItems = (sorter as IPackingItemClusteredSorter).SortPackingItemsBySequenceGroup(items, bin, delta); 287 } else { 288 sortedItems = (sorter as IPackingItemClusteredSorter).SortPackingItems(items, bin, delta); 289 } 290 } else { 291 if (sortBySequenceGroup) { 292 sortedItems = sorter.SortPackingItemsBySequenceGroup(items, bin); 293 } else { 294 sortedItems = sorter.SortPackingItems(items, bin); 295 } 296 } 297 return sortedItems; 298 } 360 299 } 361 300 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Instances/RandomInstanceProvider.cs
r15617 r15989 198 198 protected virtual void SampleItemParameters(IRandom rand, out int w, out int h, out int d) { 199 199 Contract.Assert(@class >= 1 && @class <= 5); 200 /*var weights = new double[] { 0.1, 0.1, 0.1, 0.1, 0.1 };200 var weights = new double[] { 0.1, 0.1, 0.1, 0.1, 0.1 }; 201 201 weights[@class - 1] = 0.6; 202 202 var type = Enumerable.Range(1, 5).SampleProportional(rand, 1, weights).First(); 203 */204 205 // as by Martello and Vigo206 int type = @class;207 if (type <= 5) {208 var t = rand.Next(1, 10);209 if (t <= 5) {210 type = t;211 }212 }213 203 214 204 switch (type) { -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPackerResidualSpaceBestFit.cs
r15820 r15989 104 104 foreach (var extremPoints in bp.ExtremePoints) { 105 105 var ep = extremPoints.Key; 106 var residualSpaces = extremPoints.Value.Where(rs => rs.Width < item.Width || rs.Height < item.Height || rs.Depth <item.Depth);106 var residualSpaces = extremPoints.Value.Where(rs => rs.Width >= item.Width && rs.Height >= item.Height && rs.Depth >= item.Depth); 107 107 if (residualSpaces.Count() <= 0) { 108 108 continue; -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/IPackingItemClusteredSorter.cs
r15646 r15989 31 31 Permutation SortPackingItems(IList<PackingItem> items, PackingShape bin, double delta); 32 32 33 Permutation SortPackingItemsBy Material(IList<PackingItem> items, PackingShape bin, double delta);33 Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin, double delta); 34 34 35 35 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/IPackingItemSorter.cs
r15618 r15989 32 32 Permutation SortPackingItems(IList<PackingItem> items, PackingShape bin); 33 33 34 Permutation SortPackingItemsBy Material(IList<PackingItem> items, PackingShape bin);34 Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin); 35 35 } 36 36 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemAreaHeightSorter.cs
r15646 r15989 34 34 } 35 35 36 public Permutation SortPackingItemsBy Material(IList<PackingItem> items, PackingShape bin) {36 public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) { 37 37 return items.SortByMaterialAreaHeight(); 38 38 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemClusterdHeightAreaSorter.cs
r15618 r15989 38 38 } 39 39 40 public Permutation SortPackingItemsBy Material(IList<PackingItem> items, PackingShape bin, double delta) {40 public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin, double delta) { 41 41 return items.SortByMaterialClusteredHeightArea(bin, delta); 42 42 } 43 43 44 public Permutation SortPackingItemsBy Material(IList<PackingItem> items, PackingShape bin) {45 return SortPackingItemsBy Material(items, bin, 10.0);44 public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) { 45 return SortPackingItemsBySequenceGroup(items, bin, 10.0); 46 46 } 47 47 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemClusteredAreaHeightSorter.cs
r15618 r15989 38 38 } 39 39 40 public Permutation SortPackingItemsBy Material(IList<PackingItem> items, PackingShape bin, double delta) {40 public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin, double delta) { 41 41 return items.SortByMaterialClusteredAreaHeight(bin, delta); 42 42 } 43 43 44 public Permutation SortPackingItemsBy Material(IList<PackingItem> items, PackingShape bin) {45 return SortPackingItemsBy Material(items, bin, 10.0);44 public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) { 45 return SortPackingItemsBySequenceGroup(items, bin, 10.0); 46 46 } 47 47 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemGivenSorter.cs
r15618 r15989 34 34 } 35 35 36 public Permutation SortPackingItemsBy Material(IList<PackingItem> items, PackingShape bin) {36 public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) { 37 37 return new Permutation(PermutationTypes.Absolute, Enumerable.Range(0, items.Count).ToArray()); 38 38 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemHeightAreaSorter.cs
r15618 r15989 34 34 } 35 35 36 public Permutation SortPackingItemsBy Material(IList<PackingItem> items, PackingShape bin) {36 public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) { 37 37 return items.SortByMaterialHeightArea(); 38 38 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemHeightVolumeSorter.cs
r15646 r15989 34 34 } 35 35 36 public Permutation SortPackingItemsBy Material(IList<PackingItem> items, PackingShape bin) {36 public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) { 37 37 return items.SortByMaterialHeightVolume(); 38 38 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PackingItemVolumeHeightSorter.cs
r15618 r15989 34 34 } 35 35 36 public Permutation SortPackingItemsBy Material(IList<PackingItem> items, PackingShape bin) {36 public Permutation SortPackingItemsBySequenceGroup(IList<PackingItem> items, PackingShape bin) { 37 37 return items.SortByMaterialVolumeHeight(); 38 38 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Algorithms/ExtremePointAlgorithmTest.cs
r15959 r15989 83 83 _extremPointAlgorithm.FittingMethodParameter.Value.Value = FittingMethod.FirstFit; 84 84 _extremPointAlgorithm.ExtremePointCreationMethodParameter.Value.Value = ExtremePointCreationMethod.PointProjection; 85 _extremPointAlgorithm.SortBy MaterialParameter.Value.Value = false;85 _extremPointAlgorithm.SortBySequenceGroupParameter.Value.Value = false; 86 86 var result = TestUtils.InvokeMethod(typeof(ExtremePointAlgorithm), _extremPointAlgorithm, "GetBest", parameters) as Tuple<Solution, double, SortingMethod?, FittingMethod?, ExtremePointCreationMethod?>; 87 87 -
branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Instances/RandomInstanceProviderTest.cs
r15959 r15989 17 17 public int Height { get; set; } 18 18 public int Depth { get; set; } 19 } 20 21 #region TestRandomInstanceProvider 22 23 24 /// <summary> 25 /// Tests if the generated random instance equals to the references generated by david pisinger 26 /// http://www.diku.dk/~pisinger/new3dbpp/test3dbpp.c 27 /// </summary> 28 [TestMethod] 29 [TestCategory("Problems.BinPacking.3D")] 30 [TestProperty("Time", "long")] 31 public void TestRandomInstanceProvider() { 32 33 var referenceItemLists = ReadReferenceItemLists(); 34 TestRandomInstanceProviderByClass(new RandomInstanceClass1Provider(), referenceItemLists); 35 TestRandomInstanceProviderByClass(new RandomInstanceClass2Provider(), referenceItemLists); 36 TestRandomInstanceProviderByClass(new RandomInstanceClass3Provider(), referenceItemLists); 37 TestRandomInstanceProviderByClass(new RandomInstanceClass4Provider(), referenceItemLists); 38 TestRandomInstanceProviderByClass(new RandomInstanceClass5Provider(), referenceItemLists); 39 TestRandomInstanceProviderByClass(new RandomInstanceClass6Provider(), referenceItemLists); 40 TestRandomInstanceProviderByClass(new RandomInstanceClass7Provider(), referenceItemLists); 41 TestRandomInstanceProviderByClass(new RandomInstanceClass8Provider(), referenceItemLists); 42 43 } 44 45 private IDictionary<string, List<Dimension>> ReadReferenceItemLists() { 46 var itemList = new Dictionary<string, List<Dimension>>(); 47 string path = @".\..\HeuristicLab.Tests\HeuristicLab.Problems.Bin-Packing-3.3\TestInstances\ReferenceInstances"; 48 49 string[] files = Directory.GetFiles(path); 50 foreach (string filePath in files) { 51 string key = Path.GetFileNameWithoutExtension(filePath); 52 53 using (StreamReader reader = new StreamReader(filePath)) { 54 int lineNumber = 1; 55 List<Dimension> dimensionList = new List<Dimension>(); 56 while (!reader.EndOfStream) { 57 string line = reader.ReadLine(); 58 if (lineNumber > 2) { 59 string[] lineValues = line.Split('\t'); 60 int id; 61 int depth; 62 int width; 63 int height; 64 Int32.TryParse(lineValues[0], out id); 65 Int32.TryParse(lineValues[1], out depth); 66 Int32.TryParse(lineValues[2], out width); 67 Int32.TryParse(lineValues[3], out height); 68 dimensionList.Add(new Dimension() { 69 Id = id, 70 Depth = depth, 71 Width = width, 72 Height = height 73 }); 74 } 75 lineNumber++; 76 } 77 itemList.Add(key, dimensionList); 78 } 79 } 80 return itemList; 81 } 82 83 private void TestRandomInstanceProviderByClass(RandomInstanceProvider randomInstanceProvider, IDictionary<string, List<Dimension>> referenceItems) { 84 85 var dataDescriptors = randomInstanceProvider.GetDataDescriptors(); 86 foreach (var dataDescriptor in dataDescriptors) { 87 List<Dimension> testItemDimensions = null; 88 if (referenceItems.TryGetValue(dataDescriptor.Name, out testItemDimensions)) { 89 var packingItems = randomInstanceProvider.LoadData(dataDescriptor).Items; 90 Assert.IsNotNull(packingItems); 91 Assert.AreEqual(testItemDimensions.Count, packingItems.Length); 92 for (int i = 0; i < packingItems.Length; i++) { 93 Assert.AreEqual(testItemDimensions[i].Width, packingItems[i].Width); 94 Assert.AreEqual(testItemDimensions[i].Height, packingItems[i].Height); 95 Assert.AreEqual(testItemDimensions[i].Depth, packingItems[i].Depth); 96 } 97 } 98 } 99 } 100 #endregion 19 } 101 20 102 21 #region TestExtremePointAlgorithm … … 198 117 algorithm.FittingMethodParameter.Value.Value = fittingMethod; 199 118 algorithm.ExtremePointCreationMethodParameter.Value.Value = epCreationMethod; 200 algorithm.SortBy MaterialParameter.Value.Value = false;119 algorithm.SortBySequenceGroupParameter.Value.Value = false; 201 120 202 121 algorithm.Problem.UseStackingConstraintsParameter.Value.Value = false; -
branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Instances/ThreeDInstanceParserTest.cs
r15959 r15989 19 19 20 20 _items1.Add(new PackingItem(8, 10, 10, _packingShape, 800, 1, 1)); // 0, V = 800, A = 80, h = 10 21 _items1.Add(new PackingItem(10, 8, 10, _packingShape, 800, 2, 1)); // 1, V = 800, A = 100, h = 822 _items1.Add(new PackingItem(10, 10, 8, _packingShape, 800, 3, 1)); // 2, V = 800, A = 80, h = 1023 _items1.Add(new PackingItem(8, 8, 10, _packingShape, 640, 4, 1)); // 3, V = 640, A = 80, h = 824 _items1.Add(new PackingItem(10, 8, 8, _packingShape, 640, 0, 1)); // 4, V = 640, A = 80, h = 821 _items1.Add(new PackingItem(10, 8, 10, _packingShape, 800, 2, 2)); // 1, V = 800, A = 100, h = 8 22 _items1.Add(new PackingItem(10, 10, 8, _packingShape, 800, 3, 3)); // 2, V = 800, A = 80, h = 10 23 _items1.Add(new PackingItem(8, 8, 10, _packingShape, 640, 4, 4)); // 3, V = 640, A = 80, h = 8 24 _items1.Add(new PackingItem(10, 8, 8, _packingShape, 640, 0, 0)); // 4, V = 640, A = 80, h = 8 25 25 _items1.Add(new PackingItem(8, 10, 8, _packingShape, 640, 1, 1)); // 5, V = 640, A = 64, h = 10 26 _items1.Add(new PackingItem(8, 8, 8, _packingShape, 512, 2, 1)); // 6, V = 512, A = 64, h = 826 _items1.Add(new PackingItem(8, 8, 8, _packingShape, 512, 2, 2)); // 6, V = 512, A = 64, h = 8 27 27 28 _items1.Add(new PackingItem(10, 10, 10, _packingShape,1000,3, 1)); // 7, V = 1000, A = 100, h = 1028 _items1.Add(new PackingItem(10, 10, 10, _packingShape,1000,3, 3)); // 7, V = 1000, A = 100, h = 10 29 29 30 _items1.Add(new PackingItem(9, 10, 10, _packingShape, 900, 4, 1)); // 8, V = 900, A = 90, h = 1031 _items1.Add(new PackingItem(10, 9, 10, _packingShape, 900, 0, 1)); // 9, V = 900, A = 100, h = 930 _items1.Add(new PackingItem(9, 10, 10, _packingShape, 900, 4, 4)); // 8, V = 900, A = 90, h = 10 31 _items1.Add(new PackingItem(10, 9, 10, _packingShape, 900, 0, 0)); // 9, V = 900, A = 100, h = 9 32 32 _items1.Add(new PackingItem(10, 10, 9, _packingShape, 900, 1, 1)); // 10, V = 900, A = 90, h = 10 33 _items1.Add(new PackingItem(9, 9, 10, _packingShape, 810, 2, 1)); // 11, V = 810, A = 90, h = 934 _items1.Add(new PackingItem(10, 9, 9, _packingShape, 810, 3, 1)); // 12, V = 810, A = 90, h = 935 _items1.Add(new PackingItem(9, 10, 9, _packingShape, 810, 4, 1)); // 13, V = 810, A = 81, h = 1036 _items1.Add(new PackingItem(9, 9, 9, _packingShape, 729, 0, 1)); // 14, V = 729, A = 81, h = 933 _items1.Add(new PackingItem(9, 9, 10, _packingShape, 810, 2, 2)); // 11, V = 810, A = 90, h = 9 34 _items1.Add(new PackingItem(10, 9, 9, _packingShape, 810, 3, 3)); // 12, V = 810, A = 90, h = 9 35 _items1.Add(new PackingItem(9, 10, 9, _packingShape, 810, 4, 4)); // 13, V = 810, A = 81, h = 10 36 _items1.Add(new PackingItem(9, 9, 9, _packingShape, 729, 0, 0)); // 14, V = 729, A = 81, h = 9 37 37 38 38 _items2 = new List<PackingItem>(); 39 39 _items2.Add(new PackingItem(8, 10, 10, _packingShape, 800, 1, 1)); // 0, V = 800, A = 80, h = 10 40 _items2.Add(new PackingItem(10, 8, 10, _packingShape, 800, 2, 1)); // 1, V = 800, A = 100, h = 841 _items2.Add(new PackingItem(10, 10, 8, _packingShape, 800, 3, 1)); // 2, V = 800, A = 80, h = 1042 _items2.Add(new PackingItem(8, 8, 10, _packingShape, 640, 4, 1)); // 3, V = 640, A = 80, h = 843 _items2.Add(new PackingItem(10, 8, 8, _packingShape, 640, 0, 1)); // 4, V = 640, A = 80, h = 840 _items2.Add(new PackingItem(10, 8, 10, _packingShape, 800, 2, 2)); // 1, V = 800, A = 100, h = 8 41 _items2.Add(new PackingItem(10, 10, 8, _packingShape, 800, 3, 3)); // 2, V = 800, A = 80, h = 10 42 _items2.Add(new PackingItem(8, 8, 10, _packingShape, 640, 4, 4)); // 3, V = 640, A = 80, h = 8 43 _items2.Add(new PackingItem(10, 8, 8, _packingShape, 640, 0, 0)); // 4, V = 640, A = 80, h = 8 44 44 _items2.Add(new PackingItem(8, 10, 8, _packingShape, 640, 1, 1)); // 5, V = 640, A = 64, h = 10 45 45 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Sorting/PermutationSortingTest.cs
r15959 r15989 18 18 19 19 _items.Add(new PackingItem(8, 10, 10, _packingShape, 1000, 1, 1)); // 0, V = 800, A = 80, h = 10 20 _items.Add(new PackingItem(10, 8, 10, _packingShape, 1000, 2, 1)); // 1, V = 800, A = 100, h = 821 _items.Add(new PackingItem(10, 10, 8, _packingShape, 1000, 3, 1)); // 2, V = 800, A = 80, h = 1022 _items.Add(new PackingItem(8, 8, 10, _packingShape, 1000, 4, 1)); // 3, V = 640, A = 80, h = 823 _items.Add(new PackingItem(10, 8, 8, _packingShape, 1000, 0, 1)); // 4, V = 640, A = 80, h = 820 _items.Add(new PackingItem(10, 8, 10, _packingShape, 1000, 2, 2)); // 1, V = 800, A = 100, h = 8 21 _items.Add(new PackingItem(10, 10, 8, _packingShape, 1000, 3, 3)); // 2, V = 800, A = 80, h = 10 22 _items.Add(new PackingItem(8, 8, 10, _packingShape, 1000, 4, 4)); // 3, V = 640, A = 80, h = 8 23 _items.Add(new PackingItem(10, 8, 8, _packingShape, 1000, 0, 0)); // 4, V = 640, A = 80, h = 8 24 24 _items.Add(new PackingItem(8, 10, 8, _packingShape, 1000, 1, 1)); // 5, V = 640, A = 64, h = 10 25 _items.Add(new PackingItem(8, 8, 8, _packingShape, 1000, 2, 1)); // 6, V = 512, A = 64, h = 825 _items.Add(new PackingItem(8, 8, 8, _packingShape, 1000, 2, 2)); // 6, V = 512, A = 64, h = 8 26 26 27 _items.Add(new PackingItem(10, 10, 10, _packingShape, 1000, 3, 1)); // 7, V = 1000, A = 100, h = 1027 _items.Add(new PackingItem(10, 10, 10, _packingShape, 1000, 3, 3)); // 7, V = 1000, A = 100, h = 10 28 28 29 _items.Add(new PackingItem(9, 10, 10, _packingShape, 1000, 4, 1)); // 8, V = 900, A = 90, h = 1030 _items.Add(new PackingItem(10, 9, 10, _packingShape, 1000, 0, 1)); // 9, V = 900, A = 100, h = 929 _items.Add(new PackingItem(9, 10, 10, _packingShape, 1000, 4, 4)); // 8, V = 900, A = 90, h = 10 30 _items.Add(new PackingItem(10, 9, 10, _packingShape, 1000, 0, 0)); // 9, V = 900, A = 100, h = 9 31 31 _items.Add(new PackingItem(10, 10, 9, _packingShape, 1000, 1, 1)); // 10, V = 900, A = 90, h = 10 32 _items.Add(new PackingItem(9, 9, 10, _packingShape, 1000, 2, 1)); // 11, V = 810, A = 90, h = 933 _items.Add(new PackingItem(10, 9, 9, _packingShape, 1000, 3, 1)); // 12, V = 810, A = 90, h = 934 _items.Add(new PackingItem(9, 10, 9, _packingShape, 1000, 4, 1)); // 13, V = 810, A = 81, h = 1035 _items.Add(new PackingItem(9, 9, 9, _packingShape, 1000, 0, 1)); // 14, V = 729, A = 81, h = 932 _items.Add(new PackingItem(9, 9, 10, _packingShape, 1000, 2, 2)); // 11, V = 810, A = 90, h = 9 33 _items.Add(new PackingItem(10, 9, 9, _packingShape, 1000, 3, 3)); // 12, V = 810, A = 90, h = 9 34 _items.Add(new PackingItem(9, 10, 9, _packingShape, 1000, 4, 4)); // 13, V = 810, A = 81, h = 10 35 _items.Add(new PackingItem(9, 9, 9, _packingShape, 1000, 0, 0)); // 14, V = 729, A = 81, h = 9 36 36 } 37 37 … … 40 40 [TestCategory("Problems.BinPacking.3D")] 41 41 [TestProperty("Time", "short")] 42 public void TestSortByVolumeHeight Extension() {43 Permutation actual = _items.SortByVolumeHeight();42 public void TestSortByVolumeHeight() { 43 Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.VolumeHeight).SortPackingItems(_items, _packingShape); 44 44 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7, 8, 10, 9, 13, 11, 12, 0, 2, 1, 14, 5, 3, 4, 6}); 45 45 for (int i = 0; i < expected.Length; i++) { … … 51 51 [TestCategory("Problems.BinPacking.3D")] 52 52 [TestProperty("Time", "short")] 53 public void TestSortByHeightVolume Extension() {54 Permutation actual = _items.SortByHeightVolume();53 public void TestSortByHeightVolume() { 54 Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.HeightVolume).SortPackingItems(_items, _packingShape); 55 55 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7, 8, 10, 13, 0, 2, 5, 9, 11, 12, 14, 1, 3, 4, 6 }); 56 56 for (int i = 0; i < expected.Length; i++) { … … 63 63 [TestCategory("Problems.BinPacking.3D")] 64 64 [TestProperty("Time", "short")] 65 public void TestSortByAreaHeight Extension() {66 Permutation actual = _items.SortByAreaHeight();65 public void TestSortByAreaHeight() { 66 Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.AreaHeight).SortPackingItems(_items, _packingShape); 67 67 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7, 9, 1, 8, 10, 11, 12, 13, 14, 0, 2, 3, 4, 5, 6}); 68 68 for (int i = 0; i < expected.Length; i++) { … … 75 75 [TestCategory("Problems.BinPacking.3D")] 76 76 [TestProperty("Time", "short")] 77 public void TestSortByHeightArea Extension() {78 Permutation actual = _items.SortByHeightArea();77 public void TestSortByHeightArea() { 78 Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.HeightArea).SortPackingItems(_items, _packingShape); 79 79 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7, 8, 10, 13, 0, 2, 5, 9, 11, 12, 14, 1, 3, 4, 6}); 80 80 for (int i = 0; i < expected.Length; i++) { … … 86 86 [TestCategory("Problems.BinPacking.3D")] 87 87 [TestProperty("Time", "short")] 88 public void TestSortByClusteredAreaHeight Extension() {89 Permutation actual = _items.SortByClusteredAreaHeight(_packingShape, 1.0);88 public void TestSortByClusteredAreaHeight() { 89 Permutation actual = ((IPackingItemClusteredSorter)PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.ClusteredAreaHeight)).SortPackingItems(_items, _packingShape, 1.0); 90 90 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 0, 2, 5, 7, 8, 10, 13, 9, 11, 12, 14, 1, 3, 4, 6 }); 91 91 for (int i = 0; i < expected.Length; i++) { … … 97 97 [TestCategory("Problems.BinPacking.3D")] 98 98 [TestProperty("Time", "short")] 99 public void TestSortByClusteredHeightArea Extension() {100 Permutation actual = _items.SortByClusteredHeightArea(_packingShape, 1.0);99 public void TestSortByClusteredHeightArea() { 100 Permutation actual = ((IPackingItemClusteredSorter)PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.ClusteredHeightArea)).SortPackingItems(_items, _packingShape, 1.0); 101 101 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 1, 7, 9, 8, 10, 11, 12, 13, 14, 0, 2, 3, 4, 5, 6 }); 102 102 for (int i = 0; i < expected.Length; i++) { … … 108 108 [TestCategory("Problems.BinPacking.3D")] 109 109 [TestProperty("Time", "short")] 110 public void TestSortBy MaterialVolumeHeightExtension() {111 Permutation actual = _items.SortByMaterialVolumeHeight();112 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 12, 2, 11, 1, 6, 10, 0, 5, 9, 14, 4});110 public void TestSortBySequenceGroupVolumeHeight() { 111 Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.VolumeHeight).SortPackingItemsBySequenceGroup(_items, _packingShape); 112 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 10, 0, 5, 11, 1, 6, 7, 12, 2, 8, 13, 3 }); 113 113 for (int i = 0; i < expected.Length; i++) { 114 114 Assert.AreEqual(expected[i], actual[i]); … … 119 119 [TestCategory("Problems.BinPacking.3D")] 120 120 [TestProperty("Time", "short")] 121 public void TestSortByMaterialHeightVolume Extension() {122 Permutation actual = _items.SortByMaterialHeightVolume();123 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 2, 12, 11, 1, 6, 10, 0, 5, 9, 14, 4});121 public void TestSortByMaterialHeightVolume() { 122 Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.HeightVolume).SortPackingItemsBySequenceGroup(_items, _packingShape); 123 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 10, 0, 5, 11, 1, 6, 7, 2, 12, 8, 13, 3 }); 124 124 for (int i = 0; i < expected.Length; i++) { 125 125 Assert.AreEqual(expected[i], actual[i]); … … 131 131 [TestCategory("Problems.BinPacking.3D")] 132 132 [TestProperty("Time", "short")] 133 public void TestSortByMaterialAreaHeight Extension() {134 Permutation actual = _items.SortByMaterialAreaHeight();135 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 12, 2, 1, 11, 6, 10, 0, 5, 9, 14, 4});133 public void TestSortByMaterialAreaHeight() { 134 Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.AreaHeight).SortPackingItemsBySequenceGroup(_items, _packingShape); 135 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 10, 0, 5, 1, 11, 6, 7, 12, 2, 8, 13, 3 }); 136 136 for (int i = 0; i < expected.Length; i++) { 137 137 Assert.AreEqual(expected[i], actual[i]); … … 143 143 [TestCategory("Problems.BinPacking.3D")] 144 144 [TestProperty("Time", "short")] 145 public void TestSortByMaterialHeightArea Extension() {146 Permutation actual = _items.SortByMaterialHeightArea();147 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 2, 12, 11, 1, 6, 10, 0, 5, 9, 14, 4});145 public void TestSortByMaterialHeightArea() { 146 Permutation actual = PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.HeightArea).SortPackingItemsBySequenceGroup(_items, _packingShape); 147 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 10, 0, 5, 11, 1, 6, 7, 2, 12, 8, 13, 3 }); 148 148 for (int i = 0; i < expected.Length; i++) { 149 149 Assert.AreEqual(expected[i], actual[i]); … … 154 154 [TestCategory("Problems.BinPacking.3D")] 155 155 [TestProperty("Time", "short")] 156 public void TestSortByMaterialClusteredAreaHeight Extension() {157 Permutation actual = _items.SortByMaterialClusteredAreaHeight(_packingShape, 1.0);158 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 2, 7, 12, 11, 1, 6, 0, 5, 10, 9, 14, 4});156 public void TestSortByMaterialClusteredAreaHeight() { 157 Permutation actual = ((IPackingItemClusteredSorter)PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.ClusteredAreaHeight)).SortPackingItemsBySequenceGroup(_items, _packingShape, 1.0); 158 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 0, 5, 10, 11, 1, 6, 2, 7, 12, 8, 13, 3 }); 159 159 for (int i = 0; i < expected.Length; i++) { 160 160 Assert.AreEqual(expected[i], actual[i]); … … 165 165 [TestCategory("Problems.BinPacking.3D")] 166 166 [TestProperty("Time", "short")] 167 public void TestSortByMaterialClusteredHeightArea Extension() {168 Permutation actual = _items.SortByClusteredHeightArea(_packingShape, 1.0);169 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 1, 7, 9, 8, 10, 11, 12, 13, 14, 0, 2, 3, 4, 5, 6});167 public void TestSortByMaterialClusteredHeightArea() { 168 Permutation actual = ((IPackingItemClusteredSorter)PackingItemSorterFactory.CreatePackingItemSorter(SortingMethod.ClusteredHeightArea)).SortPackingItemsBySequenceGroup(_items, _packingShape, 1.0); 169 Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 9, 14, 4, 10, 0, 5, 1, 11, 6, 7, 12, 2, 8, 13, 3}); 170 170 for (int i = 0; i < expected.Length; i++) { 171 171 Assert.AreEqual(expected[i], actual[i]);
Note: See TracChangeset
for help on using the changeset viewer.