1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using System.Text;
|
---|
26 | using HeuristicLab.Problems.BinPacking.Dimensions;
|
---|
27 | using HeuristicLab.Problems.BinPacking.Interfaces;
|
---|
28 | using HeuristicLab.Problems.BinPacking.Shapes;
|
---|
29 | using HeuristicLab.Problems.BinPacking.PackingBin;
|
---|
30 | using HeuristicLab.Problems.BinPacking.PackingItem;
|
---|
31 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
32 | using HeuristicLab.Core;
|
---|
33 | using HeuristicLab.Common;
|
---|
34 | using HeuristicLab.Optimization;
|
---|
35 | using HeuristicLab.Problems.BinPacking.Evaluators;
|
---|
36 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
37 | using HeuristicLab.Data;
|
---|
38 | using HeuristicLab.Problems.BinPacking.Decoders;
|
---|
39 | using System.Reflection;
|
---|
40 | using System.IO;
|
---|
41 | using HeuristicLab.Parameters;
|
---|
42 | using HeuristicLab.Encodings.PackingEncoding.PackingSequence;
|
---|
43 | using HeuristicLab.Encodings.PackingEncoding.GroupingVector;
|
---|
44 | using HeuristicLab.Problems.Instances;
|
---|
45 | using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;
|
---|
46 | using HeuristicLab.PluginInfrastructure;
|
---|
47 |
|
---|
48 | namespace HeuristicLab.Problems.BinPacking.Problem {
|
---|
49 | [Item("CuboidIdenticalBinPackingProblem", "Represents a three-dimensional bin-packing problem using only bins with identical measures and bins/items with cuboidic shapes.")]
|
---|
50 | [StorableClass]
|
---|
51 | [Creatable("Problems")]
|
---|
52 | public class CuboidIdenticalBinPackingProblem : RegularIdenticalBinPackingProblem<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> {
|
---|
53 |
|
---|
54 | #region Default Instance
|
---|
55 | private static readonly BPPData DefaultInstance = new BPPData() {
|
---|
56 | Name = "3D BPP Default Instance",
|
---|
57 | Description = "The default instance for 3D Bin Packing.",
|
---|
58 | BinMeasures = new int[] {25,25,35},
|
---|
59 | ItemMeasures = new int[][] {
|
---|
60 | new int[] {12,5,10},
|
---|
61 | new int[] {10,18,20},
|
---|
62 | new int[] {9,7,7},
|
---|
63 | new int[] {21,12,4},
|
---|
64 | new int[] {8,8,12},
|
---|
65 | new int[] {3,6,14},
|
---|
66 | new int[] {20,4,9},
|
---|
67 | new int[] {5,9,8},
|
---|
68 | new int[] {7,17,3},
|
---|
69 | new int[] {13,20,15},
|
---|
70 | new int[] {9,11,9},
|
---|
71 | new int[] {10,18,20},
|
---|
72 | new int[] {9,7,7},
|
---|
73 | new int[] {21,12,4},
|
---|
74 | new int[] {8,8,12},
|
---|
75 | new int[] {3,6,14},
|
---|
76 | new int[] {20,4,9},
|
---|
77 | new int[] {5,9,8},
|
---|
78 | new int[] {7,17,3},
|
---|
79 | new int[] {13,20,15},
|
---|
80 | new int[] {9,11,9},
|
---|
81 | new int[] {10,18,20},
|
---|
82 | new int[] {9,7,7},
|
---|
83 | new int[] {21,12,4},
|
---|
84 | new int[] {8,8,12},
|
---|
85 | new int[] {3,6,14},
|
---|
86 | new int[] {20,4,9},
|
---|
87 | new int[] {5,9,8},
|
---|
88 | new int[] {7,17,3},
|
---|
89 | new int[] {13,20,15},
|
---|
90 | new int[] {9,11,9},
|
---|
91 | new int[] {10,18,20},
|
---|
92 | new int[] {9,7,7},
|
---|
93 | new int[] {21,12,4},
|
---|
94 | new int[] {8,8,12},
|
---|
95 | new int[] {3,6,14},
|
---|
96 | new int[] {20,4,9},
|
---|
97 | new int[] {5,9,8},
|
---|
98 | new int[] {7,17,3},
|
---|
99 | new int[] {13,20,15},
|
---|
100 | new int[] {9,11,9}
|
---|
101 | },
|
---|
102 | Items = 30
|
---|
103 | };
|
---|
104 | #endregion
|
---|
105 |
|
---|
106 | [StorableConstructor]
|
---|
107 | protected CuboidIdenticalBinPackingProblem(bool deserializing) : base(deserializing) { }
|
---|
108 | protected CuboidIdenticalBinPackingProblem(CuboidIdenticalBinPackingProblem original, Cloner cloner)
|
---|
109 | : base(original, cloner) {
|
---|
110 | }
|
---|
111 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
112 | return new CuboidIdenticalBinPackingProblem(this, cloner);
|
---|
113 | }
|
---|
114 | public CuboidIdenticalBinPackingProblem() : base(
|
---|
115 | new PackingPlanEvaluationAlgorithm<Permutation, ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>()) {
|
---|
116 | }
|
---|
117 |
|
---|
118 |
|
---|
119 |
|
---|
120 | #region Helpers
|
---|
121 | protected override void InitializeDecoder() {
|
---|
122 | Operators.RemoveAll(op => typeof(I2DOperator).IsAssignableFrom(op.GetType()));
|
---|
123 |
|
---|
124 | PackingSolutionDecoderParameter.ValidValues.Clear();
|
---|
125 | if (SolutionCreator is PackingSequenceRandomCreator) {
|
---|
126 | PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DPSDecoder>());
|
---|
127 | //PackingSolutionDecoder = new ExtremePointPackingSequenceDecoder3D();
|
---|
128 | } else if (SolutionCreator is GroupingVectorRandomCreator) {
|
---|
129 | PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DGVDecoder>());
|
---|
130 | //PackingSolutionDecoder = new ExtremePointGroupingVectorDecoder3D();
|
---|
131 | } else if (SolutionCreator is MultiComponentVectorRandomCreator) {
|
---|
132 | PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I3DMCVDecoder>());
|
---|
133 | //PackingSolutionDecoder = ApplicationManager.Manager.GetInstances<ExtremePointMultiComponentVectorDecoder3D>().First();
|
---|
134 | } else {
|
---|
135 | string error = "The given problem does not support the selected solution-creator.";
|
---|
136 | PluginInfrastructure.ErrorHandling.ShowErrorDialog(error, null);
|
---|
137 | }
|
---|
138 | }
|
---|
139 |
|
---|
140 | protected override IPackingPlanEvaluator CreateDefaultEvaluator() {
|
---|
141 | return new PackingRatioCuboidIdenticalBinEvaluator();
|
---|
142 | }
|
---|
143 |
|
---|
144 | protected override void InitializeProblemData() {
|
---|
145 | Load(DefaultInstance);
|
---|
146 | }
|
---|
147 |
|
---|
148 | protected override void RemoveTooBigItems() {
|
---|
149 | PackingItemMeasures.RemoveAll(pi =>
|
---|
150 | !PackingBinMeasures.Encloses (new ThreeDimensionalPacking(0, 0, 0, 0, false), pi) &&
|
---|
151 | !PackingBinMeasures.Encloses(new ThreeDimensionalPacking(0, 0, 0, 0, true), pi));
|
---|
152 | }
|
---|
153 | #endregion
|
---|
154 | }
|
---|
155 | }
|
---|