Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 9426 was 9348, checked in by jhelm, 12 years ago

#1966: First working version of bin-packing problems.

File size: 5.1 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;
45
46namespace HeuristicLab.Problems.BinPacking.Problem {
47  [Item("CuboidIdenticalBinPackingProblem", "Represents a three-dimensional bin-packing problem using only bins with identical measures and bins/items with cuboidic shapes.")]
48  [StorableClass]
49  [Creatable("Problems")]
50  public class CuboidIdenticalBinPackingProblem : RegularIdenticalBinPackingProblem<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> {
51
52    #region Default Instance
53    private static readonly BPPData DefaultInstance = new BPPData() { 
54      Name = "3D BPP Default Instance",
55      Description = "The default instance for 3D Bin Packing.",
56      BinMeasures = new int[] {25,25,35},
57      ItemMeasures = new int[][] {
58        new int[] {12,5,10},
59        new int[] {10,18,20},
60        new int[] {9,7,7},
61        new int[] {21,12,4},
62        new int[] {8,8,12},
63        new int[] {3,6,14},
64        new int[] {20,4,9},
65        new int[] {5,9,8},
66        new int[] {7,17,3},
67        new int[] {13,20,15},
68        new int[] {9,11,9},
69        new int[] {10,18,20},
70        new int[] {9,7,7},
71        new int[] {21,12,4},
72        new int[] {8,8,12},
73        new int[] {3,6,14},
74        new int[] {20,4,9},
75        new int[] {5,9,8},
76        new int[] {7,17,3},
77        new int[] {13,20,15},
78        new int[] {9,11,9},
79        new int[] {10,18,20},
80        new int[] {9,7,7},
81        new int[] {21,12,4},
82        new int[] {8,8,12},
83        new int[] {3,6,14},
84        new int[] {20,4,9},
85        new int[] {5,9,8},
86        new int[] {7,17,3},
87        new int[] {13,20,15},
88        new int[] {9,11,9},
89        new int[] {10,18,20},
90        new int[] {9,7,7},
91        new int[] {21,12,4},
92        new int[] {8,8,12},
93        new int[] {3,6,14},
94        new int[] {20,4,9},
95        new int[] {5,9,8},
96        new int[] {7,17,3},
97        new int[] {13,20,15},
98        new int[] {9,11,9}
99      },
100      Items = 30
101    };
102    #endregion
103   
104    [StorableConstructor]
105    protected CuboidIdenticalBinPackingProblem(bool deserializing) : base(deserializing) { }
106    protected CuboidIdenticalBinPackingProblem(CuboidIdenticalBinPackingProblem original, Cloner cloner)
107      : base(original, cloner) {
108    }
109    public override IDeepCloneable Clone(Cloner cloner) {
110      return new CuboidIdenticalBinPackingProblem(this, cloner);
111    }
112    public CuboidIdenticalBinPackingProblem() : base(
113      new PackingPlanEvaluationAlgorithm<PackingSequenceEncoding, ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>()) {
114    }
115
116
117
118    #region Helpers
119    protected override void InitializeDecoder() {
120      if (SolutionCreator is PackingSequenceRandomCreator) {
121        PackingSolutionDecoder = new ThreeDimensionalBottomLeftPackingSequenceDecoder();
122      } else if (SolutionCreator is GroupingVectorRandomCreator) {
123        PackingSolutionDecoder = new ThreeDimensionalBottomLeftGroupingVectorDecoder();
124      } else {
125        string error = "The given problem does not support the selected solution-creator.";
126        PluginInfrastructure.ErrorHandling.ShowErrorDialog(error, null);
127      }
128    }
129
130    protected override IPackingPlanEvaluator CreateDefaultEvaluator() {
131      return new PackingRatioCuboidIdenticalBinEvaluator();
132    }
133
134    protected override void InitializeProblemData() {
135      Load(DefaultInstance);
136    }
137    #endregion
138  }
139}
Note: See TracBrowser for help on using the repository browser.