1 | using System;
|
---|
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
3 | using HeuristicLab.Problems.BinPacking3D;
|
---|
4 | using System.Collections.Generic;
|
---|
5 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
6 | using HeuristicLab.Problems.BinPacking3D.Sorting;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.Problems.BinPacking._3D.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)); // 0, V = 800, A = 80, h = 10
|
---|
20 | _items.Add(new PackingItem(10, 8, 10, _packingShape, 1000, 2)); // 1, V = 800, A = 100, h = 8
|
---|
21 | _items.Add(new PackingItem(10, 10, 8, _packingShape, 1000, 3)); // 2, V = 800, A = 80, h = 10
|
---|
22 | _items.Add(new PackingItem(8, 8, 10, _packingShape, 1000, 4)); // 3, V = 640, A = 80, h = 8
|
---|
23 | _items.Add(new PackingItem(10, 8, 8, _packingShape, 1000, 0)); // 4, V = 640, A = 80, h = 8
|
---|
24 | _items.Add(new PackingItem(8, 10, 8, _packingShape, 1000, 1)); // 5, V = 640, A = 64, h = 10
|
---|
25 | _items.Add(new PackingItem(8, 8, 8, _packingShape, 1000, 2)); // 6, V = 512, A = 64, h = 8
|
---|
26 |
|
---|
27 | _items.Add(new PackingItem(10, 10, 10, _packingShape, 1000, 3)); // 7, V = 1000, A = 100, h = 10
|
---|
28 |
|
---|
29 | _items.Add(new PackingItem(9, 10, 10, _packingShape, 1000, 4)); // 8, V = 900, A = 90, h = 10
|
---|
30 | _items.Add(new PackingItem(10, 9, 10, _packingShape, 1000, 0)); // 9, V = 900, A = 100, h = 9
|
---|
31 | _items.Add(new PackingItem(10, 10, 9, _packingShape, 1000, 1)); // 10, V = 900, A = 90, h = 10
|
---|
32 | _items.Add(new PackingItem(9, 9, 10, _packingShape, 1000, 2)); // 11, V = 810, A = 90, h = 9
|
---|
33 | _items.Add(new PackingItem(10, 9, 9, _packingShape, 1000, 3)); // 12, V = 810, A = 90, h = 9
|
---|
34 | _items.Add(new PackingItem(9, 10, 9, _packingShape, 1000, 4)); // 13, V = 810, A = 81, h = 10
|
---|
35 | _items.Add(new PackingItem(9, 9, 9, _packingShape, 1000, 0)); // 14, V = 729, A = 81, h = 9
|
---|
36 | }
|
---|
37 |
|
---|
38 |
|
---|
39 | [TestMethod]
|
---|
40 | [TestCategory("Problems.BinPacking.3D")]
|
---|
41 | public void TestSortByVolumeHeightExtension() {
|
---|
42 | Permutation actual = _items.SortByVolumeHeight();
|
---|
43 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7, 8, 10, 9, 13, 11, 12, 0, 2, 1, 14, 5, 3, 4, 6});
|
---|
44 | for (int i = 0; i < expected.Length; i++) {
|
---|
45 | Assert.AreEqual(expected[i], actual[i]);
|
---|
46 | }
|
---|
47 | }
|
---|
48 |
|
---|
49 | [TestMethod]
|
---|
50 | [TestCategory("Problems.BinPacking.3D")]
|
---|
51 | public void TestSortByHeightVolumeExtension() {
|
---|
52 | Permutation actual = _items.SortByHeightVolume();
|
---|
53 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7, 8, 10, 13, 0, 2, 5, 9, 11, 12, 14, 1, 3, 4, 6 });
|
---|
54 | for (int i = 0; i < expected.Length; i++) {
|
---|
55 | Assert.AreEqual(expected[i], actual[i]);
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 |
|
---|
60 | [TestMethod]
|
---|
61 | [TestCategory("Problems.BinPacking.3D")]
|
---|
62 | public void TestSortByAreaHeightExtension() {
|
---|
63 | Permutation actual = _items.SortByAreaHeight();
|
---|
64 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7, 9, 1, 8, 10, 11, 12, 13, 14, 0, 2, 3, 4, 5, 6});
|
---|
65 | for (int i = 0; i < expected.Length; i++) {
|
---|
66 | Assert.AreEqual(expected[i], actual[i]);
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 |
|
---|
71 | [TestMethod]
|
---|
72 | [TestCategory("Problems.BinPacking.3D")]
|
---|
73 | public void TestSortByHeightAreaExtension() {
|
---|
74 | Permutation actual = _items.SortByHeightArea();
|
---|
75 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 7, 8, 10, 13, 0, 2, 5, 9, 11, 12, 14, 1, 3, 4, 6});
|
---|
76 | for (int i = 0; i < expected.Length; i++) {
|
---|
77 | Assert.AreEqual(expected[i], actual[i]);
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | [TestMethod]
|
---|
82 | [TestCategory("Problems.BinPacking.3D")]
|
---|
83 | public void TestSortByClusteredAreaHeightExtension() {
|
---|
84 | Permutation actual = _items.SortByClusteredAreaHeight(_packingShape, 1.0);
|
---|
85 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 0, 2, 5, 7, 8, 10, 13, 9, 11, 12, 14, 1, 3, 4, 6 });
|
---|
86 | for (int i = 0; i < expected.Length; i++) {
|
---|
87 | Assert.AreEqual(expected[i], actual[i]);
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | [TestMethod]
|
---|
92 | [TestCategory("Problems.BinPacking.3D")]
|
---|
93 | public void TestSortByClusteredHeightAreaExtension() {
|
---|
94 | Permutation actual = _items.SortByClusteredHeightArea(_packingShape, 1.0);
|
---|
95 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 1, 7, 9, 8, 10, 11, 12, 13, 14, 0, 2, 3, 4, 5, 6 });
|
---|
96 | for (int i = 0; i < expected.Length; i++) {
|
---|
97 | Assert.AreEqual(expected[i], actual[i]);
|
---|
98 | }
|
---|
99 | }
|
---|
100 |
|
---|
101 | [TestMethod]
|
---|
102 | [TestCategory("Problems.BinPacking.3D")]
|
---|
103 | public void TestSortByMaterialVolumeHeightExtension() {
|
---|
104 | Permutation actual = _items.SortByMaterialVolumeHeight();
|
---|
105 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 12, 2, 11, 1, 6, 10, 0, 5, 9, 14, 4 });
|
---|
106 | for (int i = 0; i < expected.Length; i++) {
|
---|
107 | Assert.AreEqual(expected[i], actual[i]);
|
---|
108 | }
|
---|
109 | }
|
---|
110 |
|
---|
111 | [TestMethod]
|
---|
112 | [TestCategory("Problems.BinPacking.3D")]
|
---|
113 | public void TestSortByMaterialHeightVolumeExtension() {
|
---|
114 | Permutation actual = _items.SortByMaterialHeightVolume();
|
---|
115 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 2, 12, 11, 1, 6, 10, 0, 5, 9, 14, 4 });
|
---|
116 | for (int i = 0; i < expected.Length; i++) {
|
---|
117 | Assert.AreEqual(expected[i], actual[i]);
|
---|
118 | }
|
---|
119 | }
|
---|
120 |
|
---|
121 |
|
---|
122 | [TestMethod]
|
---|
123 | [TestCategory("Problems.BinPacking.3D")]
|
---|
124 | public void TestSortByMaterialAreaHeightExtension() {
|
---|
125 | Permutation actual = _items.SortByMaterialAreaHeight();
|
---|
126 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 12, 2, 1, 11, 6, 10, 0, 5, 9, 14, 4 });
|
---|
127 | for (int i = 0; i < expected.Length; i++) {
|
---|
128 | Assert.AreEqual(expected[i], actual[i]);
|
---|
129 | }
|
---|
130 | }
|
---|
131 |
|
---|
132 |
|
---|
133 | [TestMethod]
|
---|
134 | [TestCategory("Problems.BinPacking.3D")]
|
---|
135 | public void TestSortByMaterialHeightAreaExtension() {
|
---|
136 | Permutation actual = _items.SortByMaterialHeightArea();
|
---|
137 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 8, 13, 3, 7, 2, 12, 11, 1, 6, 10, 0, 5, 9, 14, 4 });
|
---|
138 | for (int i = 0; i < expected.Length; i++) {
|
---|
139 | Assert.AreEqual(expected[i], actual[i]);
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | [TestMethod]
|
---|
144 | [TestCategory("Problems.BinPacking.3D")]
|
---|
145 | public void TestSortByMaterialClusteredAreaHeightExtension() {
|
---|
146 | Permutation actual = _items.SortByMaterialClusteredAreaHeight(_packingShape, 1.0);
|
---|
147 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 0, 2, 5, 7, 8, 10, 13, 9, 11, 12, 14, 1, 3, 4, 6 });
|
---|
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 | public void TestSortByMaterialClusteredHeightAreaExtension() {
|
---|
156 | Permutation actual = _items.SortByClusteredHeightArea(_packingShape, 1.0);
|
---|
157 | Permutation expected = new Permutation(PermutationTypes.Absolute, new int[] { 1, 7, 9, 8, 10, 11, 12, 13, 14, 0, 2, 3, 4, 5, 6 });
|
---|
158 | for (int i = 0; i < expected.Length; i++) {
|
---|
159 | Assert.AreEqual(expected[i], actual[i]);
|
---|
160 | }
|
---|
161 | }
|
---|
162 |
|
---|
163 |
|
---|
164 | /*
|
---|
165 | _items.Add(new PackingItem(8, 10, 10, _packingShape, 1000, 1)); // 0, V = 800, A = 80, h = 10
|
---|
166 | _items.Add(new PackingItem(10, 8, 10, _packingShape, 1000, 2)); // 1, V = 800, A = 100, h = 8
|
---|
167 | _items.Add(new PackingItem(10, 10, 8, _packingShape, 1000, 3)); // 2, V = 800, A = 80, h = 10
|
---|
168 | _items.Add(new PackingItem(8, 8, 10, _packingShape, 1000, 4)); // 3, V = 640, A = 80, h = 8
|
---|
169 | _items.Add(new PackingItem(10, 8, 8, _packingShape, 1000, 0)); // 4, V = 640, A = 80, h = 8
|
---|
170 | _items.Add(new PackingItem(8, 10, 8, _packingShape, 1000, 1)); // 5, V = 640, A = 64, h = 10
|
---|
171 | _items.Add(new PackingItem(8, 8, 8, _packingShape, 1000, 2)); // 6, V = 512, A = 64, h = 8
|
---|
172 |
|
---|
173 | _items.Add(new PackingItem(10, 10, 10, _packingShape, 1000, 3)); // 7, V = 1000, A = 100, h = 10
|
---|
174 |
|
---|
175 | _items.Add(new PackingItem(9, 10, 10, _packingShape, 1000, 4)); // 8, V = 900, A = 90, h = 10
|
---|
176 | _items.Add(new PackingItem(10, 9, 10, _packingShape, 1000, 0)); // 9, V = 900, A = 100, h = 9
|
---|
177 | _items.Add(new PackingItem(10, 10, 9, _packingShape, 1000, 1)); // 10, V = 900, A = 90, h = 10
|
---|
178 | _items.Add(new PackingItem(9, 9, 10, _packingShape, 1000, 2)); // 11, V = 810, A = 90, h = 9
|
---|
179 | _items.Add(new PackingItem(10, 9, 9, _packingShape, 1000, 3)); // 12, V = 810, A = 90, h = 9
|
---|
180 | _items.Add(new PackingItem(9, 10, 9, _packingShape, 1000, 4)); // 13, V = 810, A = 81, h = 10
|
---|
181 | _items.Add(new PackingItem(9, 9, 9, _packingShape, 1000, 0)); // 14, V = 729, A = 81, h = 9
|
---|
182 | */
|
---|
183 | }
|
---|
184 | }
|
---|