[9348] | 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.Core;
|
---|
| 32 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 33 | using HeuristicLab.Common;
|
---|
| 34 | using HeuristicLab.Optimization;
|
---|
| 35 | using HeuristicLab.Problems.BinPacking.Evaluators;
|
---|
| 36 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
| 37 | using HeuristicLab.PluginInfrastructure;
|
---|
| 38 | using HeuristicLab.Parameters;
|
---|
| 39 | using HeuristicLab.Data;
|
---|
| 40 | using HeuristicLab.Problems.BinPacking.Decoders;
|
---|
[9440] | 41 | using HeuristicLab.Encodings.PackingEncoding.PackingPlan;
|
---|
[9348] | 42 | using HeuristicLab.Encodings.PackingEncoding.PackingSequence;
|
---|
| 43 | using HeuristicLab.Encodings.PackingEncoding.GroupingVector;
|
---|
| 44 | using HeuristicLab.Problems.Instances;
|
---|
[9440] | 45 | using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;
|
---|
[9348] | 46 |
|
---|
| 47 | namespace HeuristicLab.Problems.BinPacking.Problem {
|
---|
| 48 | [Item("RectangularIdenticalBinPackingProblem", "Represents a two-dimensional bin-packing problem using only bins with identical measures and bins/items with rectangular shapes.")]
|
---|
| 49 | [StorableClass]
|
---|
| 50 | [Creatable("Problems")]
|
---|
| 51 | public class RectangularIdenticalBinPackingProblem : RegularIdenticalBinPackingProblem<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> {
|
---|
| 52 |
|
---|
| 53 | #region Default Instance
|
---|
| 54 | private static readonly BPPData DefaultInstance = new BPPData() {
|
---|
| 55 | Name = "2D BPP Default Instance",
|
---|
| 56 | Description = "The default instance for 2D Bin Packing.",
|
---|
| 57 | BinMeasures = new int[] { 20, 16 },
|
---|
| 58 | ItemMeasures = new int[][] {
|
---|
| 59 | new int[] {3,8},
|
---|
| 60 | new int[] {5,3},
|
---|
| 61 | new int[] {9,3},
|
---|
| 62 | new int[] {2,7},
|
---|
| 63 | new int[] {5,3},
|
---|
| 64 | new int[] {9,3},
|
---|
| 65 | new int[] {2,7},
|
---|
| 66 | new int[] {5,3},
|
---|
| 67 | new int[] {9,3},
|
---|
| 68 | new int[] {2,7},
|
---|
| 69 | new int[] {5,3},
|
---|
| 70 | new int[] {9,3},
|
---|
| 71 | new int[] {2,7},
|
---|
| 72 | new int[] {5,3},
|
---|
| 73 | new int[] {9,3},
|
---|
| 74 | new int[] {2,7},
|
---|
| 75 | new int[] {5,3},
|
---|
| 76 | new int[] {9,3},
|
---|
| 77 | new int[] {2,7},
|
---|
| 78 | new int[] {5,3},
|
---|
| 79 | new int[] {9,3},
|
---|
| 80 | new int[] {2,7},
|
---|
| 81 | new int[] {5,3},
|
---|
| 82 | new int[] {9,3},
|
---|
| 83 | new int[] {2,7},
|
---|
| 84 | new int[] {5,3},
|
---|
| 85 | new int[] {9,3},
|
---|
| 86 | new int[] {2,7},
|
---|
| 87 | new int[] {5,3},
|
---|
| 88 | new int[] {9,3},
|
---|
| 89 | new int[] {2,7},
|
---|
| 90 | new int[] {5,3},
|
---|
| 91 | new int[] {9,3},
|
---|
| 92 | new int[] {2,7},
|
---|
| 93 | new int[] {5,3},
|
---|
| 94 | new int[] {9,3},
|
---|
| 95 | new int[] {2,7}
|
---|
| 96 | },
|
---|
| 97 | Items = 30
|
---|
| 98 | };
|
---|
| 99 | #endregion
|
---|
| 100 |
|
---|
| 101 | [StorableConstructor]
|
---|
| 102 | protected RectangularIdenticalBinPackingProblem(bool deserializing) : base(deserializing) { }
|
---|
| 103 | protected RectangularIdenticalBinPackingProblem(RectangularIdenticalBinPackingProblem original, Cloner cloner)
|
---|
| 104 | : base(original, cloner) {
|
---|
| 105 | }
|
---|
| 106 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 107 | return new RectangularIdenticalBinPackingProblem(this, cloner);
|
---|
| 108 | }
|
---|
| 109 | public RectangularIdenticalBinPackingProblem() : base(
|
---|
[9563] | 110 | new PackingPlanEvaluationAlgorithm<Permutation, TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>()) {
|
---|
[9348] | 111 | }
|
---|
| 112 |
|
---|
| 113 |
|
---|
| 114 | #region Helpers
|
---|
| 115 | protected override void InitializeDecoder() {
|
---|
[9495] | 116 | Operators.RemoveAll(op => typeof(I3DOperator).IsAssignableFrom(op.GetType()));
|
---|
| 117 |
|
---|
[9563] | 118 | PackingSolutionDecoderParameter.ValidValues.Clear();
|
---|
| 119 | if (SolutionCreator is PackingSequenceRandomCreator) {
|
---|
| 120 | PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DPSDecoder>());
|
---|
| 121 | //PackingSolutionDecoder = new ExtremePointPackingSequenceDecoder2D();
|
---|
| 122 | } else if (SolutionCreator is GroupingVectorRandomCreator) {
|
---|
| 123 | PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DGVDecoder>());
|
---|
| 124 | //PackingSolutionDecoder = new ExtremePointGroupingVectorDecoder2D();
|
---|
| 125 | } else if (SolutionCreator is MultiComponentVectorRandomCreator) {
|
---|
| 126 | PackingSolutionDecoderParameter.ValidValues.UnionWith(ApplicationManager.Manager.GetInstances<I2DMCVDecoder>());
|
---|
| 127 | //PackingSolutionDecoder = new ExtremePointMultiComponentVectorDecoder2D();
|
---|
[9348] | 128 | } else {
|
---|
| 129 | string error = "The given problem does not support the selected solution-creator.";
|
---|
| 130 | PluginInfrastructure.ErrorHandling.ShowErrorDialog(error, null);
|
---|
| 131 | }
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | protected override IPackingPlanEvaluator CreateDefaultEvaluator() {
|
---|
| 135 | return new PackingRatioRectangularIdenticalBinEvaluator ();
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | protected override void InitializeProblemData() {
|
---|
| 139 | Load(DefaultInstance);
|
---|
| 140 | }
|
---|
[9598] | 141 |
|
---|
| 142 | protected override void RemoveTooBigItems() {
|
---|
| 143 | PackingItemMeasures.RemoveAll(pi =>
|
---|
| 144 | !PackingBinMeasures.Encloses(new TwoDimensionalPacking(0, 0, 0, false), pi) &&
|
---|
| 145 | !PackingBinMeasures.Encloses(new TwoDimensionalPacking(0, 0, 0, true), pi));
|
---|
| 146 | }
|
---|
[9348] | 147 | #endregion
|
---|
| 148 | }
|
---|
| 149 | }
|
---|