- Timestamp:
- 06/07/13 01:20:12 (12 years ago)
- 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 33 33 [Item("Occupated Points", "A datastructure holding all currently occupied points of a packing-bin.")] 34 34 [StorableClass] 35 public abstract class OccupiedPoints<D, I> : Item35 public abstract class OccupiedPoints<D, B, I> : Item 36 36 where D : class, IPackingDimensions 37 where B : PackingShape<D>, IPackingBin 37 38 where I : PackingShape<D>, IPackingItem { 38 39 39 public OccupiedPoints( ) : base() { }40 public OccupiedPoints(B binMeasures) : base() { } 40 41 [StorableConstructor] 41 42 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) 43 44 : base(original, cloner) { 44 45 } … … 51 52 public abstract bool IsStaticStable(I item, D ep); 52 53 public abstract bool WeightIsSupported(I item, D ep, ItemList<I> items); 53 54 public abstract void ChangeBinMeasures(B binMeasures); 54 55 } 55 56 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/OccupiedPoints2D.cs
r9593 r9596 35 35 [Item("Occupated Points 2D", "A datastructure holding all currently occupied points of a 2D packing-bin.")] 36 36 [StorableClass] 37 public class OccupiedPoints2D : OccupiedPoints<TwoDimensionalPacking, RectangularPacking Item> {37 public class OccupiedPoints2D : OccupiedPoints<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> { 38 38 39 39 [Storable] 40 40 private int[,] occupiedPoints { get; set; } 41 41 42 public OccupiedPoints2D(RectangularPackingBin binMeasures) : base( ) {42 public OccupiedPoints2D(RectangularPackingBin binMeasures) : base(binMeasures) { 43 43 occupiedPoints = new int[binMeasures.Width, binMeasures.Height]; 44 44 for (int w = 0; w < binMeasures.Width; w++) { … … 67 67 return true; 68 68 } 69 70 69 public override void OccupyPoints(RectangularPackingItem measures, TwoDimensionalPacking position, int itemID) { 71 70 int width = position.Rotated ? measures.Height : measures.Width; … … 77 76 } 78 77 } 79 80 78 public override bool IsPointOccupied(TwoDimensionalPacking point) { 81 79 return occupiedPoints[point.X, point.Y] != -1; 82 80 } 83 84 81 public override int ShortestPossibleSideFromEP(TwoDimensionalPacking ep) { 85 82 int shortestSide = int.MaxValue; … … 102 99 return shortestSide; 103 100 } 104 105 101 public override bool IsStaticStable(RectangularPackingItem item, TwoDimensionalPacking ep) { 106 102 //For the current implementation there was no need for stacking-constraints in the 2D-case. 107 103 //But it could be interesting for shelf-packing applications! 108 return true;104 throw new NotImplementedException(); 109 105 } 110 106 public override bool WeightIsSupported(RectangularPackingItem item, TwoDimensionalPacking ep, ItemList<RectangularPackingItem> items) { 111 107 return true; 112 108 } 109 public override void ChangeBinMeasures(RectangularPackingBin binMeasures) { 110 throw new NotImplementedException(); 111 } 113 112 } 114 113 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/OccupiedPoints3D.cs
r9593 r9596 35 35 [Item("Occupied Points 3D", "A datastructure holding all currently occupied points of a 3D packing-bin.")] 36 36 [StorableClass] 37 public class OccupiedPoints3D : OccupiedPoints<ThreeDimensionalPacking, CuboidPacking Item> {37 public class OccupiedPoints3D : OccupiedPoints<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> { 38 38 39 39 [Storable] 40 40 private int[, ,] occupiedPoints { get; set; } 41 41 42 public OccupiedPoints3D(CuboidPackingBin binMeasures) {42 public OccupiedPoints3D(CuboidPackingBin binMeasures) : base(binMeasures) { 43 43 occupiedPoints = new int[binMeasures.Width, binMeasures.Height, binMeasures.Depth]; 44 44 for (int w = 0; w < binMeasures.Width; w++) { … … 71 71 return true; 72 72 } 73 74 73 public override void OccupyPoints(CuboidPackingItem measures, ThreeDimensionalPacking position, int itemID) { 75 74 int width = position.Rotated ? measures.Depth : measures.Width; … … 83 82 } 84 83 } 85 86 84 public override bool IsPointOccupied(ThreeDimensionalPacking point) { 87 85 return occupiedPoints[point.X, point.Y, point.Z] != -1; 88 86 } 89 90 87 public override int ShortestPossibleSideFromEP(ThreeDimensionalPacking ep) { 91 88 int shortestSide = int.MaxValue; … … 114 111 return shortestSide; 115 112 } 116 117 118 113 public override bool IsStaticStable(CuboidPackingItem item, ThreeDimensionalPacking ep) { 119 114 //Static stability is given, if item is placed on the ground … … 164 159 return false; 165 160 } 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 } 167 176 } 168 177 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/ThreeDimensionalPacking.cs
r9440 r9596 81 81 return base.GetHashCode() + 13 * X + 17 * Y + 23 * Z; 82 82 } 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 } 83 103 } 84 104 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Dimensions/TwoDimensionalPacking.cs
r9440 r9596 77 77 return base.GetHashCode() + 13 * X + 17 * Y; 78 78 } 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 79 94 } 80 95 }
Note: See TracChangeset
for help on using the changeset viewer.