Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/CuboidIdenticalBinPackingProblem.cs @ 9563

Last change on this file since 9563 was 9563, checked in by jhelm, 11 years ago

#1966: Implemented additional Operator-Wrappers for PackingSequence and GroupingVector; Implemented additional problem-class for Rosenbauer-Problemstatement; Added marker-interfaces for decoder-types;

File size: 5.9 KB
Line 
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
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Problems.BinPacking.Dimensions;
27using HeuristicLab.Problems.BinPacking.Interfaces;
28using HeuristicLab.Problems.BinPacking.Shapes;
29using HeuristicLab.Problems.BinPacking.PackingBin;
30using HeuristicLab.Problems.BinPacking.PackingItem;
31using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
32using HeuristicLab.Core;
33using HeuristicLab.Common;
34using HeuristicLab.Optimization;
35using HeuristicLab.Problems.BinPacking.Evaluators;
36using HeuristicLab.Encodings.PermutationEncoding;
37using HeuristicLab.Data;
38using HeuristicLab.Problems.BinPacking.Decoders;
39using System.Reflection;
40using System.IO;
41using HeuristicLab.Parameters;
42using HeuristicLab.Encodings.PackingEncoding.PackingSequence;
43using HeuristicLab.Encodings.PackingEncoding.GroupingVector;
44using HeuristicLab.Problems.Instances;
45using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;
46using HeuristicLab.PluginInfrastructure;
47
48namespace 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    #endregion
148  }
149}
Note: See TracBrowser for help on using the repository browser.