Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/RectangularIdenticalBinPackingProblem.cs @ 9348

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

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

File size: 4.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.Core;
32using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
33using HeuristicLab.Common;
34using HeuristicLab.Optimization;
35using HeuristicLab.Problems.BinPacking.Evaluators;
36using HeuristicLab.Encodings.PermutationEncoding;
37using HeuristicLab.PluginInfrastructure;
38using HeuristicLab.Parameters;
39using HeuristicLab.Data;
40using HeuristicLab.Problems.BinPacking.Decoders;
41using HeuristicLab.Problems.BinPacking.PackingPlans;
42using HeuristicLab.Encodings.PackingEncoding.PackingSequence;
43using HeuristicLab.Encodings.PackingEncoding.GroupingVector;
44using HeuristicLab.Problems.Instances;
45
46namespace HeuristicLab.Problems.BinPacking.Problem {
47  [Item("RectangularIdenticalBinPackingProblem", "Represents a two-dimensional bin-packing problem using only bins with identical measures and bins/items with rectangular shapes.")]
48  [StorableClass]
49  [Creatable("Problems")]
50  public class RectangularIdenticalBinPackingProblem : RegularIdenticalBinPackingProblem<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> {
51
52    #region Default Instance
53    private static readonly BPPData DefaultInstance = new BPPData() {
54      Name = "2D BPP Default Instance",
55      Description = "The default instance for 2D Bin Packing.",
56      BinMeasures = new int[] { 20, 16 },
57      ItemMeasures = new int[][] {
58        new int[] {3,8},
59        new int[] {5,3},
60        new int[] {9,3},
61        new int[] {2,7},
62        new int[] {5,3},
63        new int[] {9,3},
64        new int[] {2,7},
65        new int[] {5,3},
66        new int[] {9,3},
67        new int[] {2,7},
68        new int[] {5,3},
69        new int[] {9,3},
70        new int[] {2,7},
71        new int[] {5,3},
72        new int[] {9,3},
73        new int[] {2,7},
74        new int[] {5,3},
75        new int[] {9,3},
76        new int[] {2,7},
77        new int[] {5,3},
78        new int[] {9,3},
79        new int[] {2,7},
80        new int[] {5,3},
81        new int[] {9,3},
82        new int[] {2,7},
83        new int[] {5,3},
84        new int[] {9,3},
85        new int[] {2,7},
86        new int[] {5,3},
87        new int[] {9,3},
88        new int[] {2,7},
89        new int[] {5,3},
90        new int[] {9,3},
91        new int[] {2,7},
92        new int[] {5,3},
93        new int[] {9,3},
94        new int[] {2,7}
95      },
96      Items = 30
97    };
98    #endregion
99
100    [StorableConstructor]
101    protected RectangularIdenticalBinPackingProblem(bool deserializing) : base(deserializing) { }
102    protected RectangularIdenticalBinPackingProblem(RectangularIdenticalBinPackingProblem original, Cloner cloner)
103      : base(original, cloner) {
104    }
105    public override IDeepCloneable Clone(Cloner cloner) {
106      return new RectangularIdenticalBinPackingProblem(this, cloner);
107    }
108    public RectangularIdenticalBinPackingProblem() : base(
109      new PackingPlanEvaluationAlgorithm<PackingSequenceEncoding, TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>()) {
110    }
111
112
113    #region Helpers
114    protected override void InitializeDecoder() {
115      if (SolutionCreator is PackingSequenceRandomCreator) {
116        PackingSolutionDecoder = new TwoDimensionalBottomLeftPackingSequenceDecoder();
117      } else if (SolutionCreator is GroupingVectorRandomCreator) {
118        PackingSolutionDecoder = new TwoDimensionalBottomLeftGroupingVectorDecoder();
119      } else {
120        string error = "The given problem does not support the selected solution-creator.";
121        PluginInfrastructure.ErrorHandling.ShowErrorDialog(error, null);
122      }
123    }
124
125    protected override IPackingPlanEvaluator CreateDefaultEvaluator() {
126      return new PackingRatioRectangularIdenticalBinEvaluator ();
127    }
128
129    protected override void InitializeProblemData() {
130      Load(DefaultInstance);
131    }
132    #endregion
133  }
134}
Note: See TracBrowser for help on using the repository browser.