Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/07/13 01:20:12 (12 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/HeuristicLab.Problems.BinPacking/3.3/Dimensions
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.