Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9596 for branches


Ignore:
Timestamp:
06/07/13 01:20:12 (11 years ago)
Author:
jhelm
Message:

#1966: More refactoring; Added more sophisticated structures for packing-plan and bin-packing representation; Transferred parts of the decoding-algorithms to these structures; Did some more refactoring and cleanup;

Location:
branches/HeuristicLab.BinPacking
Files:
3 added
11 deleted
33 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.BinPacking.sln

    r9348 r9596  
    11
    2 Microsoft Visual Studio Solution File, Format Version 11.00
    3 # Visual Studio 2010
     2Microsoft Visual Studio Solution File, Format Version 12.00
     3# Visual Studio 2012
    44Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.BinPacking-3.3", "HeuristicLab.Problems.BinPacking\3.3\HeuristicLab.Problems.BinPacking-3.3.csproj", "{F8A55094-3CD5-4034-B0CA-5BD7FFB016D4}"
    55EndProject
     
    77  ProjectSection(SolutionItems) = preProject
    88    ..\Build.cmd = ..\Build.cmd
     9    Performance1.psess = Performance1.psess
    910    ..\PreBuildEvent.cmd = ..\PreBuildEvent.cmd
    1011  EndProjectSection
     
    6061    HideSolutionNode = FALSE
    6162  EndGlobalSection
     63  GlobalSection(Performance) = preSolution
     64    HasPerformanceSessions = true
     65  EndGlobalSection
    6266EndGlobal
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Plugin.cs

    r9593 r9596  
    2626  /// Plugin class for HeuristicLab.Problems.BinPacking.Views plugin.
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Problems.BinPacking.Views", "3.3.7.9495")]
     28  [Plugin("HeuristicLab.Problems.BinPacking.Views", "3.3.7.9593")]
    2929  [PluginFile("HeuristicLab.Problems.BinPacking.Views-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Common", "3.3")]
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Properties/AssemblyInfo.cs

    r9593 r9596  
    5454// by using the '*' as shown below:
    5555[assembly: AssemblyVersion("3.3.0.0")]
    56 [assembly: AssemblyFileVersion("3.3.7.9495")]
     56[assembly: AssemblyFileVersion("3.3.7.9593")]
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftGroupingVectorDecoder.cs

    r9593 r9596  
    4141  [Item("Identical bin two dimensional grouping vector decoder", "<Description missing...>")]
    4242  [StorableClass]
    43   public class BottomLeftGroupingVectorDecoder : PackingSolutionDecoder<
    44       TwoDimensionalPacking,
    45       RectangularPackingBin,
    46       RectangularPackingItem>, I2DGVDecoder {
    47 
    48     public BottomLeftGroupingVectorDecoder()
    49       : base() {
    50         //EncodedSolutionParameter.ActualName = "EncodedSolution";
    51     }
     43  public class BottomLeftGroupingVectorDecoder : PackingSolutionDecoder<TwoDimensionalPacking, RectangularPackingBin,RectangularPackingItem>, I2DGVDecoder {
     44    public BottomLeftGroupingVectorDecoder() : base() {}
    5245    [StorableConstructor]
    5346    protected BottomLeftGroupingVectorDecoder(bool deserializing) : base(deserializing) { }
     
    5952    }
    6053
    61 
    6254    public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {
    63 
    6455      var solution = encodedSolution as GroupingVectorEncoding;
    6556      if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector");
    66 
    67       PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result =
    68         new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures);
    69 
    70       result.BinPackings = TwoDimensionalPackingFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); //BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures);
     57      PackingPlan2D result = new PackingPlan2D(binMeasures);
     58      result.Pack(solution, itemMeasures);
    7159      return result;
    7260    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftMultiComponentVectorDecoder.cs

    r9593 r9596  
    4141  [Item("Identical bin two dimensional multi component vector decoder", "<Description missing...>")]
    4242  [StorableClass]
    43   public class BottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder<
    44       TwoDimensionalPacking,
    45       RectangularPackingBin,
    46       RectangularPackingItem>, I2DMCVDecoder {
    47 
    48     public BottomLeftMultiComponentVectorDecoder()
    49       : base() {
    50       //EncodedSolutionParameter.ActualName = "EncodedSolution";
    51     }
     43  public class BottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder<TwoDimensionalPacking,RectangularPackingBin, RectangularPackingItem>, I2DMCVDecoder {
     44    public BottomLeftMultiComponentVectorDecoder() : base() {}
    5245    [StorableConstructor]
    5346    protected BottomLeftMultiComponentVectorDecoder(bool deserializing) : base(deserializing) { }
     
    5952    }
    6053
    61 
    6254    public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {
    63 
    6455      var solution = encodedSolution as MultiComponentVectorEncoding;
    6556      if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponent Vector");
    66 
    67       PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result =
    68         new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures);
    69 
    70       result.BinPackings = TwoDimensionalPackingFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); //BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures);
    71 
     57      PackingPlan2D result = new PackingPlan2D(binMeasures);
     58      result.Pack(solution, itemMeasures);
    7259      return result;
    7360    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftPackingSequenceDecoder.cs

    r9593 r9596  
    4040  [Item("Identical bin, two dimensional, direct permutation decoder", "<Description missing...>")]
    4141  [StorableClass]
    42   public class BottomLeftPackingSequenceDecoder : PackingSolutionDecoder<
    43       TwoDimensionalPacking,
    44       RectangularPackingBin,
    45       RectangularPackingItem>, I2DPSDecoder {
     42  public class BottomLeftPackingSequenceDecoder : PackingSolutionDecoder<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>, I2DPSDecoder {
    4643
    47     public BottomLeftPackingSequenceDecoder()
    48       : base() {
    49         //EncodedSolutionParameter.ActualName = "EncodedSolution";
    50     }
     44    public BottomLeftPackingSequenceDecoder(): base() { }
    5145    [StorableConstructor]
    5246    protected BottomLeftPackingSequenceDecoder(bool deserializing) : base(deserializing) { }
     
    5852    }
    5953
    60 
    6154    public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {
    62 
    6355      var solution = encodedSolution as PackingSequenceEncoding;
    6456      if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence");
    65 
    66       PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result =
    67         new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures);
    68 
    69       result.BinPackings = TwoDimensionalPackingFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); //BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures);
    70 
     57      PackingPlan2D result = new PackingPlan2D(binMeasures);
     58      result.Pack(solution, itemMeasures);
    7159      return result;
    7260    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointGroupingVectorDecoder2D.cs

    r9593 r9596  
    4141  [Item("Identical bin, two dimensional, extreme points based decoder for the GroupingVector encoding.", "<Description missing...>")]
    4242  [StorableClass]
    43   public class ExtremePointGroupingVectorDecoder2D : PackingSolutionDecoder<
    44       TwoDimensionalPacking,
    45       RectangularPackingBin,
    46       RectangularPackingItem>, I2DGVDecoder {
    47 
    48     public ExtremePointGroupingVectorDecoder2D ()
    49       : base() {
    50     }
     43  public class ExtremePointGroupingVectorDecoder2D : PackingSolutionDecoder<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>, I2DGVDecoder {
     44    public ExtremePointGroupingVectorDecoder2D () : base() {}
    5145    [StorableConstructor]
    5246    protected ExtremePointGroupingVectorDecoder2D (bool deserializing) : base(deserializing) { }
     
    5953
    6054    public static PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> Decode(GroupingVectorEncoding solution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {
    61       PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result =
    62         new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures);
    63 
    64       result.BinPackings = TwoDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);//ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);
    65 
     55      PackingPlan2D result = new PackingPlan2D(binMeasures, true, false);
     56      result.Pack(solution, itemMeasures);
    6657      return result;
    6758    }
    6859
    6960    public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {
    70                      
    7161      var solution = encodedSolution as GroupingVectorEncoding;
    7262      if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector");
    73 
    7463      return Decode(solution, binMeasures, itemMeasures);
    7564    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointMultiComponentVectorDecoder2D.cs

    r9593 r9596  
    4242  [Item("Identical bin, two dimensional, extreme points based decoder for the MultiComponentVector encoding.", "<Description missing...>")]
    4343  [StorableClass]
    44   public class ExtremePointMultiComponentVectorDecoder2D : PackingSolutionDecoder<
    45       TwoDimensionalPacking,
    46       RectangularPackingBin,
    47       RectangularPackingItem>, I2DMCVDecoder {
    48 
    49     public ExtremePointMultiComponentVectorDecoder2D ()
    50       : base() {
    51     }
     44  public class ExtremePointMultiComponentVectorDecoder2D : PackingSolutionDecoder<TwoDimensionalPacking,RectangularPackingBin, RectangularPackingItem>, I2DMCVDecoder {
     45    public ExtremePointMultiComponentVectorDecoder2D () : base() {}
    5246    [StorableConstructor]
    5347    protected ExtremePointMultiComponentVectorDecoder2D (bool deserializing) : base(deserializing) { }
     
    6054
    6155    public static PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> Decode(MultiComponentVectorEncoding solution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {
    62       PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result =
    63         new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures);
    64 
    65       result.BinPackings = TwoDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);//ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);
    66 
     56      PackingPlan2D result = new PackingPlan2D(binMeasures, true, false);
     57      result.Pack(solution, itemMeasures);
    6758      return result;
    6859    }
    6960
    7061    public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {
    71 
    7262      var solution = encodedSolution as MultiComponentVectorEncoding;
    7363      if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector");
    74 
    7564      return Decode(solution, binMeasures, itemMeasures);
    7665    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointPackingSequenceDecoder2D.cs

    r9593 r9596  
    4040  [Item("Identical bin, two dimensional, extreme points based decoder for the PackingSequence encoding.", "<Description missing...>")]
    4141  [StorableClass]
    42   public class ExtremePointPackingSequenceDecoder2D : PackingSolutionDecoder<
    43       TwoDimensionalPacking,
    44       RectangularPackingBin,
    45       RectangularPackingItem>, I2DPSDecoder {
    46 
    47     public ExtremePointPackingSequenceDecoder2D ()
    48       : base() {
    49     }
     42  public class ExtremePointPackingSequenceDecoder2D : PackingSolutionDecoder<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>, I2DPSDecoder {
     43    public ExtremePointPackingSequenceDecoder2D () : base() {}
    5044    [StorableConstructor]
    5145    protected ExtremePointPackingSequenceDecoder2D (bool deserializing) : base(deserializing) { }
     
    5953
    6054    public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {
    61 
    6255      var solution = encodedSolution as PackingSequenceEncoding;
    6356      if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence");
    64 
    65       PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result =
    66         new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures);
    67 
    68       result.BinPackings = TwoDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);//ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);
    69 
     57      PackingPlan2D result = new PackingPlan2D(binMeasures, true, false);
     58      result.Pack(solution, itemMeasures);
    7059      return result;
    7160    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftGroupingVectorDecoder.cs

    r9593 r9596  
    3838
    3939namespace HeuristicLab.Problems.BinPacking.Decoders {
    40   [Item("Identical bin three dimensional direct grouping vector decoder", "<Description missing...>")]
     40  [Item("Identical bin, three dimensional, GroupingVector-decoder", "<Description missing...>")]
    4141  [StorableClass]
    42   public class DeepestBottomLeftGroupingVectorDecoder : PackingSolutionDecoder<
    43       ThreeDimensionalPacking,
    44       CuboidPackingBin,
    45       CuboidPackingItem>, I3DGVDecoder {
    46 
    47     public DeepestBottomLeftGroupingVectorDecoder()
    48       : base() {
    49         //EncodedSolutionParameter.ActualName = "EncodedSolution";
    50     }
     42  public class DeepestBottomLeftGroupingVectorDecoder : PackingSolutionDecoder<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DGVDecoder {
     43    public DeepestBottomLeftGroupingVectorDecoder() : base() {}
    5144    [StorableConstructor]
    5245    protected DeepestBottomLeftGroupingVectorDecoder(bool deserializing) : base(deserializing) { }
     
    5851    }
    5952
    60 
    6153    public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {
    62 
    6354      var solution = encodedSolution as GroupingVectorEncoding;
    6455      if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector");
    65 
    66       PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures);
    67 
    68       result.BinPackings = ThreeDimensionalPackingFunctions.DeepestLeftBottomPacking(solution, binMeasures, itemMeasures);
    69 
     56      PackingPlan3D result = new PackingPlan3D(binMeasures);
     57      result.Pack(solution, itemMeasures);
    7058      return result;
    7159    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftMultiComponentVectorDecoder.cs

    r9593 r9596  
    3939
    4040namespace HeuristicLab.Problems.BinPacking.Decoders {
    41   [Item("Identical bin three dimensional multi component vector decoder", "<Description missing...>")]
     41  [Item("Identical bin, three dimensional, MultiComponentVector-decoder", "<Description missing...>")]
    4242  [StorableClass]
    43   public class DeepestBottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder<
    44       ThreeDimensionalPacking,
    45       CuboidPackingBin,
    46       CuboidPackingItem>, I3DMCVDecoder {
    47 
    48     public DeepestBottomLeftMultiComponentVectorDecoder()
    49       : base() {
    50         //EncodedSolutionParameter.ActualName = "EncodedSolution";
    51     }
     43  public class DeepestBottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DMCVDecoder {
     44    public DeepestBottomLeftMultiComponentVectorDecoder() : base() { }
    5245    [StorableConstructor]
    5346    protected DeepestBottomLeftMultiComponentVectorDecoder(bool deserializing) : base(deserializing) { }
     
    5952    }
    6053
    61 
    6254    public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {
    63 
    6455      var solution = encodedSolution as MultiComponentVectorEncoding;
    6556      if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponent Vector");
    66 
    67       PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result =
    68         new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures);
    69 
    70       result.BinPackings = ThreeDimensionalPackingFunctions.DeepestLeftBottomPacking(solution, binMeasures, itemMeasures);
    71 
     57      PackingPlan3D result = new PackingPlan3D(binMeasures);
     58      result.Pack(solution, itemMeasures);
    7259      return result;
    7360    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftPackingSequenceDecoder.cs

    r9593 r9596  
    3838
    3939namespace HeuristicLab.Problems.BinPacking.Decoders {
    40   [Item("Identical bin, three dimensional, direct permutation decoder", "<Description missing...>")]
     40  [Item("Identical bin, three dimensional, PackingSequence-decoder", "<Description missing...>")]
    4141  [StorableClass]
    42   public class DeepestBottomLeftPackingSequenceDecoder : PackingSolutionDecoder<
    43       ThreeDimensionalPacking,
    44       CuboidPackingBin,
    45       CuboidPackingItem>, I3DPSDecoder {
    46 
    47     public DeepestBottomLeftPackingSequenceDecoder()
    48       : base() {
    49         //EncodedSolutionParameter.ActualName = "EncodedSolution";
    50     }
     42  public class DeepestBottomLeftPackingSequenceDecoder : PackingSolutionDecoder<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DPSDecoder {
     43    public DeepestBottomLeftPackingSequenceDecoder(): base() {}
    5144    [StorableConstructor]
    5245    protected DeepestBottomLeftPackingSequenceDecoder(bool deserializing) : base(deserializing) { }
     
    5851    }
    5952
    60 
    6153    public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {
    62 
    6354      var solution = encodedSolution as PackingSequenceEncoding;
    6455      if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence");
    65 
    66       PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result =
    67         new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures);
    68 
    69       result.BinPackings = ThreeDimensionalPackingFunctions.DeepestLeftBottomPacking(solution, binMeasures, itemMeasures);
    70 
     56      PackingPlan3D result = new PackingPlan3D(binMeasures);
     57      result.Pack(solution, itemMeasures);
    7158      return result;
    7259    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointGroupingVectorDecoder3D.cs

    r9593 r9596  
    4242  [Item("Identical bin, three dimensional, extreme points based decoder for the GroupingVector encoding.", "<Description missing...>")]
    4343  [StorableClass]
    44   public class ExtremePointGroupingVectorDecoder3D : PackingSolutionDecoder<
    45       ThreeDimensionalPacking,
    46       CuboidPackingBin,
    47       CuboidPackingItem>, I3DGVDecoder {
    48 
    49     public ValueParameter<BoolValue> StackingConstraintsParameter {
    50       get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; }
    51     }
    52 
    53     public ExtremePointGroupingVectorDecoder3D ()
    54       : base() {
    55       Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not."));
    56     }
     44  public class ExtremePointGroupingVectorDecoder3D : PackingSolutionDecoder< ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DGVDecoder {
     45    public ExtremePointGroupingVectorDecoder3D () : base() { }
    5746    [StorableConstructor]
    5847    protected ExtremePointGroupingVectorDecoder3D (bool deserializing) : base(deserializing) { }
     
    6554
    6655    public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(GroupingVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures, bool stackingConstraints) {
    67       PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result =
    68         new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures);
    69 
    70       result.BinPackings = ThreeDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures, stackingConstraints);
    71 
     56      PackingPlan3D result = new PackingPlan3D(binMeasures, true, stackingConstraints);
     57      result.Pack(solution, itemMeasures);
    7258      return result;
    7359    }
    7460
    7561    public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {
    76                      
    7762      var solution = encodedSolution as GroupingVectorEncoding;
    7863      if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector");
    79 
    8064      return Decode(solution, binMeasures, itemMeasures, StackingConstraintsParameter.Value.Value);
    8165    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointMultiComponentVectorDecoder3D.cs

    r9593 r9596  
    4343  [Item("Identical bin, three dimensional, extreme points based decoder for the MultiComponentVector encoding.", "<Description missing...>")]
    4444  [StorableClass]
    45   public class ExtremePointMultiComponentVectorDecoder3D : PackingSolutionDecoder<
    46       ThreeDimensionalPacking,
    47       CuboidPackingBin,
    48       CuboidPackingItem>, I3DMCVDecoder {
    49 
    50     public ValueParameter<BoolValue> StackingConstraintsParameter {
    51       get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; }
    52     }
    53 
    54     public ExtremePointMultiComponentVectorDecoder3D ()
    55       : base() {
    56       Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not."));
    57     }
     45  public class ExtremePointMultiComponentVectorDecoder3D : PackingSolutionDecoder<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DMCVDecoder {
     46    public ExtremePointMultiComponentVectorDecoder3D () : base() { }
    5847    [StorableConstructor]
    5948    protected ExtremePointMultiComponentVectorDecoder3D (bool deserializing) : base(deserializing) { }
     
    6655
    6756    public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures, bool stackingConstraints) {
    68       PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result =
    69         new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures);
    70 
    71       result.BinPackings = ThreeDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures, stackingConstraints);
    72 
     57      PackingPlan3D result = new PackingPlan3D(binMeasures, true, stackingConstraints);
     58      result.Pack(solution, itemMeasures);
    7359      return result;
    7460    }
    7561
    7662    public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {
    77 
    7863      var solution = encodedSolution as MultiComponentVectorEncoding;
    7964      if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector");
    80 
    8165      return Decode(solution, binMeasures, itemMeasures, StackingConstraintsParameter.Value.Value);
    8266    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointPackingSequenceDecoder3D.cs

    r9593 r9596  
    4141  [Item("Identical bin, three dimensional, extreme points based decoder for the PackingSequence encoding.", "<Description missing...>")]
    4242  [StorableClass]
    43   public class ExtremePointPackingSequenceDecoder3D : PackingSolutionDecoder<
    44       ThreeDimensionalPacking,
    45       CuboidPackingBin,
    46       CuboidPackingItem>, I3DPSDecoder {
    47 
    48     public ValueParameter<BoolValue> StackingConstraintsParameter {
    49       get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; }
    50     }
    51 
    52     public ExtremePointPackingSequenceDecoder3D ()
    53       : base() {
    54         Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not."));
    55     }
     43  public class ExtremePointPackingSequenceDecoder3D : PackingSolutionDecoder<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, I3DPSDecoder {
     44    public ExtremePointPackingSequenceDecoder3D () : base() {}
    5645    [StorableConstructor]
    5746    protected ExtremePointPackingSequenceDecoder3D (bool deserializing) : base(deserializing) { }
     
    6554
    6655    public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {
    67 
    6856      var solution = encodedSolution as PackingSequenceEncoding;
    6957      if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence");
    70 
    71       PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result =
    72         new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures);
    73 
    74       result.BinPackings = ThreeDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures, StackingConstraintsParameter.Value.Value);
    75 
     58      PackingPlan3D result = new PackingPlan3D(binMeasures, true, StackingConstraintsParameter.Value.Value);
     59      result.Pack(solution, itemMeasures);
    7660      return result;
    7761    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ISOContainerMultiComponentVectorDecoder3D.cs

    r9593 r9596  
    6060
    6161    public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {
    62      
    63       PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result =
    64         new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>();
    65                                                                    /*
    66       #region Preperations
    67       int nrOfBins = solution.NrOfBins;
    68                      
    69       Dictionary<int, List<PackingInformation>> unpackedItemIndexesPerBin = new Dictionary<int, List<PackingInformation>>();
    70       Dictionary<int, HashSet<ThreeDimensionalPacking>> extremePointsForBin = new Dictionary<int, HashSet<ThreeDimensionalPacking>>(); 
    71       ObservableDictionary<int, CuboidPackingBin> resultingBinMeasures = new ObservableDictionary<int, CuboidPackingBin>();
    72       var occupiedPoints = new List<int[, ,]>();
     62      PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> resultPlan = new PackingPlan3D(binMeasures);
     63      ObservableList<BinPacking3D> result = new ObservableList<BinPacking3D>();
    7364
    74       for (int i = 0; i < nrOfBins; i++) {
    75         unpackedItemIndexesPerBin[i] = new List<PackingInformation>(solution.PackingInformations[i]);
     65      var sequenceMatrix = solution.GenerateSequenceMatrix();
     66      Dictionary<int, bool> rotated = solution.GenerateRotationArray();
    7667
    77         extremePointsForBin[i] = new HashSet<ThreeDimensionalPacking>();
    78         extremePointsForBin[i].Add(new ThreeDimensionalPacking(i, 0, 0, 0, false));
    79         occupiedPoints = ExtremePointsFunctions3D.IncreaseBinCountForOccupiedPoints(occupiedPoints, binMeasures);
    80         resultingBinMeasures[i] = new CuboidPackingBin(binMeasures.Width, binMeasures.Height, binMeasures.Depth);
     68      //Fill bins according to grouping vector
     69      List<int> remainingIDs = new List<int>();
     70      foreach (var sequence in sequenceMatrix) {
     71        remainingIDs = remainingIDs.Concat(sequence).ToList();
     72        var bp = new BinPacking3D(binMeasures);
     73        bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, true, rotated);
     74        if (remainingIDs.Count > 0) {
     75          bp.DoubleDepth();
     76          bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, true, rotated);
     77        }
     78        result.Add(bp);
    8179      }
     80      result.RemoveAll(x => x.ItemPositions.Count == 0);
     81      result = new ObservableList<BinPacking3D>(result.OrderByDescending(bp => bp.PackingDensity));
    8282
    83       ObservableDictionary<int, ThreeDimensionalPacking> itemPositions = new ObservableDictionary<int, ThreeDimensionalPacking>();
    84       var remainingItems = new List<PackingInformation>();
    85 
    86       #endregion Preperations
    87 
    88 
    89       //Iterate over all bin-lists
    90       for (int binNr = 0; binNr < nrOfBins; binNr++) {
    91         //Iterate over the current bin-item-list and find feasible positions in the current bin for each item
    92         var unpackedItems = unpackedItemIndexesPerBin[binNr];
    93         for (int i = 0; i < unpackedItems.Count; i++) {
    94           var itemIndex = unpackedItems[i].ItemID;
    95           var item = itemMeasures[itemIndex];
    96 
    97           extremePointsForBin[binNr] = ExtremePointsFunctions3D.OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, resultingBinMeasures[binNr]);
    98           var positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated);
    99 
    100           if (positionFound == null && resultingBinMeasures[binNr].Depth.Equals(binMeasures.Depth)) {
    101             occupiedPoints = DoubleDepthForBinNr(occupiedPoints, ref resultingBinMeasures, binNr);
    102             positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated);
    103           }
    104 
    105           if (positionFound != null) {
    106             extremePointsForBin[binNr].Remove(positionFound);
    107             itemPositions[itemIndex] = positionFound;
    108             occupiedPoints = ExtremePointsFunctions3D.OccupyPointsForNewItem(occupiedPoints, item, positionFound, itemIndex);
    109             extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, resultingBinMeasures[binNr]);
    110           } else {
    111             remainingItems.Add(unpackedItems[i]);
    112             solution.PackingInformations[binNr].Remove(unpackedItems[i]);
     83      //Try to put remaining items in existing bins
     84      var temp = new List<int>(remainingIDs);
     85      foreach (int id in temp) {
     86        foreach (var bp in result) {
     87          var position = bp.FindExtremePointForItem(itemMeasures[id], rotated[id], true);
     88          if (remainingIDs.Count > 0) {
     89            bp.DoubleDepth();
     90            position = bp.FindExtremePointForItem(itemMeasures[id], rotated[id], true);
     91          }
     92          if (position != null) {
     93            bp.PackItem(id, itemMeasures[id], position);
     94            remainingIDs.Remove(id);
    11395          }
    11496        }
    11597      }
    11698
    117 
    118       //Packing of remaining items   
    119       //Iterate over all bin-lists
    120       for (int binNr = 0; binNr < nrOfBins && remainingItems.Count > 0; binNr++) {
    121         var unpackedItems = new List<PackingInformation>(remainingItems);
    122         //Iterate over all the remaining items
    123         for (int i = 0; i < unpackedItems.Count; i++) {
    124           var itemIndex = unpackedItems[i].ItemID;
    125           var item = itemMeasures[itemIndex];
    126 
    127           extremePointsForBin[binNr] = ExtremePointsFunctions3D.OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, resultingBinMeasures[binNr]);
    128           var positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated);
    129 
    130 
    131           if (positionFound == null && resultingBinMeasures[binNr].Depth.Equals(binMeasures.Depth)) {
    132             occupiedPoints = DoubleDepthForBinNr(occupiedPoints, ref resultingBinMeasures, binNr);
    133             positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated);
    134           }
    135          
    136           if (positionFound != null) {
    137             extremePointsForBin[binNr].Remove(positionFound);
    138             itemPositions[itemIndex] = positionFound;
    139             occupiedPoints = ExtremePointsFunctions3D.OccupyPointsForNewItem(occupiedPoints, item, positionFound, itemIndex);
    140             extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, resultingBinMeasures[binNr]);
    141             remainingItems.Remove(unpackedItems[i]);
    142             solution.PackingInformations[binNr].Add(unpackedItems[i]);
    143           }
     99      //Put still remaining items in new bins
     100      while (remainingIDs.Count > 0) {
     101        var bp = new BinPacking3D(binMeasures);
     102        bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, true, rotated);
     103        if (remainingIDs.Count > 0) {
     104          bp.DoubleDepth();
     105          bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, true, rotated);
    144106        }
    145         if (remainingItems.Count > 0 && binNr + 1 >= nrOfBins) {
    146           extremePointsForBin[nrOfBins] = new HashSet<ThreeDimensionalPacking>();
    147           extremePointsForBin[nrOfBins].Add(new ThreeDimensionalPacking(nrOfBins, 0, 0, 0, false));
    148           occupiedPoints = ExtremePointsFunctions3D.IncreaseBinCountForOccupiedPoints(occupiedPoints, binMeasures);
    149           resultingBinMeasures[nrOfBins] = new CuboidPackingBin(binMeasures.Width, binMeasures.Height, binMeasures.Depth);
    150           solution.PackingInformations[nrOfBins] = new ItemList<PackingInformation>();
    151           nrOfBins++;
    152         }
     107        result.Add(bp);
    153108      }
    154 
    155       result.BinPackings = BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>.GetBinPackings(itemPositions, resultingBinMeasures, itemMeasures, nrOfBins);   */
    156       return result;
    157     }
    158 
    159     private static List<int[, ,]> DoubleDepthForBinNr(List<int[, ,]> occupiedPoints, ref ObservableDictionary<int, CuboidPackingBin> binMeasures, int binNr) {
    160       var oldDepth = binMeasures[binNr].Depth;
    161       binMeasures[binNr].Depth = binMeasures[binNr].Depth * 2;
    162       var newBinOccupation = new int[binMeasures[binNr].Width, binMeasures[binNr].Height, binMeasures[binNr].Depth];
    163       for (int w = 0; w < binMeasures[binNr].Width; w++) {
    164         for (int h = 0; h < binMeasures[binNr].Height; h++) {
    165           for (int d = 0; d < binMeasures[binNr].Depth; d++) {
    166             if (d < oldDepth)
    167               newBinOccupation[w, h, d] = occupiedPoints[binNr][w, h, d];
    168             else
    169               newBinOccupation[w, h, d] = -1;
    170           }
    171         }
    172       }
    173 
    174       occupiedPoints[binNr] = newBinOccupation;
    175       return occupiedPoints;
     109      result.RemoveAll(x => x.ItemPositions.Count == 0);
     110      resultPlan.BinPackings = new ObservableList<BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>>(result.OrderByDescending(bp => bp.PackingDensity));
     111      return resultPlan;
    176112    }
    177113
    178114
    179 
    180 
    181115    public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {
    182 
    183116      var solution = encodedSolution as MultiComponentVectorEncoding;
    184117      if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector");
    185 
    186118      return Decode(solution, binMeasures, itemMeasures);
    187119    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/PackingSolutionDecoder.cs

    r9563 r9596  
    5959      get { return (ILookupParameter<PackingPlan<D, B, I>>)Parameters["PackingPlan"]; }
    6060    }
     61    public ValueParameter<BoolValue> StackingConstraintsParameter {
     62      get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; }
     63    }
    6164
    6265
     
    6770      Parameters.Add(new LookupParameter<ItemList<I>>("PackingItemMeasures", "Packing-item data taken from the bin-packing problem-instance."));
    6871      Parameters.Add(new LookupParameter<B>("PackingBinMeasures", "Packing-bin data taken from the bin-packing problem-instance."));
     72      Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not."));
    6973    }
    7074
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/OccupiedPoints.cs

    r9593 r9596  
    3333  [Item("Occupated Points", "A datastructure holding all currently occupied points of a packing-bin.")]
    3434  [StorableClass]
    35   public abstract class OccupiedPoints<D, I> : Item
     35  public abstract class OccupiedPoints<D, B, I> : Item
    3636    where D : class, IPackingDimensions
     37    where B : PackingShape<D>, IPackingBin
    3738    where I : PackingShape<D>, IPackingItem {
    3839
    39     public OccupiedPoints() : base() { }
     40    public OccupiedPoints(B binMeasures) : base() { }
    4041    [StorableConstructor]
    4142    protected OccupiedPoints(bool deserializing) : base(deserializing) { }
    42     protected OccupiedPoints(OccupiedPoints<D,I> original, Cloner cloner)
     43    protected OccupiedPoints(OccupiedPoints<D,B,I> original, Cloner cloner)
    4344      : base(original, cloner) {
    4445    }
     
    5152    public abstract bool IsStaticStable(I item, D ep);
    5253    public abstract bool WeightIsSupported(I item, D ep, ItemList<I> items);
    53  
     54    public abstract void ChangeBinMeasures(B binMeasures);
    5455  }
    5556}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/OccupiedPoints2D.cs

    r9593 r9596  
    3535  [Item("Occupated Points 2D", "A datastructure holding all currently occupied points of a 2D packing-bin.")]
    3636  [StorableClass]
    37   public class OccupiedPoints2D : OccupiedPoints<TwoDimensionalPacking, RectangularPackingItem> {
     37  public class OccupiedPoints2D : OccupiedPoints<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> {
    3838                   
    3939    [Storable]
    4040    private int[,] occupiedPoints { get; set; }
    4141
    42     public OccupiedPoints2D(RectangularPackingBin binMeasures) : base() {
     42    public OccupiedPoints2D(RectangularPackingBin binMeasures) : base(binMeasures) {
    4343      occupiedPoints = new int[binMeasures.Width, binMeasures.Height];
    4444      for (int w = 0; w < binMeasures.Width; w++) {
     
    6767      return true;
    6868    }
    69 
    7069    public override void OccupyPoints(RectangularPackingItem measures, TwoDimensionalPacking position, int itemID) {
    7170      int width = position.Rotated ? measures.Height : measures.Width;
     
    7776      }
    7877    }
    79 
    8078    public override bool IsPointOccupied(TwoDimensionalPacking point) {
    8179      return occupiedPoints[point.X, point.Y] != -1;
    8280    }
    83 
    8481    public override int ShortestPossibleSideFromEP(TwoDimensionalPacking ep) {
    8582      int shortestSide = int.MaxValue;
     
    10299      return shortestSide;
    103100    }
    104 
    105101    public override bool IsStaticStable(RectangularPackingItem item, TwoDimensionalPacking ep) {
    106102      //For the current implementation there was no need for stacking-constraints in the 2D-case.
    107103      //But it could be interesting for shelf-packing applications!
    108       return true;
     104      throw new NotImplementedException();
    109105    }
    110106    public override bool WeightIsSupported(RectangularPackingItem item, TwoDimensionalPacking ep, ItemList<RectangularPackingItem> items) {
    111107      return true;
    112108    }
     109    public override void ChangeBinMeasures(RectangularPackingBin binMeasures) {
     110      throw new NotImplementedException();
     111    }
    113112  }
    114113}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/OccupiedPoints3D.cs

    r9593 r9596  
    3535  [Item("Occupied Points 3D", "A datastructure holding all currently occupied points of a 3D packing-bin.")]
    3636  [StorableClass]
    37   public class OccupiedPoints3D : OccupiedPoints<ThreeDimensionalPacking, CuboidPackingItem> {
     37  public class OccupiedPoints3D : OccupiedPoints<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> {
    3838
    3939    [Storable]
    4040    private int[, ,] occupiedPoints { get; set; }
    4141
    42     public OccupiedPoints3D(CuboidPackingBin binMeasures) {
     42    public OccupiedPoints3D(CuboidPackingBin binMeasures) : base(binMeasures) {
    4343      occupiedPoints = new int[binMeasures.Width, binMeasures.Height, binMeasures.Depth];
    4444      for (int w = 0; w < binMeasures.Width; w++) {
     
    7171      return true;
    7272    }
    73 
    7473    public override void OccupyPoints(CuboidPackingItem measures, ThreeDimensionalPacking position, int itemID) {
    7574      int width = position.Rotated ? measures.Depth : measures.Width;
     
    8382      }
    8483    }
    85 
    8684    public override bool IsPointOccupied(ThreeDimensionalPacking point) {
    8785      return occupiedPoints[point.X, point.Y, point.Z] != -1;
    8886    }
    89 
    9087    public override int ShortestPossibleSideFromEP(ThreeDimensionalPacking ep) {
    9188      int shortestSide = int.MaxValue;
     
    114111      return shortestSide;
    115112    }
    116 
    117 
    118113    public override bool IsStaticStable(CuboidPackingItem item, ThreeDimensionalPacking ep) {
    119114      //Static stability is given, if item is placed on the ground
     
    164159      return false;
    165160    }
    166  
     161    public override void ChangeBinMeasures(CuboidPackingBin binMeasures) {
     162      int oldDepth = occupiedPoints.GetLength(2);
     163      var newBinOccupation = new int[binMeasures.Width, binMeasures.Height, binMeasures.Depth];
     164      for (int w = 0; w < binMeasures.Width; w++) {
     165        for (int h = 0; h < binMeasures.Height; h++) {
     166          for (int d = 0; d < binMeasures.Depth; d++) {
     167            if (d < oldDepth)
     168              newBinOccupation[w, h, d] = occupiedPoints[w, h, d];
     169            else
     170              newBinOccupation[w, h, d] = -1;
     171          }
     172        }
     173      }
     174      occupiedPoints = newBinOccupation;
     175    }
    167176  }
    168177}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/ThreeDimensionalPacking.cs

    r9440 r9596  
    8181      return base.GetHashCode() + 13 * X + 17 * Y + 23 * Z;
    8282    }
     83
     84    public static ThreeDimensionalPacking MoveLeft(ThreeDimensionalPacking original) {
     85      return new ThreeDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Z, original.Rotated);
     86    }
     87    public static ThreeDimensionalPacking MoveDown(ThreeDimensionalPacking original) {
     88      return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Z, original.Rotated);
     89    }
     90    public static ThreeDimensionalPacking MoveBack(ThreeDimensionalPacking original) {
     91      return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y, original.Z - 1, original.Rotated);
     92    }
     93
     94    public static ThreeDimensionalPacking MoveRight(ThreeDimensionalPacking original) {
     95      return new ThreeDimensionalPacking(original.AssignedBin, original.X + 1, original.Y, original.Z, original.Rotated);
     96    }
     97    public static ThreeDimensionalPacking MoveUp(ThreeDimensionalPacking original) {
     98      return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y + 1, original.Z, original.Rotated);
     99    }
     100    public static ThreeDimensionalPacking MoveFront(ThreeDimensionalPacking original) {
     101      return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y, original.Z + 1, original.Rotated);
     102    }
    83103  }
    84104}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/TwoDimensionalPacking.cs

    r9440 r9596  
    7777      return base.GetHashCode() + 13 * X + 17 * Y;
    7878    }
     79
     80    public static TwoDimensionalPacking MoveLeft(TwoDimensionalPacking original) {
     81      return new TwoDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Rotated);
     82    }
     83    public static TwoDimensionalPacking MoveDown(TwoDimensionalPacking original) {
     84      return new TwoDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Rotated);
     85    }
     86
     87    public static TwoDimensionalPacking MoveRight(TwoDimensionalPacking original) {
     88      return new TwoDimensionalPacking(original.AssignedBin, original.X + 1, original.Y, original.Rotated);
     89    }
     90    public static TwoDimensionalPacking MoveUp(TwoDimensionalPacking original) {
     91      return new TwoDimensionalPacking(original.AssignedBin, original.X, original.Y + 1, original.Rotated);
     92    }
     93
    7994  }
    8095}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/GroupingVectorEncoding.cs

    r9348 r9596  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using System.Linq;
    2224using System.Text;
    2325using HeuristicLab.Common;
     
    5052        GroupingVector = new IntegerVector();
    5153    }
     54
     55    public List<List<int>> GenerateSequenceMatrix() {
     56      List<List<int>> result = new List<List<int>>();
     57      int nrOfBins = GroupingVector.Max() + 1;
     58      for (int i = 0; i < nrOfBins; i++)
     59        result.Add(new List<int>());
     60      for (int i = 0; i < GroupingVector.Length; i++) {
     61        result[GroupingVector[i]].Add(i);
     62      }
     63      return result;
     64    }
     65   
     66
    5267
    5368    public override string ToString() {
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/BinBasedMultiComponentVectorCrossover.cs

    r9563 r9596  
    3333  public class BinBasedMultiComponentVectorCrossover :  MultiComponentVectorCrossover {
    3434    [StorableConstructor]
    35     protected BinBasedMultiComponentVectorCrossover (bool deserializing) : base(deserializing) { }
    36     protected BinBasedMultiComponentVectorCrossover (BinBasedMultiComponentVectorCrossover original, Cloner cloner) : base(original, cloner) { }
    37     public BinBasedMultiComponentVectorCrossover ()
     35    protected BinBasedMultiComponentVectorCrossover(bool deserializing) : base(deserializing) { }
     36    protected BinBasedMultiComponentVectorCrossover(BinBasedMultiComponentVectorCrossover original, Cloner cloner) : base(original, cloner) { }
     37    public BinBasedMultiComponentVectorCrossover()
    3838      : base() {
    3939    }
    4040    public override IDeepCloneable Clone(Cloner cloner) {
    41       return new BinBasedMultiComponentVectorCrossover (this, cloner);
     41      return new BinBasedMultiComponentVectorCrossover(this, cloner);
    4242    }
    4343
    4444    public override MultiComponentVectorEncoding Cross(IRandom random, MultiComponentVectorEncoding parent1, MultiComponentVectorEncoding parent2) {
    45       MultiComponentVectorEncoding child = new MultiComponentVectorEncoding();
     45      MultiComponentVectorEncoding child = new MultiComponentVectorEncoding ();
     46
    4647      int nrOfItems = parent1.NrOfItems;
    4748      bool[] itemAlreadyAssigned = new bool[nrOfItems];
    48 
    49       bool useParent2 = false;
    5049      int nrOfBins = parent1.NrOfBins > parent2.NrOfBins ? parent2.NrOfBins : parent1.NrOfBins;
    5150
     51      //Add one bin from parent1
     52      int swappedBinNr = random.Next(nrOfBins);
     53      var swappedBin = new ItemList<PackingInformation>();
     54      for (int i = 0; i < parent1.PackingInformations[swappedBinNr].Count; i++) {
     55        PackingInformation pi = new PackingInformation(parent1.PackingInformations[swappedBinNr][i]);
     56        if (!itemAlreadyAssigned[pi.ItemID]) {
     57          itemAlreadyAssigned[pi.ItemID] = true;
     58          swappedBin.Add(new PackingInformation(pi));
     59        }
     60      }
     61      child.PackingInformations[swappedBinNr] = swappedBin;
    5262
     63      //Get the remaining bins from parent2
    5364      for (int binNr = 0; binNr < nrOfBins; binNr++) {
    54         MultiComponentVectorEncoding currentParent1 = useParent2 ? parent2 : parent1;
    55         MultiComponentVectorEncoding currentParent2 = useParent2 ? parent1 : parent2;
    56 
    57 
    58         var newBin = new ItemList<PackingInformation>();
    59         double crossPointPercent = 0;
    60 
    61         int nrOfItems1 = currentParent1.PackingInformations[binNr].Count;
    62         if (nrOfItems1 > 0) {
    63           double crossPoint1 = random.Next(nrOfItems1);
    64           crossPointPercent = crossPoint1 / nrOfItems1;
    65           for (int i = 0; i < crossPoint1; i++) {
    66             PackingInformation pi = new PackingInformation(currentParent1.PackingInformations[binNr][i]);
     65        if (binNr != swappedBinNr) {
     66          var newBin = new ItemList<PackingInformation>();
     67          var currentParent = parent2;
     68          int nrOfItemsInBin = currentParent.PackingInformations[binNr].Count;
     69          for (int i = 0; i < nrOfItemsInBin; i++) {
     70            PackingInformation pi = new PackingInformation(currentParent.PackingInformations[binNr][i]);
    6771            if (!itemAlreadyAssigned[pi.ItemID]) {
    6872              itemAlreadyAssigned[pi.ItemID] = true;
     
    7074            }
    7175          }
     76          child.PackingInformations[binNr] = newBin;
    7277        }
    73 
    74         int nrOfItems2 = currentParent2.PackingInformations[binNr].Count;
    75         if (nrOfItems2 > 0) {
    76           int crossPoint2 = Convert.ToInt32(nrOfItems2 * crossPointPercent);
    77           for (int i = crossPoint2; i < nrOfItems2; i++) {
    78             PackingInformation pi = new PackingInformation(currentParent2.PackingInformations[binNr][i]);
    79             if (!itemAlreadyAssigned[pi.ItemID]) {
    80               itemAlreadyAssigned[pi.ItemID] = true;
    81               newBin.Add(new PackingInformation(pi));
    82             }
    83           }
    84         }
    85 
    86         child.PackingInformations[binNr] = newBin;
    87         useParent2 = !useParent2;
    8878      }
    8979
     80      //Pack still remaining items in bin#0
    9081      for (int itemID = 0; itemID < nrOfItems; itemID++) {
    9182        if (!itemAlreadyAssigned[itemID])
     
    9384      }
    9485
    95      
     86
    9687      return child;
    9788    }       
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/MultiComponentVectorEncoding.cs

    r9563 r9596  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Text;
    2425using HeuristicLab.Collections;
     
    6465      : base() {
    6566        PackingInformations = new ObservableDictionary<int, ItemList<PackingInformation>>();
    66     }       
     67    }
     68
     69    public List<List<int>> GenerateSequenceMatrix() {
     70      List<List<int>> result = new List<List<int>>();
     71      foreach (var bi in PackingInformations) {
     72        var temp = new List<int>();
     73        foreach (var piEntry in bi.Value) {
     74          temp.Add(piEntry.ItemID);
     75        }
     76        result.Add(temp);
     77      }
     78      return result;
     79    }
     80    public Dictionary<int, bool> GenerateRotationArray() {
     81      Dictionary<int, bool> result = new Dictionary<int, bool>();
     82      foreach (var bi in PackingInformations)
     83        foreach (var pi in bi.Value)
     84          result[pi.ItemID] = pi.Rotated;
     85      return result;
     86    }
     87
     88
    6789
    6890    public override string ToString() {
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/SequenceBasedMultiComponentVectorCrossover.cs

    r9593 r9596  
    3333  public class SequenceBasedMultiComponentVectorCrossover :  MultiComponentVectorCrossover {
    3434    [StorableConstructor]
    35     protected SequenceBasedMultiComponentVectorCrossover(bool deserializing) : base(deserializing) { }
    36     protected SequenceBasedMultiComponentVectorCrossover(SequenceBasedMultiComponentVectorCrossover original, Cloner cloner) : base(original, cloner) { }
    37     public SequenceBasedMultiComponentVectorCrossover()
     35    protected SequenceBasedMultiComponentVectorCrossover (bool deserializing) : base(deserializing) { }
     36    protected SequenceBasedMultiComponentVectorCrossover (SequenceBasedMultiComponentVectorCrossover original, Cloner cloner) : base(original, cloner) { }
     37    public SequenceBasedMultiComponentVectorCrossover ()
    3838      : base() {
    3939    }
    4040    public override IDeepCloneable Clone(Cloner cloner) {
    41       return new SequenceBasedMultiComponentVectorCrossover(this, cloner);
     41      return new SequenceBasedMultiComponentVectorCrossover (this, cloner);
    4242    }
    4343
    4444    public override MultiComponentVectorEncoding Cross(IRandom random, MultiComponentVectorEncoding parent1, MultiComponentVectorEncoding parent2) {
    45       MultiComponentVectorEncoding child = new MultiComponentVectorEncoding ();
    46 
     45      MultiComponentVectorEncoding child = new MultiComponentVectorEncoding();
    4746      int nrOfItems = parent1.NrOfItems;
    4847      bool[] itemAlreadyAssigned = new bool[nrOfItems];
     48
     49      bool useParent2 = false;
    4950      int nrOfBins = parent1.NrOfBins > parent2.NrOfBins ? parent2.NrOfBins : parent1.NrOfBins;
    50       int swappedBin = random.Next(nrOfBins);
     51
    5152
    5253      for (int binNr = 0; binNr < nrOfBins; binNr++) {
     54        MultiComponentVectorEncoding currentParent1 = useParent2 ? parent2 : parent1;
     55        MultiComponentVectorEncoding currentParent2 = useParent2 ? parent1 : parent2;
     56
    5357
    5458        var newBin = new ItemList<PackingInformation>();
    55         var currentParent = binNr == swappedBin ? parent1 : parent2;
     59        double crossPointPercent = 0;
    5660
    57         int nrOfItemsInBin = currentParent.PackingInformations[binNr].Count;
    58         for (int i = 0; i < nrOfItemsInBin; i++) {
    59           PackingInformation pi = new PackingInformation(currentParent.PackingInformations[binNr][i]);
    60           if (!itemAlreadyAssigned[pi.ItemID]) {
    61             itemAlreadyAssigned[pi.ItemID] = true;
    62             newBin.Add(new PackingInformation(pi));
     61        int nrOfItems1 = currentParent1.PackingInformations[binNr].Count;
     62        if (nrOfItems1 > 0) {
     63          double crossPoint1 = random.Next(nrOfItems1);
     64          crossPointPercent = crossPoint1 / nrOfItems1;
     65          for (int i = 0; i < crossPoint1; i++) {
     66            PackingInformation pi = new PackingInformation(currentParent1.PackingInformations[binNr][i]);
     67            if (!itemAlreadyAssigned[pi.ItemID]) {
     68              itemAlreadyAssigned[pi.ItemID] = true;
     69              newBin.Add(new PackingInformation(pi));
     70            }
     71          }
     72        }
     73
     74        int nrOfItems2 = currentParent2.PackingInformations[binNr].Count;
     75        if (nrOfItems2 > 0) {
     76          int crossPoint2 = Convert.ToInt32(nrOfItems2 * crossPointPercent);
     77          for (int i = crossPoint2; i < nrOfItems2; i++) {
     78            PackingInformation pi = new PackingInformation(currentParent2.PackingInformations[binNr][i]);
     79            if (!itemAlreadyAssigned[pi.ItemID]) {
     80              itemAlreadyAssigned[pi.ItemID] = true;
     81              newBin.Add(new PackingInformation(pi));
     82            }
    6383          }
    6484        }
    6585
    6686        child.PackingInformations[binNr] = newBin;
     87        useParent2 = !useParent2;
    6788      }
    6889
     
    7293      }
    7394
    74 
     95     
    7596      return child;
    7697    }       
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs

    r9593 r9596  
    3535using HeuristicLab.Problems.BinPacking.Dimensions;
    3636using HeuristicLab.Problems.BinPacking.PackingBin;
     37using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;
     38using HeuristicLab.Encodings.PackingEncoding.GroupingVector;
     39using HeuristicLab.Encodings.PackingEncoding.PackingSequence;
    3740
    3841namespace HeuristicLab.Encodings.PackingEncoding.PackingPlan {
    3942  [Item("PackingPlan", "Represents a concrete solution for a bin-packing problem.")]
    4043  [StorableClass]
    41   public class PackingPlan<D, B, I> : ParameterizedNamedItem, IPackingPlan
     44  public abstract class PackingPlan<D, B, I> : ParameterizedNamedItem, IPackingPlan
    4245    where D : class, IPackingDimensions
    4346    where B : PackingShape<D>, IPackingBin
     
    5255      }
    5356    }
     57    [Storable]
     58    protected bool StackingConstraints { get; set; }
     59    [Storable]
     60    protected bool UseExtremePoints { get; set; }
     61
     62    [Storable]
     63    public B BinMeasures { get; private set; }
    5464
    5565    [Storable]
     
    7181    #endregion
    7282
    73     public PackingPlan(B binMeasures)
    74       : this(){
    75       //this.BinPackings.Add(new BinPacking<D,B,I> ());
    76     }
    77     public PackingPlan()
    78       : base() {
    79       this.BinPackings = new ObservableList<BinPacking<D, B,I>>();
     83    public PackingPlan(B binMeasures, bool useExtremePoints, bool stackingConstraints)
     84      : base(){
     85        BinMeasures = (B)binMeasures.Clone();
     86        StackingConstraints = stackingConstraints;
     87        UseExtremePoints = useExtremePoints;
     88        BinPackings = new ObservableList<BinPacking<D, B, I>>();
    8089    }
    8190
     
    8695        this.BinPackings = new ObservableList<BinPacking<D, B, I>>(original.BinPackings);
    8796    }
    88     public override IDeepCloneable Clone(Cloner cloner) {
    89       return new PackingPlan<D,B,I>(this, cloner);
    90     }
    91          
     97   
     98
     99    public abstract BinPacking<D, B, I> NewBinPacking();
     100    public void UpdateBinPackings() {
     101      BinPackings.RemoveAll(x => x.ItemPositions.Count == 0);
     102      BinPackings = new ObservableList<BinPacking<D, B, I>>(BinPackings.OrderByDescending (bp => bp.PackingDensity));
     103    }
     104
     105    public void Pack(MultiComponentVectorEncoding solution, ItemList<I> itemMeasures) {
     106      var sequenceMatrix = solution.GenerateSequenceMatrix();
     107      Dictionary<int, bool> rotated = solution.GenerateRotationArray();
     108
     109      //Fill bins according to grouping vector
     110      List<int> remainingIDs = new List<int>();
     111      foreach (var sequence in sequenceMatrix) {
     112        remainingIDs = remainingIDs.Concat(sequence).ToList();
     113        var bp = NewBinPacking();
     114        if (!UseExtremePoints)
     115          bp.SlidingBasedPacking(ref remainingIDs, itemMeasures, rotated);
     116        else
     117          bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints, rotated);
     118        BinPackings.Add(bp);
     119      }
     120      UpdateBinPackings();
     121
     122      //Try to put remaining items in existing bins
     123      var temp = new List<int>(remainingIDs);
     124      foreach (int id in temp) {
     125        foreach (var bp in BinPackings) {
     126          var position = UseExtremePoints ? bp.FindExtremePointForItem(itemMeasures[id], rotated[id], StackingConstraints) : bp.FindPositionBySliding(itemMeasures[id], rotated[id]);
     127          if (position != null) {
     128            bp.PackItem(id, itemMeasures[id], position);
     129            remainingIDs.Remove(id);
     130          }
     131        }
     132      }
     133
     134      //Put still remaining items in new bins
     135      while (remainingIDs.Count > 0) {
     136        var bp = NewBinPacking();
     137        if (!UseExtremePoints)
     138          bp.SlidingBasedPacking(ref remainingIDs, itemMeasures, rotated);
     139        else
     140          bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints, rotated);
     141        BinPackings.Add(bp);
     142      }
     143      UpdateBinPackings();
     144    }
     145    public void Pack(GroupingVectorEncoding solution, ItemList<I> itemMeasures) {
     146      var sequenceMatrix = solution.GenerateSequenceMatrix();
     147
     148      //Fill bins according to grouping vector
     149      List<int> remainingIDs = new List<int>();
     150      foreach (var sequence in sequenceMatrix) {
     151        remainingIDs = remainingIDs.Concat(sequence).ToList();
     152        var bp = NewBinPacking();
     153        if (!UseExtremePoints)
     154          bp.SlidingBasedPacking(ref remainingIDs, itemMeasures);
     155        else
     156          bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints);
     157        BinPackings.Add(bp);
     158      }
     159      UpdateBinPackings();
     160
     161      //Try to put remaining items in existing bins
     162      var temp = new List<int>(remainingIDs);
     163      foreach (int id in temp) {
     164        foreach (var bp in BinPackings) { 
     165          var position = UseExtremePoints ? bp.FindExtremePointForItem (itemMeasures[id], false, StackingConstraints) : bp.FindPositionBySliding(itemMeasures[id], false);
     166          if (position != null) {
     167            bp.PackItem(id, itemMeasures[id], position);
     168            remainingIDs.Remove(id);
     169          }
     170        }
     171      }
     172
     173      //Put still remaining items in new bins
     174      while (remainingIDs.Count > 0) {
     175        var bp = NewBinPacking();
     176        if (!UseExtremePoints)
     177          bp.SlidingBasedPacking(ref remainingIDs, itemMeasures);
     178        else
     179          bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints);
     180        BinPackings.Add(bp);
     181      }
     182      UpdateBinPackings();
     183    }
     184    public void Pack(PackingSequenceEncoding solution, ItemList<I> itemMeasures) {
     185      List<int> remainingIDs = new List<int>(solution.PackingSequence);
     186      while (remainingIDs.Count > 0) {
     187        var bp = NewBinPacking();
     188        if (!UseExtremePoints)
     189          bp.SlidingBasedPacking(ref remainingIDs, itemMeasures);
     190        else
     191          bp.ExtremePointBasedPacking(ref remainingIDs, itemMeasures, StackingConstraints);
     192        BinPackings.Add(bp);
     193      }
     194      UpdateBinPackings();
     195    }
     196
    92197
    93198    #region Events
     
    126231  }
    127232
    128   [Item("BinPacking", "Represents a single-bin packing for a bin-packing problem.")]
     233
     234
     235
     236  [Item("PackingPlan2D", "Represents a concrete solution for a 2D bin-packing problem.")]
    129237  [StorableClass]
    130   public abstract class BinPacking<D,B,I>  : Item
    131     where D : class, IPackingDimensions
    132     where B : PackingShape<D>, IPackingBin
    133     where I : PackingShape<D>, IPackingItem {
    134  
    135     [Storable]
    136     public ObservableDictionary<int, D> ItemPositions { get; private set; }
    137 
    138     [Storable]
    139     public B BinMeasures { get; private set; }
    140 
    141     [Storable]
    142     public ObservableDictionary<int, I> ItemMeasures { get; private set; }
    143 
    144     [Storable]
    145     public HashSet<D> ExtremePoints { get; protected set; }
    146 
    147     [Storable]
    148     public OccupiedPoints<D, I> OccupiedPoints { get; protected set; }
    149 
    150     public BinPacking(B binMeasures) : base() {   
    151       ItemPositions = new ObservableDictionary<int, D>();
    152       ItemMeasures = new ObservableDictionary<int, I>();
    153       BinMeasures = (B)binMeasures.Clone();
    154       ExtremePoints = new HashSet<D>();
    155       ExtremePoints.Add(binMeasures.Origin);
    156     }
    157 
     238  public class PackingPlan2D : PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> {
     239    public PackingPlan2D(RectangularPackingBin binMeasures) : this(binMeasures, false, false) { }
     240    public PackingPlan2D(RectangularPackingBin binMeasures, bool useExtremePoints, bool stackingConstraints) : base(binMeasures, useExtremePoints, stackingConstraints) { }
    158241    [StorableConstructor]
    159     protected BinPacking(bool deserializing) : base(deserializing) { }
    160     protected BinPacking(BinPacking<D,B,I> original, Cloner cloner)
     242    protected PackingPlan2D(bool deserializing) : base(deserializing) { }
     243    protected PackingPlan2D(PackingPlan2D original, Cloner cloner)
    161244      : base(original, cloner) {
    162       this.ItemPositions = new ObservableDictionary<int, D>(original.ItemPositions);
    163       this.ItemMeasures = new ObservableDictionary<int, I>(original.ItemMeasures);
    164         this.BinMeasures = (B)original.BinMeasures.Clone(cloner);
    165     }
    166    
    167 
    168     protected abstract void GenerateNewExtremePointsForNewItem(I measures, D position);
    169     public abstract D FindExtremePointForItem(I measures, bool rotated, bool stackingConstraint);
    170     public abstract D FindPositionBySliding(I measures, bool rotated);
    171     public void PackItem(int itemID, I measures, D position) {
    172       ItemMeasures[itemID] = measures;
    173       ItemPositions[itemID] = position;
    174       ExtremePoints.Remove(position);
    175       GenerateNewExtremePointsForNewItem(measures, position);
    176       OccupiedPoints.OccupyPoints(measures, position, itemID);
    177     }
    178 
    179 
    180     public double PackingDensity {
    181       get {
    182         double result = 0;
    183         foreach (var entry in ItemMeasures)
    184           result += entry.Value.MultipliedMeasures;
    185         result /= BinMeasures.MultipliedMeasures;
    186         return result;
    187       }
    188     }
    189 
    190     public bool IsPositionFeasible1(I currentItem, D currentPosition) {
    191       //In this case feasability is defined as following: 1. the item fits into the bin-borders; 2. the item does not collide with another already packed item
    192       if (!BinMeasures.Encloses(currentPosition, currentItem))
    193         return false;
    194 
    195       foreach (var ipEntry in ItemPositions) {
    196         if (ItemMeasures[ipEntry.Key].Overlaps(ipEntry.Value, currentPosition, currentItem))
    197           return false;
    198       }
    199 
    200       return true;
    201     }
    202     public bool IsPositionFeasible(I currentItem, D position) {
    203       if (!BinMeasures.Encloses(position, currentItem))
    204         return false;
    205 
    206       return OccupiedPoints.IsPositionFeasible (currentItem, position);
     245    }
     246    public override IDeepCloneable Clone(Cloner cloner) {
     247      return new PackingPlan2D(this, cloner);
     248    }
     249    public override BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> NewBinPacking() {
     250      return new BinPacking2D(BinMeasures);
    207251    }
    208252  }
     
    212256
    213257
    214   [Item("BinPacking2D", "Represents a single-bin packing for a 2D bin-packing problem.")]
     258  [Item("PackingPlan3D", "Represents a concrete solution for a 3D bin-packing problem.")]
    215259  [StorableClass]
    216   public class BinPacking2D : BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> {
    217 
    218     public BinPacking2D(RectangularPackingBin binMeasures) : base(binMeasures) {
    219       OccupiedPoints = new OccupiedPoints2D(binMeasures);
    220     }
     260  public class PackingPlan3D : PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> {
     261    public PackingPlan3D(CuboidPackingBin binMeasures) : this(binMeasures, false, false) { }
     262    public PackingPlan3D(CuboidPackingBin binMeasures, bool useExtremePoints, bool stackingConstraints) : base(binMeasures, useExtremePoints, stackingConstraints) { }
    221263    [StorableConstructor]
    222     protected BinPacking2D(bool deserializing) : base(deserializing) { }
    223     protected BinPacking2D(BinPacking2D original, Cloner cloner)
     264    protected PackingPlan3D(bool deserializing) : base(deserializing) { }
     265    protected PackingPlan3D(PackingPlan3D original, Cloner cloner)
    224266      : base(original, cloner) {
    225267    }
    226268    public override IDeepCloneable Clone(Cloner cloner) {
    227       return new BinPacking2D(this, cloner);
    228     }
    229                      
    230     protected override void GenerateNewExtremePointsForNewItem(RectangularPackingItem newItem, TwoDimensionalPacking position) {
    231 
    232       int newWidth = position.Rotated ? newItem.Height : newItem.Width;
    233       int newHeight = position.Rotated ? newItem.Width : newItem.Height;
    234 
    235       //Find ExtremePoints beginning from sourcepointX
    236       var sourcePointX = new TwoDimensionalPacking(0, position.X + newWidth, position.Y);
    237       if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height) {
    238         //Traversing down the y-axis       
    239         while (sourcePointX.Y > 0 && !OccupiedPoints.IsPointOccupied(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y - 1))) {
    240           sourcePointX.Y--;
    241         }
    242         ExtremePoints.Add(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y));
    243       }
    244 
    245 
    246 
    247 
    248       //Find ExtremePoints beginning from sourcepointY
    249       var sourcePointY = new TwoDimensionalPacking(0, position.X, position.Y + newItem.Height);
    250       if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height) {
    251         //Traversing down the x-axis 
    252         while (sourcePointY.X > 0 && !OccupiedPoints.IsPointOccupied(new TwoDimensionalPacking (0,sourcePointY.X - 1, sourcePointY.Y))) {
    253           sourcePointY.X--;
    254         }
    255         ExtremePoints.Add(new TwoDimensionalPacking(0, sourcePointY.X, sourcePointY.Y));
    256       }
    257 
    258       ExtremePoints = new HashSet<TwoDimensionalPacking>(ExtremePoints.
    259         OrderBy(ep => ep.AssignedBin).
    260         ThenBy(ep => ep.X).
    261         ThenBy(ep => ep.Y).
    262         ThenBy(ep => OccupiedPoints.ShortestPossibleSideFromEP(ep)));
    263     }
    264 
    265     public override TwoDimensionalPacking FindExtremePointForItem(RectangularPackingItem measures, bool rotated, bool stackingConstraint) {
    266       RectangularPackingItem item = new RectangularPackingItem(
    267         rotated ? measures.Height : measures.Width,
    268         rotated ? measures.Width : measures.Height,
    269         measures.TargetBin);
    270 
    271       int epIndex = 0;
    272       while (epIndex < ExtremePoints.Count && (!IsPositionFeasible(item, ExtremePoints.ElementAt(epIndex)))) { epIndex++; }
    273 
    274       if (epIndex < ExtremePoints.Count) {
    275         var result = ExtremePoints.ElementAt(epIndex);
    276         result.Rotated = rotated;
    277         return result;
    278       }
    279       return null;
    280     }
    281     public override TwoDimensionalPacking FindPositionBySliding(RectangularPackingItem measures, bool rotated) {
    282       TwoDimensionalPacking currentPosition = new TwoDimensionalPacking(0,
    283         BinMeasures.Width - (rotated ? measures.Height : measures.Width),
    284         BinMeasures.Height - (rotated ? measures.Width : measures.Height), rotated);
    285       //Slide the item as far as possible to the left
    286       while (IsPositionFeasible(measures, MoveLeft(currentPosition))
    287         || IsPositionFeasible(measures, MoveDown(currentPosition))) {
    288         //Slide the item as far as possible to the bottom
    289         while (IsPositionFeasible(measures, MoveDown(currentPosition))) {
    290           currentPosition = MoveDown(currentPosition);
    291         }
    292         if (IsPositionFeasible(measures, MoveLeft(currentPosition)))
    293           currentPosition = MoveLeft(currentPosition);
    294       }
    295 
    296       return IsPositionFeasible(measures, currentPosition) ? currentPosition : null;
    297     }
    298     private static TwoDimensionalPacking MoveLeft(TwoDimensionalPacking original) {
    299       return new TwoDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Rotated);
    300     }
    301     private static TwoDimensionalPacking MoveDown(TwoDimensionalPacking original) {
    302       return new TwoDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Rotated);
     269      return new PackingPlan3D(this, cloner);
     270    }
     271    public override BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> NewBinPacking() {
     272      return new BinPacking3D(BinMeasures);
    303273    }
    304274  }
    305275
    306 
    307 
    308   [Item("BinPacking3D", "Represents a single-bin packing for a 3D bin-packing problem.")]
    309   [StorableClass]
    310   public class BinPacking3D : BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> {
    311 
    312    
    313     public BinPacking3D(CuboidPackingBin binMeasures) : base(binMeasures) {
    314       OccupiedPoints = new OccupiedPoints3D(binMeasures);
    315     }
    316     [StorableConstructor]
    317     protected BinPacking3D(bool deserializing) : base(deserializing) { }
    318     protected BinPacking3D(BinPacking3D original, Cloner cloner)
    319       : base(original, cloner) {
    320     }
    321     public override IDeepCloneable Clone(Cloner cloner) {
    322       return new BinPacking3D(this, cloner);
    323     }
    324                                        
    325     protected override void GenerateNewExtremePointsForNewItem(CuboidPackingItem newItem, ThreeDimensionalPacking position) {
    326       int newWidth = position.Rotated ? newItem.Depth : newItem.Width;
    327       int newDepth = position.Rotated ? newItem.Width : newItem.Depth;
    328 
    329       //Find ExtremePoints beginning from sourcepointX
    330       var sourcePointX = new ThreeDimensionalPacking(0, position.X + newWidth, position.Y, position.Z);
    331       if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height && sourcePointX.Z < BinMeasures.Depth) {
    332         //Traversing down the y-axis                                                                           
    333         int currentYValue = sourcePointX.Y;
    334         while (currentYValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointX.X, currentYValue, sourcePointX.Z))) {
    335           currentYValue--;
    336         }
    337         ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointX.X, currentYValue, sourcePointX.Z));
    338 
    339         //Traversing down the z-axis
    340         int currentZValue = sourcePointX.Z;
    341         while (currentZValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointX.X, sourcePointX.Y, currentZValue - 1))) {
    342           currentZValue--;
    343         }
    344         ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, currentZValue));
    345       }
    346 
    347 
    348 
    349 
    350       //Find ExtremePoints beginning from sourcepointY
    351       var sourcePointY = new ThreeDimensionalPacking(0, position.X, position.Y + newItem.Height, position.Z);
    352       if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height && sourcePointY.Z < BinMeasures.Depth) {
    353         //Traversing down the x-axis 
    354         int currentXValue = sourcePointY.X;
    355         while (currentXValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, currentXValue - 1, sourcePointY.Y, sourcePointY.Z))) {
    356           currentXValue--;
    357         }
    358         ExtremePoints.Add(new ThreeDimensionalPacking(0, currentXValue, sourcePointY.Y, sourcePointY.Z));
    359 
    360         //Traversing down the z-axis
    361         int currentZValue = sourcePointY.Z;
    362         while (currentZValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointY.X, sourcePointY.Y, currentZValue - 1))) {
    363           currentZValue--;
    364         }
    365         ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, currentZValue));
    366       }
    367 
    368 
    369 
    370 
    371 
    372       //Find ExtremePoints beginning from sourcepointZ
    373       var sourcePointZ = new ThreeDimensionalPacking(0, position.X, position.Y, position.Z + newDepth);
    374       if (sourcePointZ.X < BinMeasures.Width && sourcePointZ.Y < BinMeasures.Height && sourcePointZ.Z < BinMeasures.Depth) {
    375         //Traversing down the x-axis 
    376         int currentXValue = sourcePointZ.X;
    377         while (currentXValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, currentXValue - 1, sourcePointZ.Y, sourcePointZ.Z))) {
    378           currentXValue--;
    379         }
    380         ExtremePoints.Add(new ThreeDimensionalPacking(0, currentXValue, sourcePointZ.Y, sourcePointZ.Z));
    381 
    382         //Traversing down the y-axis                                                                           
    383         int currentYValue = sourcePointZ.Y;
    384         while (currentYValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointZ.X, currentYValue, sourcePointZ.Z))) {
    385           currentYValue--;
    386         }
    387         ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointZ.X, currentYValue, sourcePointZ.Z));
    388       }
    389 
    390       ExtremePoints = new HashSet<ThreeDimensionalPacking>(ExtremePoints.
    391         OrderBy(ep => ep.AssignedBin).
    392         ThenBy(ep => ep.Z).
    393         ThenBy(ep => ep.X).
    394         ThenBy(ep => ep.Y).
    395         ThenBy(ep => OccupiedPoints.ShortestPossibleSideFromEP(ep)));
    396     }
    397 
    398     public override ThreeDimensionalPacking FindExtremePointForItem(CuboidPackingItem measures, bool rotated, bool stackingConstraint) {
    399 
    400       CuboidPackingItem item = new CuboidPackingItem(
    401         rotated ? measures.Depth : measures.Width,
    402         measures.Height,
    403         rotated ? measures.Width : measures.Depth,
    404         measures.TargetBin);
    405 
    406       int epIndex = 0;
    407       while (epIndex < ExtremePoints.Count && (
    408         !IsPositionFeasible(item, ExtremePoints.ElementAt(epIndex)) || (stackingConstraint && !OccupiedPoints.IsStaticStable(item, ExtremePoints.ElementAt(epIndex)))
    409       )) { epIndex++; }
    410 
    411       if (epIndex < ExtremePoints.Count) {
    412         var result = ExtremePoints.ElementAt(epIndex);
    413         result.Rotated = rotated;
    414         return result;
    415       }
    416       return null;
    417     }
    418     public override ThreeDimensionalPacking FindPositionBySliding(CuboidPackingItem measures, bool rotated) {
    419       //Starting-position at upper right corner (=left bottom point of item-rectangle is at position item.width,item.height)
    420       ThreeDimensionalPacking currentPosition = new ThreeDimensionalPacking(0,
    421         BinMeasures.Width - (rotated ? measures.Depth : measures.Width),
    422         BinMeasures.Height - measures.Height,
    423         BinMeasures.Depth - (rotated ? measures.Width : measures.Depth), rotated);
    424       //Slide the item as far as possible to the bottom
    425       while (IsPositionFeasible(measures, MoveDown(currentPosition))
    426         || IsPositionFeasible(measures, MoveLeft(currentPosition))
    427         || IsPositionFeasible(measures, MoveBack(currentPosition))) {
    428         //Slide the item as far as possible to the left
    429         while (IsPositionFeasible(measures, MoveLeft(currentPosition))
    430         || IsPositionFeasible(measures, MoveBack(currentPosition))) {
    431           //Slide the item as far as possible to the back
    432           while (IsPositionFeasible(measures, MoveBack(currentPosition))) {
    433             currentPosition = MoveBack(currentPosition);
    434           }
    435           if (IsPositionFeasible(measures, MoveLeft(currentPosition)))
    436             currentPosition = MoveLeft(currentPosition);
    437         }
    438         if (IsPositionFeasible(measures, MoveDown(currentPosition)))
    439           currentPosition = MoveDown(currentPosition);
    440       }
    441 
    442       return IsPositionFeasible(measures, currentPosition) ? currentPosition : null;
    443     }
    444     private static ThreeDimensionalPacking MoveLeft(ThreeDimensionalPacking original) {
    445       return new ThreeDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Z, original.Rotated);
    446     }
    447     private static ThreeDimensionalPacking MoveDown(ThreeDimensionalPacking original) {
    448       return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Z, original.Rotated);
    449     }
    450     private static ThreeDimensionalPacking MoveBack(ThreeDimensionalPacking original) {
    451       return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y, original.Z - 1, original.Rotated);
    452     }
    453   }
    454 
    455 
    456 
    457276}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj

    r9593 r9596  
    166166    <Compile Include="Analyzers\BinPackingAnalyzer.cs" />
    167167    <Compile Include="Decoders\2D\BL\BottomLeftMultiComponentVectorDecoder.cs" />
    168     <Compile Include="Decoders\2D\TwoDimensionalPackingFunctions.cs" />
    169168    <Compile Include="Decoders\2D\EP\ExtremePointGroupingVectorDecoder2D.cs" />
    170169    <Compile Include="Decoders\2D\EP\ExtremePointMultiComponentVectorDecoder2D.cs" />
    171170    <Compile Include="Decoders\2D\EP\ExtremePointPackingSequenceDecoder2D.cs" />
    172     <Compile Include="Decoders\3D\ThreeDimensionalPackingFunctions.cs" />
    173171    <Compile Include="Decoders\3D\EP\ExtremePointMultiComponentVectorDecoder3D.cs" />
    174172    <Compile Include="Decoders\3D\EP\ExtremePointGroupingVectorDecoder3D.cs" />
     
    180178    <Compile Include="Decoders\2D\BL\BottomLeftPackingSequenceDecoder.cs" />
    181179    <Compile Include="Decoders\3D\EP\ISOContainerMultiComponentVectorDecoder3D.cs" />
    182     <Compile Include="Decoders\SequentialPackingFunctions.cs">
    183       <SubType>Code</SubType>
    184     </Compile>
    185180    <Compile Include="Decoders\PackingSolutionDecoder.cs" />
    186     <Compile Include="Dimensions\OccupiedPoints3D.cs" />
    187     <Compile Include="Dimensions\OccupiedPoints2D.cs" />
    188     <Compile Include="Dimensions\OccupiedPoints.cs" />
    189181    <Compile Include="Encodings\GroupingVector\GroupingVectorSwap2Manipulator.cs" />
    190182    <Compile Include="Encodings\GroupingVector\GroupingVectorSinglePointCrossover.cs" />
     
    211203    <Compile Include="Encodings\GroupingVector\GroupingVectorManipulator.cs" />
    212204    <Compile Include="Encodings\GroupingVector\GroupingVectorRandomCreator.cs" />
     205    <Compile Include="Encodings\MultiComponentVector\SequenceBasedMultiComponentVectorCrossover.cs" />
    213206    <Compile Include="Encodings\MultiComponentVector\BinBasedMultiComponentVectorCrossover.cs" />
    214     <Compile Include="Encodings\MultiComponentVector\SequenceBasedMultiComponentVectorCrossover.cs" />
    215207    <Compile Include="Encodings\MultiComponentVector\Moves\Multi\Attributes\ChangePositionMoveAttribute.cs" />
    216208    <Compile Include="Encodings\MultiComponentVector\Moves\Triple\Attributes\MCVTripleMoveAttribute.cs" />
     
    241233    <Compile Include="Encodings\MultiComponentVector\MultiComponentVectorRandomCreator.cs" />
    242234    <Compile Include="Encodings\MultiComponentVector\ThreeWayMultiComponentVectorManipulator.cs" />
     235    <Compile Include="Encodings\PackingPlans\BinPacking2D.cs" />
     236    <Compile Include="Encodings\PackingPlans\BinPacking3D.cs" />
     237    <Compile Include="Encodings\PackingPlans\BinPacking.cs" />
    243238    <Compile Include="Encodings\PackingPlans\PackingPlan.cs" />
    244239    <Compile Include="Encodings\PackingSequence\Moves\Insertion\ExhaustiveInsertionMoveGenerator.cs" />
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Instances/BPPORLIBParser.cs

    r9348 r9596  
    9090
    9191      for (int k = 0; k < Items; k++) {
    92         if (reader.EndOfStream) throw new InvalidDataException("Unexpected End of Stream.");
     92        if (reader.EndOfStream) throw new InvalidDataException("Unexpected End of Stream (at line " + k + ").");
    9393        var valLine = reader.ReadLine();
    9494        while (String.IsNullOrWhiteSpace(valLine)) valLine = reader.ReadLine();
     
    101101      }
    102102
    103       int problemClassNr = int.Parse(problemClass[0]);
    104       Name = (isThreeDimensional ? "3" : "2") + "dbpp_class_0" + problemClassNr;
    105       if (!isThreeDimensional) {
    106         if (problemClassNr >= 1 && problemClassNr <= 5)
    107           Description = "Proposed by Berkey and Wang.";
    108         else if (problemClassNr >= 6 && problemClassNr <= 10)
    109           Description = "Proposed by Martello and Vigo.";
     103      Int32 problemClassNr = -1;
     104      if (int.TryParse(problemClass[0], out problemClassNr)) {
     105        Name = (isThreeDimensional ? "3" : "2") + "dbpp_class_0" + problemClassNr;
     106        if (!isThreeDimensional) {
     107          if (problemClassNr >= 1 && problemClassNr <= 5)
     108            Description = "Proposed by Berkey and Wang.";
     109          else if (problemClassNr >= 6 && problemClassNr <= 10)
     110            Description = "Proposed by Martello and Vigo.";
     111        } else {
     112          if (problemClassNr >= 1 && problemClassNr <= 5)
     113            Description = "Proposed by Martello and Vigo.";
     114          else if (problemClassNr >= 6 && problemClassNr <= 9)
     115            Description = "Proposed by Berkey and Wang.";
     116        }
    110117      } else {
    111         if (problemClassNr >= 1 && problemClassNr <= 5)
    112           Description = "Proposed by Martello and Vigo.";
    113         else if (problemClassNr >= 6 && problemClassNr <= 9)
    114           Description = "Proposed by Berkey and Wang.";
     118        Name = "Unknown";
     119        Description = "<Missing>";
    115120      }
    116121     
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Plugin.cs

    r9593 r9596  
    2626  /// Plugin class for HeuristicLab.Problems.BinPacking plugin.
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.9563")]
     28  [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.9593")]
    2929  [PluginFile("HeuristicLab.Problems.BinPacking-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Common", "3.3")]
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs

    r9593 r9596  
    5555    public override ThreeDimensionalPacking Origin { get { return new ThreeDimensionalPacking(0, 0, 0, 0); } }
    5656    public override int MultipliedMeasures { get { return Width * Height * Depth; } }
    57    
     57
     58    public override bool EnclosesPoint(ThreeDimensionalPacking myPosition, ThreeDimensionalPacking checkedPoint) {
     59      var c = new CuboidDiagonal(myPosition, this);
     60      return (c.x1 <= checkedPoint.X &&
     61                c.x2 >= checkedPoint.X &&
     62                c.y1 <= checkedPoint.Y &&
     63                c.y2 >= checkedPoint.Y &&
     64                c.z1 <= checkedPoint.Z &&
     65                c.z2 >= checkedPoint.Z);
     66    }
    5867    public override bool Encloses(ThreeDimensionalPacking checkedPosition, PackingShape<ThreeDimensionalPacking> checkedShape) {
    5968      return Encloses(checkedPosition, (CuboidPackingShape) checkedShape);
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/PackingShape.cs

    r9593 r9596  
    3939    }
    4040
     41    public abstract bool EnclosesPoint(D myPosition, D checkedPoint);
    4142    public abstract bool Encloses(D checkedPosition, PackingShape<D> checkedShape);
    4243    public abstract bool Overlaps(D myPosition, D checkedPosition, PackingShape<D> checkedShape);
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/RectangularPackingShape.cs

    r9593 r9596  
    5151    public override int MultipliedMeasures { get { return Height * Width; } }
    5252
     53    public override bool EnclosesPoint(TwoDimensionalPacking myPosition, TwoDimensionalPacking checkedPoint) {
     54      var r = new RectangleDiagonal(myPosition, this);
     55      return (r.x1 <= checkedPoint.X &&
     56                r.x2 >= checkedPoint.X &&
     57                r.y1 <= checkedPoint.Y &&
     58                r.y2 >= checkedPoint.Y);
     59    }
    5360    public override bool Encloses(TwoDimensionalPacking checkedPosition, PackingShape<TwoDimensionalPacking> checkedShape) {
    5461      return Encloses(checkedPosition, (RectangularPackingShape)checkedShape);
Note: See TracChangeset for help on using the changeset viewer.