Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Sorting/PermutationSortingTest.cs @ 15959

Last change on this file since 15959 was 15959, checked in by rhanghof, 5 years ago

#2817:

  • Refactoring BinPackerFormClosure.cs -> BinPackerWidthBestFit.cs
  • Changes on the unit tests
File size: 7.9 KB
Line 
1using System;
2using Microsoft.VisualStudio.TestTools.UnitTesting;
3using HeuristicLab.Problems.BinPacking3D;
4using System.Collections.Generic;
5using HeuristicLab.Encodings.PermutationEncoding;
6using HeuristicLab.Problems.BinPacking3D.Sorting;
7
8namespace HeuristicLab.Problems.BinPacking._3D.Sorting.Tests {
9  [TestClass]
10  public class PermutationSortingTest {
11    private PackingShape _packingShape;
12    private IList<PackingItem> _items;
13
14    [TestInitialize]
15    public void Initializes() {
16      _packingShape = new PackingShape(20, 20, 20);
17      _items = new List<PackingItem>();
18
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 =  8
21      _items.Add(new PackingItem(10, 10, 8, _packingShape, 1000, 3, 1)); // 2,  V = 800,  A =  80, h = 10
22      _items.Add(new PackingItem(8, 8, 10, _packingShape, 1000, 4, 1)); // 3,   V = 640,  A =  80, h =  8
23      _items.Add(new PackingItem(10, 8, 8, _packingShape, 1000, 0, 1)); // 4,   V = 640,  A =  80, h =  8
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 =  8
26
27      _items.Add(new PackingItem(10, 10, 10, _packingShape, 1000, 3, 1)); // 7, V = 1000, A = 100, h = 10
28
29      _items.Add(new PackingItem(9, 10, 10, _packingShape, 1000, 4, 1)); // 8,  V = 900,  A =  90, h = 10
30      _items.Add(new PackingItem(10, 9, 10, _packingShape, 1000, 0, 1)); // 9,  V = 900,  A = 100, h =  9
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 =  9
33      _items.Add(new PackingItem(10, 9, 9, _packingShape, 1000, 3, 1)); // 12,  V = 810,  A =  90, h =  9
34      _items.Add(new PackingItem(9, 10, 9, _packingShape, 1000, 4, 1)); // 13,  V = 810,  A =  81, h = 10
35      _items.Add(new PackingItem(9, 9, 9, _packingShape, 1000, 0, 1)); // 14,   V = 729,  A =  81, h =  9
36    }
37
38   
39    [TestMethod]
40    [TestCategory("Problems.BinPacking.3D")]
41    [TestProperty("Time", "short")]
42    public void TestSortByVolumeHeightExtension() {
43      Permutation actual = _items.SortByVolumeHeight();
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      for (int i = 0; i < expected.Length; i++) {
46        Assert.AreEqual(expected[i], actual[i]);
47      }
48    }
49   
50    [TestMethod]
51    [TestCategory("Problems.BinPacking.3D")]
52    [TestProperty("Time", "short")]
53    public void TestSortByHeightVolumeExtension() {
54      Permutation actual = _items.SortByHeightVolume();
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      for (int i = 0; i < expected.Length; i++) {
57        Assert.AreEqual(expected[i], actual[i]);
58      }
59    }
60
61   
62    [TestMethod]
63    [TestCategory("Problems.BinPacking.3D")]
64    [TestProperty("Time", "short")]
65    public void TestSortByAreaHeightExtension() {
66      Permutation actual = _items.SortByAreaHeight();
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      for (int i = 0; i < expected.Length; i++) {
69        Assert.AreEqual(expected[i], actual[i]);
70      }
71    }
72   
73
74    [TestMethod]
75    [TestCategory("Problems.BinPacking.3D")]
76    [TestProperty("Time", "short")]
77    public void TestSortByHeightAreaExtension() {
78      Permutation actual = _items.SortByHeightArea();
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      for (int i = 0; i < expected.Length; i++) {
81        Assert.AreEqual(expected[i], actual[i]);
82      }
83    }
84
85    [TestMethod]
86    [TestCategory("Problems.BinPacking.3D")]
87    [TestProperty("Time", "short")]
88    public void TestSortByClusteredAreaHeightExtension() {
89      Permutation actual = _items.SortByClusteredAreaHeight(_packingShape, 1.0);
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      for (int i = 0; i < expected.Length; i++) {
92        Assert.AreEqual(expected[i], actual[i]);
93      }
94    }
95
96    [TestMethod]
97    [TestCategory("Problems.BinPacking.3D")]
98    [TestProperty("Time", "short")]
99    public void TestSortByClusteredHeightAreaExtension() {
100      Permutation actual = _items.SortByClusteredHeightArea(_packingShape, 1.0);
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      for (int i = 0; i < expected.Length; i++) {
103        Assert.AreEqual(expected[i], actual[i]);
104      }
105    }
106
107    [TestMethod]
108    [TestCategory("Problems.BinPacking.3D")]
109    [TestProperty("Time", "short")]
110    public void TestSortByMaterialVolumeHeightExtension() {
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 });
113      for (int i = 0; i < expected.Length; i++) {
114        Assert.AreEqual(expected[i], actual[i]);
115      }
116    }
117
118    [TestMethod]
119    [TestCategory("Problems.BinPacking.3D")]
120    [TestProperty("Time", "short")]
121    public void TestSortByMaterialHeightVolumeExtension() {
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 });
124      for (int i = 0; i < expected.Length; i++) {
125        Assert.AreEqual(expected[i], actual[i]);
126      }
127    }
128
129
130    [TestMethod]
131    [TestCategory("Problems.BinPacking.3D")]
132    [TestProperty("Time", "short")]
133    public void TestSortByMaterialAreaHeightExtension() {
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 });
136      for (int i = 0; i < expected.Length; i++) {
137        Assert.AreEqual(expected[i], actual[i]);
138      }
139    }
140
141
142    [TestMethod]
143    [TestCategory("Problems.BinPacking.3D")]
144    [TestProperty("Time", "short")]
145    public void TestSortByMaterialHeightAreaExtension() {
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 });
148      for (int i = 0; i < expected.Length; i++) {
149        Assert.AreEqual(expected[i], actual[i]);
150      }
151    }
152
153    [TestMethod]
154    [TestCategory("Problems.BinPacking.3D")]
155    [TestProperty("Time", "short")]
156    public void TestSortByMaterialClusteredAreaHeightExtension() {
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 });
159      for (int i = 0; i < expected.Length; i++) {
160        Assert.AreEqual(expected[i], actual[i]);
161      }
162    }
163
164    [TestMethod]
165    [TestCategory("Problems.BinPacking.3D")]
166    [TestProperty("Time", "short")]
167    public void TestSortByMaterialClusteredHeightAreaExtension() {
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 });
170      for (int i = 0; i < expected.Length; i++) {
171        Assert.AreEqual(expected[i], actual[i]);
172      }
173    }   
174  }
175}
Note: See TracBrowser for help on using the repository browser.