Changeset 14048 for branches/HeuristicLab.BinPacking
- Timestamp:
- 07/12/16 19:54:35 (8 years ago)
- Location:
- branches/HeuristicLab.BinPacking
- Files:
-
- 49 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/BinPacking2D.cs
r14046 r14048 31 31 [Item("BinPacking2D", "Represents a single-bin packing for a 2D bin-packing problem.")] 32 32 [StorableClass] 33 public class BinPacking2D : BinPacking< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> {33 public class BinPacking2D : BinPacking<PackingPosition, RectangularPackingShape, RectangularPackingItem> { 34 34 35 35 public BinPacking2D(RectangularPackingShape binMeasures) 36 36 : base(binMeasures) { 37 ExtremePoints = new SortedSet< TwoDimensionalPacking>(new EPComparer2D());37 ExtremePoints = new SortedSet<PackingPosition>(new EPComparer2D()); 38 38 ExtremePoints.Add(binMeasures.Origin); 39 39 } … … 42 42 protected BinPacking2D(BinPacking2D original, Cloner cloner) 43 43 : base(original, cloner) { 44 this.ExtremePoints = new SortedSet< TwoDimensionalPacking>(original.ExtremePoints, new EPComparer2D());44 this.ExtremePoints = new SortedSet<PackingPosition>(original.ExtremePoints, new EPComparer2D()); 45 45 } 46 46 public override IDeepCloneable Clone(Cloner cloner) { … … 48 48 } 49 49 50 protected override void GenerateNewExtremePointsForNewItem(RectangularPackingItem newItem, TwoDimensionalPackingposition) {50 protected override void GenerateNewExtremePointsForNewItem(RectangularPackingItem newItem, PackingPosition position) { 51 51 52 52 int newWidth = position.Rotated ? newItem.Height : newItem.Width; … … 54 54 55 55 //Find ExtremePoints beginning from sourcepointX 56 var sourcePointX = new TwoDimensionalPacking(0, position.X + newWidth, position.Y);56 var sourcePointX = new PackingPosition(0, position.X + newWidth, position.Y); 57 57 if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height) { 58 58 //Traversing down the y-axis 59 var newPoint = new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y - 1);59 var newPoint = new PackingPosition(0, sourcePointX.X, sourcePointX.Y - 1); 60 60 while (sourcePointX.Y > 0 && !IsPointOccupied(newPoint)) { 61 61 sourcePointX = newPoint; 62 newPoint = new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y - 1);63 } 64 ExtremePoints.Add(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y));62 newPoint = new PackingPosition(0, sourcePointX.X, sourcePointX.Y - 1); 63 } 64 ExtremePoints.Add(new PackingPosition(0, sourcePointX.X, sourcePointX.Y)); 65 65 } 66 66 67 67 //Find ExtremePoints beginning from sourcepointY 68 var sourcePointY = new TwoDimensionalPacking(0, position.X, position.Y + newItem.Height);68 var sourcePointY = new PackingPosition(0, position.X, position.Y + newItem.Height); 69 69 if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height) { 70 70 //Traversing down the x-axis 71 var newPoint = new TwoDimensionalPacking(0, sourcePointY.X - 1, sourcePointY.Y);71 var newPoint = new PackingPosition(0, sourcePointY.X - 1, sourcePointY.Y); 72 72 while (sourcePointY.X > 0 && !IsPointOccupied(newPoint)) { 73 73 sourcePointY = newPoint; 74 newPoint = new TwoDimensionalPacking(0, sourcePointY.X - 1, sourcePointY.Y);75 } 76 ExtremePoints.Add(new TwoDimensionalPacking(0, sourcePointY.X, sourcePointY.Y));74 newPoint = new PackingPosition(0, sourcePointY.X - 1, sourcePointY.Y); 75 } 76 ExtremePoints.Add(new PackingPosition(0, sourcePointY.X, sourcePointY.Y)); 77 77 } 78 78 … … 85 85 } 86 86 87 public override TwoDimensionalPackingFindExtremePointForItem(RectangularPackingItem measures, bool rotated, bool stackingConstraints) {87 public override PackingPosition FindExtremePointForItem(RectangularPackingItem measures, bool rotated, bool stackingConstraints) { 88 88 RectangularPackingItem item = new RectangularPackingItem( 89 89 rotated ? measures.Height : measures.Width, … … 97 97 var currentPoint = ExtremePoints.ElementAt(epIndex); 98 98 99 var result = new TwoDimensionalPacking(currentPoint.AssignedBin, currentPoint.X, currentPoint.Y, rotated);99 var result = new PackingPosition(currentPoint.AssignedBin, currentPoint.X, currentPoint.Y, rotated); 100 100 return result; 101 101 } 102 102 return null; 103 103 } 104 public override TwoDimensionalPackingFindPositionBySliding(RectangularPackingItem measures, bool rotated) {105 TwoDimensionalPacking currentPosition = new TwoDimensionalPacking(0,104 public override PackingPosition FindPositionBySliding(RectangularPackingItem measures, bool rotated) { 105 PackingPosition currentPosition = new PackingPosition(0, 106 106 BinMeasures.Width - (rotated ? measures.Height : measures.Width), 107 107 BinMeasures.Height - (rotated ? measures.Width : measures.Height), rotated); 108 108 //Slide the item as far as possible to the left 109 while (IsPositionFeasible(measures, TwoDimensionalPacking.MoveLeft(currentPosition))110 || IsPositionFeasible(measures, TwoDimensionalPacking.MoveDown(currentPosition))) {109 while (IsPositionFeasible(measures, PackingPosition.MoveLeft(currentPosition)) 110 || IsPositionFeasible(measures, PackingPosition.MoveDown(currentPosition))) { 111 111 //Slide the item as far as possible to the bottom 112 while (IsPositionFeasible(measures, TwoDimensionalPacking.MoveDown(currentPosition))) {113 currentPosition = TwoDimensionalPacking.MoveDown(currentPosition);114 } 115 if (IsPositionFeasible(measures, TwoDimensionalPacking.MoveLeft(currentPosition)))116 currentPosition = TwoDimensionalPacking.MoveLeft(currentPosition);112 while (IsPositionFeasible(measures, PackingPosition.MoveDown(currentPosition))) { 113 currentPosition = PackingPosition.MoveDown(currentPosition); 114 } 115 if (IsPositionFeasible(measures, PackingPosition.MoveLeft(currentPosition))) 116 currentPosition = PackingPosition.MoveLeft(currentPosition); 117 117 } 118 118 … … 165 165 } 166 166 167 public override int ShortestPossibleSideFromPoint( TwoDimensionalPackingposition) {167 public override int ShortestPossibleSideFromPoint(PackingPosition position) { 168 168 int shortestSide = int.MaxValue; 169 169 int width = BinMeasures.Width; … … 173 173 return shortestSide; 174 174 175 TwoDimensionalPacking current = new TwoDimensionalPacking(0, position.X, position.Y);176 while (current.X < width && IsPointOccupied(current)) { current = TwoDimensionalPacking.MoveRight(current); }175 PackingPosition current = new PackingPosition(0, position.X, position.Y); 176 while (current.X < width && IsPointOccupied(current)) { current = PackingPosition.MoveRight(current); } 177 177 if (current.X - position.X < shortestSide) 178 178 shortestSide = current.X - position.X; 179 179 180 180 181 current = new TwoDimensionalPacking(0, position.X, position.Y);182 while (current.Y < height && IsPointOccupied(current)) { current = TwoDimensionalPacking.MoveUp(current); }181 current = new PackingPosition(0, position.X, position.Y); 182 while (current.Y < height && IsPointOccupied(current)) { current = PackingPosition.MoveUp(current); } 183 183 if (current.Y - position.Y < shortestSide) 184 184 shortestSide = current.Y - position.Y; … … 186 186 return shortestSide; 187 187 } 188 public override bool IsStaticStable(RectangularPackingItem item, TwoDimensionalPackingposition) {188 public override bool IsStaticStable(RectangularPackingItem item, PackingPosition position) { 189 189 throw new NotImplementedException(); 190 190 } … … 196 196 } 197 197 } 198 protected override void AddNewItemToOccupationLayers(int itemID, RectangularPackingItem measures, TwoDimensionalPackingposition) {198 protected override void AddNewItemToOccupationLayers(int itemID, RectangularPackingItem measures, PackingPosition position) { 199 199 int x1 = position.X / 10; 200 200 int x2 = (position.X + (position.Rotated ? measures.Height : measures.Width)) / 10; … … 203 203 OccupationLayers[i].Add(itemID); 204 204 } 205 protected override List<int> GetLayerItemIDs( TwoDimensionalPackingposition) {205 protected override List<int> GetLayerItemIDs(PackingPosition position) { 206 206 return OccupationLayers[position.X / 10]; 207 207 } 208 protected override List<int> GetLayerItemIDs(RectangularPackingItem measures, TwoDimensionalPackingposition) {208 protected override List<int> GetLayerItemIDs(RectangularPackingItem measures, PackingPosition position) { 209 209 List<int> result = new List<int>(); 210 210 int x1 = position.X / 10; … … 217 217 } 218 218 } 219 public class EPComparer2D : IComparer< TwoDimensionalPacking> {220 public int Compare( TwoDimensionalPacking a, TwoDimensionalPackingb) {219 public class EPComparer2D : IComparer<PackingPosition> { 220 public int Compare(PackingPosition a, PackingPosition b) { 221 221 int result = a.X.CompareTo(b.X); 222 222 if (result == 0) -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Decoders/BL/BottomLeftGroupingVectorDecoder.cs
r14047 r14048 31 31 [Item("Identical bin two dimensional grouping vector decoder", "<Description missing...>")] 32 32 [StorableClass] 33 public class BottomLeftGroupingVectorDecoder : PackingSolutionDecoder< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>, I2DGVDecoder {33 public class BottomLeftGroupingVectorDecoder : PackingSolutionDecoder<PackingPosition, RectangularPackingShape, RectangularPackingItem>, I2DGVDecoder { 34 34 public BottomLeftGroupingVectorDecoder() : base() {} 35 35 [StorableConstructor] … … 42 42 } 43 43 44 public override PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) {44 public override PackingPlan<PackingPosition, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 45 45 var solution = encodedSolution as GroupingVectorEncoding; 46 46 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Decoders/BL/BottomLeftMultiComponentVectorDecoder.cs
r14047 r14048 31 31 [Item("Identical bin two dimensional multi component vector decoder", "<Description missing...>")] 32 32 [StorableClass] 33 public class BottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder< TwoDimensionalPacking,RectangularPackingShape, RectangularPackingItem>, I2DMCVDecoder {33 public class BottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder<PackingPosition,RectangularPackingShape, RectangularPackingItem>, I2DMCVDecoder { 34 34 public BottomLeftMultiComponentVectorDecoder() : base() {} 35 35 [StorableConstructor] … … 42 42 } 43 43 44 public override PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) {44 public override PackingPlan<PackingPosition, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 45 45 var solution = encodedSolution as MultiComponentVectorEncoding; 46 46 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponent Vector"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Decoders/BL/BottomLeftPackingSequenceDecoder.cs
r14047 r14048 32 32 [Item("Identical bin, two dimensional, direct permutation decoder", "<Description missing...>")] 33 33 [StorableClass] 34 public class BottomLeftPackingSequenceDecoder : PackingSolutionDecoder< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>, I2DPSDecoder {34 public class BottomLeftPackingSequenceDecoder : PackingSolutionDecoder<PackingPosition, RectangularPackingShape, RectangularPackingItem>, I2DPSDecoder { 35 35 36 36 public BottomLeftPackingSequenceDecoder(): base() { } … … 44 44 } 45 45 46 public override PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) {46 public override PackingPlan<PackingPosition, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 47 47 var solution = encodedSolution as PackingSequenceEncoding; 48 48 if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Decoders/EP/ExtremePointGroupingVectorDecoder2D.cs
r14047 r14048 32 32 [Item("Identical bin, two dimensional, extreme points based decoder for the GroupingVector encoding.", "<Description missing...>")] 33 33 [StorableClass] 34 public class ExtremePointGroupingVectorDecoder2D : PackingSolutionDecoder< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>, I2DGVDecoder {34 public class ExtremePointGroupingVectorDecoder2D : PackingSolutionDecoder<PackingPosition, RectangularPackingShape, RectangularPackingItem>, I2DGVDecoder { 35 35 public ExtremePointGroupingVectorDecoder2D () : base() {} 36 36 [StorableConstructor] … … 43 43 } 44 44 45 public static PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> Decode(GroupingVectorEncoding solution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) {45 public static PackingPlan<PackingPosition, RectangularPackingShape, RectangularPackingItem> Decode(GroupingVectorEncoding solution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 46 46 Solution result = new Solution(binMeasures, true, false); 47 47 result.Pack(solution, itemMeasures); … … 49 49 } 50 50 51 public override PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) {51 public override PackingPlan<PackingPosition, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 52 52 var solution = encodedSolution as GroupingVectorEncoding; 53 53 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Decoders/EP/ExtremePointMultiComponentVectorDecoder2D.cs
r14047 r14048 31 31 [Item("Identical bin, two dimensional, extreme points based decoder for the MultiComponentVector encoding.", "<Description missing...>")] // TODO 32 32 [StorableClass] 33 public class ExtremePointMultiComponentVectorDecoder2D : PackingSolutionDecoder< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>, I2DMCVDecoder {33 public class ExtremePointMultiComponentVectorDecoder2D : PackingSolutionDecoder<PackingPosition, RectangularPackingShape, RectangularPackingItem>, I2DMCVDecoder { 34 34 public ExtremePointMultiComponentVectorDecoder2D () : base() {} 35 35 [StorableConstructor] … … 42 42 } 43 43 44 public static PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> Decode(MultiComponentVectorEncoding solution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) {44 public static PackingPlan<PackingPosition, RectangularPackingShape, RectangularPackingItem> Decode(MultiComponentVectorEncoding solution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 45 45 Solution result = new Solution(binMeasures, true, false); 46 46 result.Pack(solution, itemMeasures); … … 48 48 } 49 49 50 public override PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) {50 public override PackingPlan<PackingPosition, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 51 51 var solution = encodedSolution as MultiComponentVectorEncoding; 52 52 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Decoders/EP/ExtremePointPackingSequenceDecoder2D.cs
r14047 r14048 32 32 [Item("Identical bin, two dimensional, extreme points based decoder for the PackingSequence encoding.", "<Description missing...>")] // TODO 33 33 [StorableClass] 34 public class ExtremePointPackingSequenceDecoder2D : PackingSolutionDecoder< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>, I2DPSDecoder {34 public class ExtremePointPackingSequenceDecoder2D : PackingSolutionDecoder<PackingPosition, RectangularPackingShape, RectangularPackingItem>, I2DPSDecoder { 35 35 public ExtremePointPackingSequenceDecoder2D () : base() {} 36 36 [StorableConstructor] … … 44 44 45 45 46 public override PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) {46 public override PackingPlan<PackingPosition, RectangularPackingShape, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingShape binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 47 47 var solution = encodedSolution as PackingSequenceEncoding; 48 48 if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/HeuristicLab.Problems.BinPacking2D-3.3.csproj
r14047 r14048 172 172 <Compile Include="MoveEvaluators\PackingMoveEvaluator2DMCV.cs" /> 173 173 <Compile Include="MoveEvaluators\PackingMoveEvaluator2DPS.cs" /> 174 <Compile Include="PackingPosition.cs" /> 174 175 <Compile Include="PackingRatioRectangularIdenticalBinEvaluator.cs" /> 175 176 <Compile Include="Plugin.cs" /> … … 179 180 <Compile Include="RectangularPackingShape.cs" /> 180 181 <Compile Include="Solution.cs" /> 181 <Compile Include="TwoDimensionalPacking.cs" />182 182 </ItemGroup> 183 183 <ItemGroup> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/MoveEvaluators/PackingMoveEvaluator2DGV.cs
r14046 r14048 29 29 [Item("GroupingVectorMoveEvaluator2D", "Class for evaluating packing moves for 2dimensional problems.")] 30 30 [StorableClass] 31 public class PackingMoveEvaluator2DGV : PackingMoveEvaluator< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>, ISingleObjectiveMoveEvaluator, IGroupingVectorMoveOperator, I2DOperator {31 public class PackingMoveEvaluator2DGV : PackingMoveEvaluator<PackingPosition, RectangularPackingShape, RectangularPackingItem>, ISingleObjectiveMoveEvaluator, IGroupingVectorMoveOperator, I2DOperator { 32 32 [StorableConstructor] 33 33 protected PackingMoveEvaluator2DGV(bool deserializing) : base(deserializing) { } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/MoveEvaluators/PackingMoveEvaluator2DMCV.cs
r14046 r14048 29 29 [Item("MultiComponentVectorMoveEvaluator2D", "Class for evaluating packing moves for 2dimensional problems.")] 30 30 [StorableClass] 31 public class PackingMoveEvaluator2DMCV : PackingMoveEvaluator< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>, ISingleObjectiveMoveEvaluator, IMultiComponentVectorMoveOperator, I2DOperator {31 public class PackingMoveEvaluator2DMCV : PackingMoveEvaluator<PackingPosition, RectangularPackingShape, RectangularPackingItem>, ISingleObjectiveMoveEvaluator, IMultiComponentVectorMoveOperator, I2DOperator { 32 32 [StorableConstructor] 33 33 protected PackingMoveEvaluator2DMCV(bool deserializing) : base(deserializing) { } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/MoveEvaluators/PackingMoveEvaluator2DPS.cs
r14046 r14048 29 29 [Item("PackingSequenceMoveEvaluator2D", "Class for evaluating packing moves for 2dimensional problems.")] 30 30 [StorableClass] 31 public class PackingMoveEvaluator2DPS : PackingMoveEvaluator< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>, ISingleObjectiveMoveEvaluator, IPackingSequenceMoveOperator, I2DOperator {31 public class PackingMoveEvaluator2DPS : PackingMoveEvaluator<PackingPosition, RectangularPackingShape, RectangularPackingItem>, ISingleObjectiveMoveEvaluator, IPackingSequenceMoveOperator, I2DOperator { 32 32 [StorableConstructor] 33 33 protected PackingMoveEvaluator2DPS(bool deserializing) : base(deserializing) { } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/PackingPosition.cs
r14047 r14048 20 20 #endregion 21 21 22 using System.Text;23 22 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 23 using HeuristicLab.Core; 25 24 using HeuristicLab.Common; 26 using HeuristicLab.Problems.BinPacking;27 25 28 26 namespace HeuristicLab.Problems.BinPacking2D { 29 [Item(" Two Dimensional Packing", "Represents a packing-position associated with a two dimensional packing-problem.")]27 [Item("Packing Position (2d)", "Represents a packing-position associated with a two dimensional packing-problem.")] 30 28 [StorableClass] 31 // TwoDimensionalPackingis an immutable class (and handled as value type concerning Equals and GetHashCode())32 public class TwoDimensionalPacking : PackingDimensions{29 // PackingPosition is an immutable class (and handled as value type concerning Equals and GetHashCode()) 30 public class PackingPosition : BinPacking.PackingPosition { 33 31 [Storable] 34 32 private readonly int x; … … 40 38 41 39 [StorableConstructor] 42 protected TwoDimensionalPacking(bool deserializing) : base(deserializing) { }43 protected TwoDimensionalPacking(TwoDimensionalPackingoriginal, Cloner cloner)40 protected PackingPosition(bool deserializing) : base(deserializing) { } 41 protected PackingPosition(PackingPosition original, Cloner cloner) 44 42 : base(original, cloner) { 45 43 x = original.X; … … 47 45 } 48 46 49 public TwoDimensionalPacking(int assignedBin, int x, int y, bool rotated = false)47 public PackingPosition(int assignedBin, int x, int y, bool rotated = false) 50 48 : base(assignedBin, rotated) { 51 49 this.x = x; … … 54 52 55 53 public override IDeepCloneable Clone(Cloner cloner) { 56 return new TwoDimensionalPacking(this, cloner);54 return new PackingPosition(this, cloner); 57 55 } 58 56 … … 62 60 63 61 public override bool Equals(object obj) { 64 var other = obj as TwoDimensionalPacking;62 var other = obj as PackingPosition; 65 63 if (other != null) 66 64 return (other.X == this.X && other.Y == this.Y && base.Equals(other)); … … 72 70 } 73 71 74 public static TwoDimensionalPacking MoveLeft(TwoDimensionalPackingoriginal) {75 return new TwoDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Rotated);72 public static PackingPosition MoveLeft(PackingPosition original) { 73 return new PackingPosition(original.AssignedBin, original.X - 1, original.Y, original.Rotated); 76 74 } 77 public static TwoDimensionalPacking MoveDown(TwoDimensionalPackingoriginal) {78 return new TwoDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Rotated);75 public static PackingPosition MoveDown(PackingPosition original) { 76 return new PackingPosition(original.AssignedBin, original.X, original.Y - 1, original.Rotated); 79 77 } 80 78 81 public static TwoDimensionalPacking MoveRight(TwoDimensionalPackingoriginal) {82 return new TwoDimensionalPacking(original.AssignedBin, original.X + 1, original.Y, original.Rotated);79 public static PackingPosition MoveRight(PackingPosition original) { 80 return new PackingPosition(original.AssignedBin, original.X + 1, original.Y, original.Rotated); 83 81 } 84 public static TwoDimensionalPacking MoveUp(TwoDimensionalPackingoriginal) {85 return new TwoDimensionalPacking(original.AssignedBin, original.X, original.Y + 1, original.Rotated);82 public static PackingPosition MoveUp(PackingPosition original) { 83 return new PackingPosition(original.AssignedBin, original.X, original.Y + 1, original.Rotated); 86 84 } 87 85 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/PackingRatioRectangularIdenticalBinEvaluator.cs
r14046 r14048 29 29 [Item("Packing-Ratio Rectangular Identical-Bin Evaluator", "Represents an evaluation-algorithm for rectangular-shaped bin-packing problems with identical bins which calculates the ratio between packed and unpacked space. Found in Falkenauer:1996")] 30 30 [StorableClass] 31 public class PackingRatioRectangularIdenticalBinEvaluator : PackingRatioRegularIdenticalBinEvaluator< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> {31 public class PackingRatioRectangularIdenticalBinEvaluator : PackingRatioRegularIdenticalBinEvaluator<PackingPosition, RectangularPackingShape, RectangularPackingItem> { 32 32 33 33 [StorableConstructor] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/RectangularIdenticalBinPackingProblem.cs
r14046 r14048 38 38 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 300)] 39 39 // TODO: only support 2d BPPData 40 public class RectangularIdenticalBinPackingProblem : BinPackingProblem< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>, IProblemInstanceConsumer<BPPData>, IProblemInstanceExporter<BPPData> {40 public class RectangularIdenticalBinPackingProblem : BinPackingProblem<PackingPosition, RectangularPackingShape, RectangularPackingItem>, IProblemInstanceConsumer<BPPData>, IProblemInstanceExporter<BPPData> { 41 41 42 42 #region Default Instance … … 97 97 } 98 98 public RectangularIdenticalBinPackingProblem() : base( 99 new PackingPlanEvaluationAlgorithm<Permutation, TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>()) {99 new PackingPlanEvaluationAlgorithm<Permutation, PackingPosition, RectangularPackingShape, RectangularPackingItem>()) { 100 100 } 101 101 … … 174 174 protected override void RemoveTooBigItems() { 175 175 PackingItemMeasures.RemoveAll(pi => 176 !PackingBinMeasures.Encloses(new TwoDimensionalPacking(0, 0, 0, false), pi) &&177 !PackingBinMeasures.Encloses(new TwoDimensionalPacking(0, 0, 0, true), pi));176 !PackingBinMeasures.Encloses(new PackingPosition(0, 0, 0, false), pi) && 177 !PackingBinMeasures.Encloses(new PackingPosition(0, 0, 0, true), pi)); 178 178 } 179 179 #endregion -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/RectangularPackingShape.cs
r14046 r14048 32 32 [Item("RectangularPackingShape", "Represents the rectangular measures (width, height) of a two-dimensional bin-packing object.")] 33 33 [StorableClass] 34 public class RectangularPackingShape : PackingShape< TwoDimensionalPacking>, IComparable<RectangularPackingShape> {34 public class RectangularPackingShape : PackingShape<PackingPosition>, IComparable<RectangularPackingShape> { 35 35 public int Height { 36 36 get { return ((IFixedValueParameter<IntValue>)Parameters["Height"]).Value.Value; } … … 86 86 87 87 #region Helpers 88 public override TwoDimensionalPacking Origin { get { return new TwoDimensionalPacking(0, 0, 0); } }88 public override PackingPosition Origin { get { return new PackingPosition(0, 0, 0); } } 89 89 public override int Volume { get { return Height * Width; } } 90 90 91 public override bool EnclosesPoint( TwoDimensionalPacking myPosition, TwoDimensionalPackingcheckedPoint) {91 public override bool EnclosesPoint(PackingPosition myPosition, PackingPosition checkedPoint) { 92 92 return (myPosition.X <= checkedPoint.X && 93 93 (myPosition.X + (myPosition.Rotated ? Height : Width) - 1) >= checkedPoint.X && … … 95 95 (myPosition.Y + (myPosition.Rotated ? Width : Height) - 1) >= checkedPoint.Y); 96 96 } 97 public override bool Encloses( TwoDimensionalPacking checkedPosition, PackingShape<TwoDimensionalPacking> checkedShape) {97 public override bool Encloses(PackingPosition checkedPosition, PackingShape<PackingPosition> checkedShape) { 98 98 return Encloses(checkedPosition, (RectangularPackingShape)checkedShape); 99 99 } 100 private bool Encloses( TwoDimensionalPackingcheckedPosition, RectangularPackingShape checkedShape) {100 private bool Encloses(PackingPosition checkedPosition, RectangularPackingShape checkedShape) { 101 101 return Encloses(new RectangleDiagonal(this), new RectangleDiagonal(checkedPosition, checkedShape)); 102 102 } … … 108 108 } 109 109 110 public override bool Overlaps( TwoDimensionalPacking myPosition, TwoDimensionalPacking checkedPosition, PackingShape<TwoDimensionalPacking> checkedShape) {110 public override bool Overlaps(PackingPosition myPosition, PackingPosition checkedPosition, PackingShape<PackingPosition> checkedShape) { 111 111 return Overlaps(myPosition, checkedPosition, (RectangularPackingShape)checkedShape); 112 112 } 113 private bool Overlaps( TwoDimensionalPacking myPosition, TwoDimensionalPackingcheckedPosition, RectangularPackingShape checkedShape) {113 private bool Overlaps(PackingPosition myPosition, PackingPosition checkedPosition, RectangularPackingShape checkedShape) { 114 114 return Overlaps(new RectangleDiagonal(myPosition, this), new RectangleDiagonal(checkedPosition, checkedShape)); 115 115 } … … 136 136 public int x2; 137 137 public int y2; 138 public RectangleDiagonal(RectangularPackingShape myShape) : this(new TwoDimensionalPacking(0, 0, 0), myShape) { }139 public RectangleDiagonal( TwoDimensionalPackingmyPosition, RectangularPackingShape myShape) {138 public RectangleDiagonal(RectangularPackingShape myShape) : this(new PackingPosition(0, 0, 0), myShape) { } 139 public RectangleDiagonal(PackingPosition myPosition, RectangularPackingShape myShape) { 140 140 x1 = myPosition.X; 141 141 y1 = myPosition.Y; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/Solution.cs
r14047 r14048 28 28 [Item("Bin Packing Solution (2d)", "Represents a solution for a 2D bin packing problem.")] 29 29 [StorableClass] 30 public class Solution : PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> {30 public class Solution : PackingPlan<PackingPosition, RectangularPackingShape, RectangularPackingItem> { 31 31 public Solution(RectangularPackingShape binMeasures) : this(binMeasures, false, false) { } 32 32 public Solution(RectangularPackingShape binMeasures, bool useExtremePoints, bool stackingConstraints) : base(binMeasures, useExtremePoints, stackingConstraints) { } … … 39 39 return new Solution(this, cloner); 40 40 } 41 public override BinPacking< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> NewBinPacking() {41 public override BinPacking<PackingPosition, RectangularPackingShape, RectangularPackingItem> NewBinPacking() { 42 42 return new BinPacking2D(BinMeasures); 43 43 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/BinPacking3D.cs
r14046 r14048 30 30 [Item("BinPacking3D", "Represents a single-bin packing for a 3D bin-packing problem.")] 31 31 [StorableClass] 32 public class BinPacking3D : BinPacking< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> {32 public class BinPacking3D : BinPacking<PackingPosition, CuboidPackingShape, CuboidPackingItem> { 33 33 34 34 public BinPacking3D(CuboidPackingShape binMeasures) 35 35 : base(binMeasures) { 36 ExtremePoints = new SortedSet< ThreeDimensionalPacking>(new EPComparer3D());36 ExtremePoints = new SortedSet<PackingPosition>(new EPComparer3D()); 37 37 ExtremePoints.Add(binMeasures.Origin); 38 38 } … … 42 42 : base(original, cloner) { 43 43 this.depthWasDoubled = original.depthWasDoubled; 44 this.ExtremePoints = new SortedSet< ThreeDimensionalPacking>(original.ExtremePoints, new EPComparer3D());44 this.ExtremePoints = new SortedSet<PackingPosition>(original.ExtremePoints, new EPComparer3D()); 45 45 } 46 46 public override IDeepCloneable Clone(Cloner cloner) { … … 48 48 } 49 49 50 protected override void GenerateNewExtremePointsForNewItem(CuboidPackingItem newItem, ThreeDimensionalPackingposition) {50 protected override void GenerateNewExtremePointsForNewItem(CuboidPackingItem newItem, PackingPosition position) { 51 51 int newWidth = position.Rotated ? newItem.Depth : newItem.Width; 52 52 int newDepth = position.Rotated ? newItem.Width : newItem.Depth; 53 53 54 54 //Find ExtremePoints beginning from sourcepointX 55 var sourcePointX = new ThreeDimensionalPacking(0, position.X + newWidth, position.Y, position.Z);55 var sourcePointX = new PackingPosition(0, position.X + newWidth, position.Y, position.Z); 56 56 if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height && sourcePointX.Z < BinMeasures.Depth) { 57 57 //Traversing down the y-axis 58 ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, sourcePointX.Z);59 while (current.Y > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveDown(current))) {60 current = ThreeDimensionalPacking.MoveDown(current);61 } 62 ExtremePoints.Add(( ThreeDimensionalPacking)current.Clone());63 while (current.X > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveLeft(current))) {64 current = ThreeDimensionalPacking.MoveLeft(current);58 PackingPosition current = new PackingPosition(0, sourcePointX.X, sourcePointX.Y, sourcePointX.Z); 59 while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) { 60 current = PackingPosition.MoveDown(current); 61 } 62 ExtremePoints.Add((PackingPosition)current.Clone()); 63 while (current.X > 0 && !IsPointOccupied(PackingPosition.MoveLeft(current))) { 64 current = PackingPosition.MoveLeft(current); 65 65 } 66 66 ExtremePoints.Add(current); 67 67 68 68 //Traversing down the z-axis 69 current = new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, sourcePointX.Z);70 while (current.Z > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveBack(current))) {71 current = ThreeDimensionalPacking.MoveBack(current);72 } 73 ExtremePoints.Add(( ThreeDimensionalPacking)current.Clone());74 while (current.Y > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveDown(current))) {75 current = ThreeDimensionalPacking.MoveDown(current);69 current = new PackingPosition(0, sourcePointX.X, sourcePointX.Y, sourcePointX.Z); 70 while (current.Z > 0 && !IsPointOccupied(PackingPosition.MoveBack(current))) { 71 current = PackingPosition.MoveBack(current); 72 } 73 ExtremePoints.Add((PackingPosition)current.Clone()); 74 while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) { 75 current = PackingPosition.MoveDown(current); 76 76 } 77 77 ExtremePoints.Add(current); … … 82 82 83 83 //Find ExtremePoints beginning from sourcepointY 84 var sourcePointY = new ThreeDimensionalPacking(0, position.X, position.Y + newItem.Height, position.Z);84 var sourcePointY = new PackingPosition(0, position.X, position.Y + newItem.Height, position.Z); 85 85 if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height && sourcePointY.Z < BinMeasures.Depth) { 86 86 //Traversing down the x-axis 87 ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, sourcePointY.Z);88 while (current.X > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveLeft(current))) {89 current = ThreeDimensionalPacking.MoveLeft(current);90 } 91 ExtremePoints.Add(( ThreeDimensionalPacking)current.Clone());92 while (current.Y > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveDown(current))) {93 current = ThreeDimensionalPacking.MoveDown(current);87 PackingPosition current = new PackingPosition(0, sourcePointY.X, sourcePointY.Y, sourcePointY.Z); 88 while (current.X > 0 && !IsPointOccupied(PackingPosition.MoveLeft(current))) { 89 current = PackingPosition.MoveLeft(current); 90 } 91 ExtremePoints.Add((PackingPosition)current.Clone()); 92 while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) { 93 current = PackingPosition.MoveDown(current); 94 94 } 95 95 ExtremePoints.Add(current); 96 96 97 97 //Traversing down the z-axis 98 current = new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, sourcePointY.Z);99 while (current.Z > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveBack(current))) {100 current = ThreeDimensionalPacking.MoveBack(current);101 } 102 ExtremePoints.Add(( ThreeDimensionalPacking)current.Clone());103 while (current.Y > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveDown(current))) {104 current = ThreeDimensionalPacking.MoveDown(current);98 current = new PackingPosition(0, sourcePointY.X, sourcePointY.Y, sourcePointY.Z); 99 while (current.Z > 0 && !IsPointOccupied(PackingPosition.MoveBack(current))) { 100 current = PackingPosition.MoveBack(current); 101 } 102 ExtremePoints.Add((PackingPosition)current.Clone()); 103 while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) { 104 current = PackingPosition.MoveDown(current); 105 105 } 106 106 ExtremePoints.Add(current); … … 112 112 113 113 //Find ExtremePoints beginning from sourcepointZ 114 var sourcePointZ = new ThreeDimensionalPacking(0, position.X, position.Y, position.Z + newDepth);114 var sourcePointZ = new PackingPosition(0, position.X, position.Y, position.Z + newDepth); 115 115 if (sourcePointZ.X < BinMeasures.Width && sourcePointZ.Y < BinMeasures.Height && sourcePointZ.Z < BinMeasures.Depth) { 116 116 //Traversing down the x-axis 117 ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointZ.X, sourcePointZ.Y, sourcePointZ.Z);118 while (current.X > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveLeft(current))) {119 current = ThreeDimensionalPacking.MoveLeft(current);120 } 121 ExtremePoints.Add(( ThreeDimensionalPacking)current.Clone());122 while (current.Y > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveDown(current))) {123 current = ThreeDimensionalPacking.MoveDown(current);117 PackingPosition current = new PackingPosition(0, sourcePointZ.X, sourcePointZ.Y, sourcePointZ.Z); 118 while (current.X > 0 && !IsPointOccupied(PackingPosition.MoveLeft(current))) { 119 current = PackingPosition.MoveLeft(current); 120 } 121 ExtremePoints.Add((PackingPosition)current.Clone()); 122 while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) { 123 current = PackingPosition.MoveDown(current); 124 124 } 125 125 ExtremePoints.Add(current); 126 126 127 127 //Traversing down the y-axis 128 current = new ThreeDimensionalPacking(0, sourcePointZ.X, sourcePointZ.Y, sourcePointZ.Z);129 while (current.Y > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveDown(current))) {130 current = ThreeDimensionalPacking.MoveDown(current);131 } 132 ExtremePoints.Add(( ThreeDimensionalPacking)current.Clone());133 while (current.X > 0 && !IsPointOccupied( ThreeDimensionalPacking.MoveLeft(current))) {134 current = ThreeDimensionalPacking.MoveLeft(current);128 current = new PackingPosition(0, sourcePointZ.X, sourcePointZ.Y, sourcePointZ.Z); 129 while (current.Y > 0 && !IsPointOccupied(PackingPosition.MoveDown(current))) { 130 current = PackingPosition.MoveDown(current); 131 } 132 ExtremePoints.Add((PackingPosition)current.Clone()); 133 while (current.X > 0 && !IsPointOccupied(PackingPosition.MoveLeft(current))) { 134 current = PackingPosition.MoveLeft(current); 135 135 } 136 136 ExtremePoints.Add(current); … … 146 146 } 147 147 148 public override ThreeDimensionalPackingFindExtremePointForItem(CuboidPackingItem measures, bool rotated, bool stackingConstraints) {148 public override PackingPosition FindExtremePointForItem(CuboidPackingItem measures, bool rotated, bool stackingConstraints) { 149 149 150 150 CuboidPackingItem item = new CuboidPackingItem( … … 164 164 if (epIndex < ExtremePoints.Count) { 165 165 var origPoint = ExtremePoints.ElementAt(epIndex); 166 var result = new ThreeDimensionalPacking(origPoint.AssignedBin, origPoint.X, origPoint.Y, origPoint.Z, rotated);166 var result = new PackingPosition(origPoint.AssignedBin, origPoint.X, origPoint.Y, origPoint.Z, rotated); 167 167 return result; 168 168 } … … 170 170 } 171 171 172 public override ThreeDimensionalPackingFindPositionBySliding(CuboidPackingItem measures, bool rotated) {172 public override PackingPosition FindPositionBySliding(CuboidPackingItem measures, bool rotated) { 173 173 //Starting-position at upper right corner (=left bottom point of item-rectangle is at position item.width,item.height) 174 ThreeDimensionalPacking currentPosition = new ThreeDimensionalPacking(0,174 PackingPosition currentPosition = new PackingPosition(0, 175 175 BinMeasures.Width - (rotated ? measures.Depth : measures.Width), 176 176 BinMeasures.Height - measures.Height, 177 177 BinMeasures.Depth - (rotated ? measures.Width : measures.Depth), rotated); 178 178 //Slide the item as far as possible to the bottom 179 while (IsPositionFeasible(measures, ThreeDimensionalPacking.MoveDown(currentPosition))180 || IsPositionFeasible(measures, ThreeDimensionalPacking.MoveLeft(currentPosition))181 || IsPositionFeasible(measures, ThreeDimensionalPacking.MoveBack(currentPosition))) {179 while (IsPositionFeasible(measures, PackingPosition.MoveDown(currentPosition)) 180 || IsPositionFeasible(measures, PackingPosition.MoveLeft(currentPosition)) 181 || IsPositionFeasible(measures, PackingPosition.MoveBack(currentPosition))) { 182 182 //Slide the item as far as possible to the left 183 while (IsPositionFeasible(measures, ThreeDimensionalPacking.MoveLeft(currentPosition))184 || IsPositionFeasible(measures, ThreeDimensionalPacking.MoveBack(currentPosition))) {183 while (IsPositionFeasible(measures, PackingPosition.MoveLeft(currentPosition)) 184 || IsPositionFeasible(measures, PackingPosition.MoveBack(currentPosition))) { 185 185 //Slide the item as far as possible to the back 186 while (IsPositionFeasible(measures, ThreeDimensionalPacking.MoveBack(currentPosition))) {187 currentPosition = ThreeDimensionalPacking.MoveBack(currentPosition);186 while (IsPositionFeasible(measures, PackingPosition.MoveBack(currentPosition))) { 187 currentPosition = PackingPosition.MoveBack(currentPosition); 188 188 } 189 if (IsPositionFeasible(measures, ThreeDimensionalPacking.MoveLeft(currentPosition)))190 currentPosition = ThreeDimensionalPacking.MoveLeft(currentPosition);191 } 192 if (IsPositionFeasible(measures, ThreeDimensionalPacking.MoveDown(currentPosition)))193 currentPosition = ThreeDimensionalPacking.MoveDown(currentPosition);189 if (IsPositionFeasible(measures, PackingPosition.MoveLeft(currentPosition))) 190 currentPosition = PackingPosition.MoveLeft(currentPosition); 191 } 192 if (IsPositionFeasible(measures, PackingPosition.MoveDown(currentPosition))) 193 currentPosition = PackingPosition.MoveDown(currentPosition); 194 194 } 195 195 … … 242 242 } 243 243 244 public override int ShortestPossibleSideFromPoint( ThreeDimensionalPackingposition) {244 public override int ShortestPossibleSideFromPoint(PackingPosition position) { 245 245 246 246 int shortestSide = int.MaxValue; … … 252 252 return shortestSide; 253 253 254 ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, position.X, position.Y, position.Z);255 while (current.X < width && IsPointOccupied(current)) { current = ThreeDimensionalPacking.MoveRight(current); }254 PackingPosition current = new PackingPosition(0, position.X, position.Y, position.Z); 255 while (current.X < width && IsPointOccupied(current)) { current = PackingPosition.MoveRight(current); } 256 256 if (current.X - position.X < shortestSide) 257 257 shortestSide = current.X - position.X; 258 258 259 259 260 current = new ThreeDimensionalPacking(0, position.X, position.Y, position.Z);261 while (current.Y < height && IsPointOccupied(current)) { current = ThreeDimensionalPacking.MoveUp(current); }260 current = new PackingPosition(0, position.X, position.Y, position.Z); 261 while (current.Y < height && IsPointOccupied(current)) { current = PackingPosition.MoveUp(current); } 262 262 if (current.Y - position.Y < shortestSide) 263 263 shortestSide = current.Y - position.Y; 264 264 265 265 266 current = new ThreeDimensionalPacking(0, position.X, position.Y, position.Z);267 while (current.Z < depth && IsPointOccupied(current)) { current = ThreeDimensionalPacking.MoveFront(current); }266 current = new PackingPosition(0, position.X, position.Y, position.Z); 267 while (current.Z < depth && IsPointOccupied(current)) { current = PackingPosition.MoveFront(current); } 268 268 if (current.Z - position.Z < shortestSide) 269 269 shortestSide = current.Z - position.Z; … … 271 271 return shortestSide; 272 272 } 273 public override bool IsStaticStable(CuboidPackingItem item, ThreeDimensionalPackingposition) {273 public override bool IsStaticStable(CuboidPackingItem item, PackingPosition position) { 274 274 //Static stability is given, if item is placed on the ground 275 275 if (position.Y == 0) 276 276 return true; 277 277 278 if (IsPointOccupied(new ThreeDimensionalPacking(0, position.X, position.Y - 1, position.Z))279 && IsPointOccupied(new ThreeDimensionalPacking(0, position.X + item.Width - 1, position.Y - 1, position.Z))280 && IsPointOccupied(new ThreeDimensionalPacking(0, position.X, position.Y - 1, position.Z + item.Depth - 1))281 && IsPointOccupied(new ThreeDimensionalPacking(0, position.X + item.Width - 1, position.Y - 1, position.Z + item.Depth - 1)))278 if (IsPointOccupied(new PackingPosition(0, position.X, position.Y - 1, position.Z)) 279 && IsPointOccupied(new PackingPosition(0, position.X + item.Width - 1, position.Y - 1, position.Z)) 280 && IsPointOccupied(new PackingPosition(0, position.X, position.Y - 1, position.Z + item.Depth - 1)) 281 && IsPointOccupied(new PackingPosition(0, position.X + item.Width - 1, position.Y - 1, position.Z + item.Depth - 1))) 282 282 return true; 283 283 … … 304 304 305 305 [Storable] 306 private bool depthWasDoubled = false; 306 private bool depthWasDoubled = false; // TODO ??? 307 307 public void DoubleDepth() { 308 308 if (!depthWasDoubled) { … … 314 314 } 315 315 316 public bool IsSupportedByAtLeastOnePoint(CuboidPackingItem item, ThreeDimensionalPackingposition) {316 public bool IsSupportedByAtLeastOnePoint(CuboidPackingItem item, PackingPosition position) { 317 317 if (position.Y == 0) 318 318 return true; … … 321 321 for (int x = position.X; x < position.X + item.Width; x++) 322 322 for (int z = position.Z; z < position.Z + item.Depth; z++) 323 if (IsPointOccupied(new ThreeDimensionalPacking(0, x, y, z)))323 if (IsPointOccupied(new PackingPosition(0, x, y, z))) 324 324 return true; 325 325 326 326 return false; 327 327 } 328 public bool IsWeightSupported(CuboidPackingItem item, ThreeDimensionalPackingep) {328 public bool IsWeightSupported(CuboidPackingItem item, PackingPosition ep) { 329 329 if (ep.Y == 0) 330 330 return true; 331 331 332 if (ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X, ep.Y - 1, ep.Z))].SupportsStacking(item)333 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width - 1, ep.Y - 1, ep.Z))].SupportsStacking(item)334 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X, ep.Y - 1, ep.Z + item.Depth - 1))].SupportsStacking(item)335 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width - 1, ep.Y - 1, ep.Z + item.Depth - 1))].SupportsStacking(item))332 if (ItemMeasures[PointOccupation(new PackingPosition(0, ep.X, ep.Y - 1, ep.Z))].SupportsStacking(item) 333 && ItemMeasures[PointOccupation(new PackingPosition(0, ep.X + item.Width - 1, ep.Y - 1, ep.Z))].SupportsStacking(item) 334 && ItemMeasures[PointOccupation(new PackingPosition(0, ep.X, ep.Y - 1, ep.Z + item.Depth - 1))].SupportsStacking(item) 335 && ItemMeasures[PointOccupation(new PackingPosition(0, ep.X + item.Width - 1, ep.Y - 1, ep.Z + item.Depth - 1))].SupportsStacking(item)) 336 336 return true; 337 337 … … 345 345 } 346 346 } 347 protected override void AddNewItemToOccupationLayers(int itemID, CuboidPackingItem measures, ThreeDimensionalPackingposition) {347 protected override void AddNewItemToOccupationLayers(int itemID, CuboidPackingItem measures, PackingPosition position) { 348 348 int z1 = position.Z / 10; 349 349 int z2 = (position.Z + (position.Rotated ? measures.Width : measures.Depth)) / 10; … … 352 352 OccupationLayers[i].Add(itemID); 353 353 } 354 protected override List<int> GetLayerItemIDs( ThreeDimensionalPackingposition) {354 protected override List<int> GetLayerItemIDs(PackingPosition position) { 355 355 return OccupationLayers[position.Z / 10]; 356 356 } 357 protected override List<int> GetLayerItemIDs(CuboidPackingItem measures, ThreeDimensionalPackingposition) {357 protected override List<int> GetLayerItemIDs(CuboidPackingItem measures, PackingPosition position) { 358 358 List<int> result = new List<int>(); 359 359 int z1 = position.Z / 10; … … 366 366 } 367 367 } 368 public class EPComparer3D : IComparer< ThreeDimensionalPacking> {369 public int Compare( ThreeDimensionalPacking a, ThreeDimensionalPackingb) {368 public class EPComparer3D : IComparer<PackingPosition> { 369 public int Compare(PackingPosition a, PackingPosition b) { 370 370 int result = a.Z.CompareTo(b.Z); 371 371 if (result == 0) -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/CuboidIdenticalBinPackingProblem.cs
r14046 r14048 38 38 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 310)] 39 39 // TODO don't support generic BPPData but only 3d BPPData 40 public class CuboidIdenticalBinPackingProblem : BinPackingProblem< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>, IProblemInstanceConsumer<BPPData>, IProblemInstanceExporter<BPPData> {40 public class CuboidIdenticalBinPackingProblem : BinPackingProblem<PackingPosition, CuboidPackingShape, CuboidPackingItem>, IProblemInstanceConsumer<BPPData>, IProblemInstanceExporter<BPPData> { 41 41 42 42 … … 102 102 } 103 103 public CuboidIdenticalBinPackingProblem() : base( 104 new PackingPlanEvaluationAlgorithm<Permutation, ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>()) {104 new PackingPlanEvaluationAlgorithm<Permutation, PackingPosition, CuboidPackingShape, CuboidPackingItem>()) { 105 105 } 106 106 … … 178 178 protected override void RemoveTooBigItems() { 179 179 PackingItemMeasures.RemoveAll(pi => 180 !PackingBinMeasures.Encloses(new ThreeDimensionalPacking(0, 0, 0, 0, false), pi) &&181 !PackingBinMeasures.Encloses(new ThreeDimensionalPacking(0, 0, 0, 0, true), pi));180 !PackingBinMeasures.Encloses(new PackingPosition(0, 0, 0, 0, false), pi) && 181 !PackingBinMeasures.Encloses(new PackingPosition(0, 0, 0, 0, true), pi)); 182 182 } 183 183 #endregion -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/CuboidPackingShape.cs
r14046 r14048 31 31 [Item("CuboidPackingShape", "Represents the cuboid measures (width, height, depth) of a three-dimensional cuboidic bin-packing object.")] 32 32 [StorableClass] 33 public class CuboidPackingShape : PackingShape< ThreeDimensionalPacking>, IComparable<CuboidPackingShape> {33 public class CuboidPackingShape : PackingShape<PackingPosition>, IComparable<CuboidPackingShape> { 34 34 public IFixedValueParameter<IntValue> HeightParameter { 35 35 get { return (IFixedValueParameter<IntValue>)Parameters["Height"]; } … … 128 128 public int y2; 129 129 public int z2; 130 public CuboidDiagonal(CuboidPackingShape myShape) : this(new ThreeDimensionalPacking(0, 0, 0, 0), myShape) { }131 public CuboidDiagonal( ThreeDimensionalPackingmyPosition, CuboidPackingShape myShape) {130 public CuboidDiagonal(CuboidPackingShape myShape) : this(new PackingPosition(0, 0, 0, 0), myShape) { } 131 public CuboidDiagonal(PackingPosition myPosition, CuboidPackingShape myShape) { 132 132 x1 = myPosition.X; 133 133 y1 = myPosition.Y; … … 141 141 142 142 #region Helpers 143 public override ThreeDimensionalPacking Origin { get { return new ThreeDimensionalPacking(0, 0, 0, 0); } }143 public override PackingPosition Origin { get { return new PackingPosition(0, 0, 0, 0); } } 144 144 public override int Volume { get { return Width * Height * Depth; } } 145 145 146 public override bool EnclosesPoint( ThreeDimensionalPacking myPosition, ThreeDimensionalPackingcheckedPoint) {146 public override bool EnclosesPoint(PackingPosition myPosition, PackingPosition checkedPoint) { 147 147 return (myPosition.X <= checkedPoint.X && 148 148 (myPosition.X + (myPosition.Rotated ? Depth : Width) - 1) >= checkedPoint.X && … … 152 152 (myPosition.Z + (myPosition.Rotated ? Width : Depth) - 1) >= checkedPoint.Z); 153 153 } 154 public override bool Encloses( ThreeDimensionalPacking checkedPosition, PackingShape<ThreeDimensionalPacking> checkedShape) {154 public override bool Encloses(PackingPosition checkedPosition, PackingShape<PackingPosition> checkedShape) { 155 155 return Encloses(checkedPosition, (CuboidPackingShape)checkedShape); 156 156 } 157 private bool Encloses( ThreeDimensionalPackingcheckedPosition, CuboidPackingShape checkedShape) {157 private bool Encloses(PackingPosition checkedPosition, CuboidPackingShape checkedShape) { 158 158 return Encloses(new CuboidDiagonal(this), new CuboidDiagonal(checkedPosition, checkedShape)); 159 159 } … … 167 167 } 168 168 169 public override bool Overlaps( ThreeDimensionalPacking myPosition, ThreeDimensionalPacking checkedPosition, PackingShape<ThreeDimensionalPacking> checkedShape) {169 public override bool Overlaps(PackingPosition myPosition, PackingPosition checkedPosition, PackingShape<PackingPosition> checkedShape) { 170 170 return Overlaps(myPosition, checkedPosition, (CuboidPackingShape)checkedShape); 171 171 } 172 private bool Overlaps( ThreeDimensionalPacking myPosition, ThreeDimensionalPackingcheckedPosition, CuboidPackingShape checkedShape) {172 private bool Overlaps(PackingPosition myPosition, PackingPosition checkedPosition, CuboidPackingShape checkedShape) { 173 173 return Overlaps(new CuboidDiagonal(myPosition, this), new CuboidDiagonal(checkedPosition, checkedShape)); 174 174 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Decoders/DBL/DeepestBottomLeftGroupingVectorDecoder.cs
r14047 r14048 31 31 [Item("Identical bin, three dimensional, GroupingVector-decoder", "<Description missing...>")] 32 32 [StorableClass] 33 public class DeepestBottomLeftGroupingVectorDecoder : PackingSolutionDecoder< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>, I3DGVDecoder {33 public class DeepestBottomLeftGroupingVectorDecoder : PackingSolutionDecoder<PackingPosition, CuboidPackingShape, CuboidPackingItem>, I3DGVDecoder { 34 34 public DeepestBottomLeftGroupingVectorDecoder() : base() {} 35 35 [StorableConstructor] … … 42 42 } 43 43 44 public override PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) {44 public override PackingPlan<PackingPosition, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 45 45 var solution = encodedSolution as GroupingVectorEncoding; 46 46 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Decoders/DBL/DeepestBottomLeftMultiComponentVectorDecoder.cs
r14047 r14048 31 31 [Item("Identical bin, three dimensional, MultiComponentVector-decoder", "<Description missing...>")] 32 32 [StorableClass] 33 public class DeepestBottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>, I3DMCVDecoder {33 public class DeepestBottomLeftMultiComponentVectorDecoder : PackingSolutionDecoder<PackingPosition, CuboidPackingShape, CuboidPackingItem>, I3DMCVDecoder { 34 34 public DeepestBottomLeftMultiComponentVectorDecoder() : base() { } 35 35 [StorableConstructor] … … 42 42 } 43 43 44 public override PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) {44 public override PackingPlan<PackingPosition, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 45 45 var solution = encodedSolution as MultiComponentVectorEncoding; 46 46 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponent Vector"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Decoders/DBL/DeepestBottomLeftPackingSequenceDecoder.cs
r14047 r14048 31 31 [Item("Identical bin, three dimensional, PackingSequence-decoder", "<Description missing...>")] 32 32 [StorableClass] 33 public class DeepestBottomLeftPackingSequenceDecoder : PackingSolutionDecoder< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>, I3DPSDecoder {33 public class DeepestBottomLeftPackingSequenceDecoder : PackingSolutionDecoder<PackingPosition, CuboidPackingShape, CuboidPackingItem>, I3DPSDecoder { 34 34 public DeepestBottomLeftPackingSequenceDecoder(): base() {} 35 35 [StorableConstructor] … … 42 42 } 43 43 44 public override PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) {44 public override PackingPlan<PackingPosition, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 45 45 var solution = encodedSolution as PackingSequenceEncoding; 46 46 if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Decoders/EP/ExtremePointGroupingVectorDecoder3D.cs
r14047 r14048 31 31 [Item("Identical bin, three dimensional, extreme points based decoder for the GroupingVector encoding.", "<Description missing...>")] 32 32 [StorableClass] 33 public class ExtremePointGroupingVectorDecoder3D : PackingSolutionDecoder< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>, I3DGVDecoder {33 public class ExtremePointGroupingVectorDecoder3D : PackingSolutionDecoder<PackingPosition, CuboidPackingShape, CuboidPackingItem>, I3DGVDecoder { 34 34 public ExtremePointGroupingVectorDecoder3D() : base() { } 35 35 [StorableConstructor] … … 42 42 } 43 43 44 public static PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> Decode(GroupingVectorEncoding solution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures, bool stackingConstraints) {44 public static PackingPlan<PackingPosition, CuboidPackingShape, CuboidPackingItem> Decode(GroupingVectorEncoding solution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures, bool stackingConstraints) { 45 45 Solution result = new Solution(binMeasures, true, stackingConstraints); 46 46 result.Pack(solution, itemMeasures); … … 48 48 } 49 49 50 public override PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) {50 public override PackingPlan<PackingPosition, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 51 51 var solution = encodedSolution as GroupingVectorEncoding; 52 52 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Decoders/EP/ExtremePointMultiComponentVectorDecoder3D.cs
r14047 r14048 31 31 [Item("Identical bin, three dimensional, extreme points based decoder for the MultiComponentVector encoding.", "<Description missing...>")] 32 32 [StorableClass] 33 public class ExtremePointMultiComponentVectorDecoder3D : PackingSolutionDecoder< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>, I3DMCVDecoder {33 public class ExtremePointMultiComponentVectorDecoder3D : PackingSolutionDecoder<PackingPosition, CuboidPackingShape, CuboidPackingItem>, I3DMCVDecoder { 34 34 public ExtremePointMultiComponentVectorDecoder3D () : base() { } 35 35 [StorableConstructor] … … 42 42 } 43 43 44 public static PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures, bool stackingConstraints) {44 public static PackingPlan<PackingPosition, CuboidPackingShape, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures, bool stackingConstraints) { 45 45 Solution result = new Solution(binMeasures, true, stackingConstraints); 46 46 result.Pack(solution, itemMeasures); … … 48 48 } 49 49 50 public override PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) {50 public override PackingPlan<PackingPosition, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 51 51 var solution = encodedSolution as MultiComponentVectorEncoding; 52 52 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Decoders/EP/ExtremePointPackingSequenceDecoder3D.cs
r14047 r14048 32 32 [Item("Identical bin, three dimensional, extreme points based decoder for the PackingSequence encoding.", "<Description missing...>")] 33 33 [StorableClass] 34 public class ExtremePointPackingSequenceDecoder3D : PackingSolutionDecoder< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>, I3DPSDecoder {34 public class ExtremePointPackingSequenceDecoder3D : PackingSolutionDecoder<PackingPosition, CuboidPackingShape, CuboidPackingItem>, I3DPSDecoder { 35 35 public ExtremePointPackingSequenceDecoder3D () : base() {} 36 36 [StorableConstructor] … … 44 44 45 45 46 public override PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) {46 public override PackingPlan<PackingPosition, CuboidPackingShape, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingShape binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 47 47 var solution = encodedSolution as PackingSequenceEncoding; 48 48 if (solution == null) throw new InvalidOperationException("Encoding is not of type PackingSequence"); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/HeuristicLab.Problems.BinPacking3D-3.3.csproj
r14047 r14048 175 175 <Compile Include="MoveEvaluators\PackingMoveEvaluator3DMCV.cs" /> 176 176 <Compile Include="MoveEvaluators\PackingMoveEvaluator3DPS.cs" /> 177 <Compile Include="PackingPosition.cs" /> 177 178 <Compile Include="PackingRatioCuboidIdenticalBinEvaluator.cs" /> 178 179 <Compile Include="Plugin.cs" /> 179 180 <Compile Include="Properties\AssemblyInfo.cs" /> 180 181 <Compile Include="Solution.cs" /> 181 <Compile Include="ThreeDimensionalPacking.cs" />182 182 </ItemGroup> 183 183 <ItemGroup> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/MoveEvaluators/PackingMoveEvaluator3DGV.cs
r14046 r14048 30 30 [Item("GroupingVectorMoveEvaluator3D", "Class for evaluating packing moves for 3dimensional problems.")] 31 31 [StorableClass] 32 public class PackingMoveEvaluator3DGV : PackingMoveEvaluator< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>, ISingleObjectiveMoveEvaluator, IGroupingVectorMoveOperator, I3DOperator {32 public class PackingMoveEvaluator3DGV : PackingMoveEvaluator<PackingPosition, CuboidPackingShape, CuboidPackingItem>, ISingleObjectiveMoveEvaluator, IGroupingVectorMoveOperator, I3DOperator { 33 33 [StorableConstructor] 34 34 protected PackingMoveEvaluator3DGV(bool deserializing) : base(deserializing) { } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/MoveEvaluators/PackingMoveEvaluator3DMCV.cs
r14046 r14048 30 30 [Item("MultiComponentVectorMoveEvaluator3D", "Class for evaluating packing moves for 3dimensional problems.")] 31 31 [StorableClass] 32 public class PackingMoveEvaluator3DMCV : PackingMoveEvaluator< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>, ISingleObjectiveMoveEvaluator, IMultiComponentVectorMoveOperator, I3DOperator {32 public class PackingMoveEvaluator3DMCV : PackingMoveEvaluator<PackingPosition, CuboidPackingShape, CuboidPackingItem>, ISingleObjectiveMoveEvaluator, IMultiComponentVectorMoveOperator, I3DOperator { 33 33 [StorableConstructor] 34 34 protected PackingMoveEvaluator3DMCV(bool deserializing) : base(deserializing) { } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/MoveEvaluators/PackingMoveEvaluator3DPS.cs
r14046 r14048 30 30 [Item("PackingSequenceMoveEvaluator3D", "Class for evaluating packing moves for 3dimensional problems.")] 31 31 [StorableClass] 32 public class PackingMoveEvaluator3DPS : PackingMoveEvaluator< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>, ISingleObjectiveMoveEvaluator, IPackingSequenceMoveOperator, I3DOperator {32 public class PackingMoveEvaluator3DPS : PackingMoveEvaluator<PackingPosition, CuboidPackingShape, CuboidPackingItem>, ISingleObjectiveMoveEvaluator, IPackingSequenceMoveOperator, I3DOperator { 33 33 [StorableConstructor] 34 34 protected PackingMoveEvaluator3DPS(bool deserializing) : base(deserializing) { } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/PackingPosition.cs
r14047 r14048 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Common; 26 using HeuristicLab.Problems.BinPacking;27 26 28 27 namespace HeuristicLab.Problems.BinPacking3D { 29 [Item(" Three Dimensional Packing", "Represents a packing-position associated with a three dimensional packing-problem.")]28 [Item("Packing Position (3d)", "Represents a packing-position associated with a three dimensional packing-problem.")] 30 29 [StorableClass] 31 // ThreeDimensionalPackingis immutable (and handled as value type concerning Equals and GetHashCode)32 public class ThreeDimensionalPacking : PackingDimensions{30 // PackingPosition is immutable (and handled as value type concerning Equals and GetHashCode) 31 public class PackingPosition : BinPacking.PackingPosition { 33 32 [Storable] 34 33 private readonly int x; … … 43 42 44 43 [StorableConstructor] 45 protected ThreeDimensionalPacking(bool deserializing) : base(deserializing) { }46 protected ThreeDimensionalPacking(ThreeDimensionalPackingoriginal, Cloner cloner)44 protected PackingPosition(bool deserializing) : base(deserializing) { } 45 protected PackingPosition(PackingPosition original, Cloner cloner) 47 46 : base(original, cloner) { 48 47 x = original.X; … … 51 50 } 52 51 public override IDeepCloneable Clone(Cloner cloner) { 53 return new ThreeDimensionalPacking(this, cloner);52 return new PackingPosition(this, cloner); 54 53 } 55 54 56 public ThreeDimensionalPacking(int assignedBin, int x, int y, int z, bool rotated = false)55 public PackingPosition(int assignedBin, int x, int y, int z, bool rotated = false) 57 56 : base(assignedBin, rotated) { 58 57 this.x = x; … … 67 66 68 67 public override bool Equals(object obj) { 69 var tdp = obj as ThreeDimensionalPacking;68 var tdp = obj as PackingPosition; 70 69 if (tdp != null) 71 70 return (tdp.X == this.X && tdp.Y == this.Y && tdp.Z == this.Z); … … 77 76 } 78 77 79 public static ThreeDimensionalPacking MoveLeft(ThreeDimensionalPackingoriginal) {80 return new ThreeDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Z, original.Rotated);78 public static PackingPosition MoveLeft(PackingPosition original) { 79 return new PackingPosition(original.AssignedBin, original.X - 1, original.Y, original.Z, original.Rotated); 81 80 } 82 public static ThreeDimensionalPacking MoveDown(ThreeDimensionalPackingoriginal) {83 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Z, original.Rotated);81 public static PackingPosition MoveDown(PackingPosition original) { 82 return new PackingPosition(original.AssignedBin, original.X, original.Y - 1, original.Z, original.Rotated); 84 83 } 85 public static ThreeDimensionalPacking MoveBack(ThreeDimensionalPackingoriginal) {86 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y, original.Z - 1, original.Rotated);84 public static PackingPosition MoveBack(PackingPosition original) { 85 return new PackingPosition(original.AssignedBin, original.X, original.Y, original.Z - 1, original.Rotated); 87 86 } 88 87 89 public static ThreeDimensionalPacking MoveRight(ThreeDimensionalPackingoriginal) {90 return new ThreeDimensionalPacking(original.AssignedBin, original.X + 1, original.Y, original.Z, original.Rotated);88 public static PackingPosition MoveRight(PackingPosition original) { 89 return new PackingPosition(original.AssignedBin, original.X + 1, original.Y, original.Z, original.Rotated); 91 90 } 92 public static ThreeDimensionalPacking MoveUp(ThreeDimensionalPackingoriginal) {93 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y + 1, original.Z, original.Rotated);91 public static PackingPosition MoveUp(PackingPosition original) { 92 return new PackingPosition(original.AssignedBin, original.X, original.Y + 1, original.Z, original.Rotated); 94 93 } 95 public static ThreeDimensionalPacking MoveFront(ThreeDimensionalPackingoriginal) {96 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y, original.Z + 1, original.Rotated);94 public static PackingPosition MoveFront(PackingPosition original) { 95 return new PackingPosition(original.AssignedBin, original.X, original.Y, original.Z + 1, original.Rotated); 97 96 } 98 97 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/PackingRatioCuboidIdenticalBinEvaluator.cs
r14046 r14048 28 28 [Item("Packing-Ratio Cuboid Identical-Bin Evaluator", "Represents an evaluation-algorithm for cuboid-shaped bin-packing problems with identical bins which calculates the ratio between packed and unpacked space. Found in Falkenauer:1996")] 29 29 [StorableClass] 30 public class PackingRatioCuboidIdenticalBinEvaluator : PackingRatioRegularIdenticalBinEvaluator< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> {30 public class PackingRatioCuboidIdenticalBinEvaluator : PackingRatioRegularIdenticalBinEvaluator<PackingPosition, CuboidPackingShape, CuboidPackingItem> { 31 31 32 32 [StorableConstructor] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/Solution.cs
r14047 r14048 7 7 [Item("Bin Packing Solution (3d)", "Represents a solution for a 3D bin packing problem.")] 8 8 [StorableClass] 9 public class Solution : PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> {9 public class Solution : PackingPlan<PackingPosition, CuboidPackingShape, CuboidPackingItem> { 10 10 public Solution(CuboidPackingShape binMeasures) : this(binMeasures, false, false) { } 11 11 public Solution(CuboidPackingShape binMeasures, bool useExtremePoints, bool stackingConstraints) : base(binMeasures, useExtremePoints, stackingConstraints) { } … … 18 18 return new Solution(this, cloner); 19 19 } 20 public override BinPacking< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> NewBinPacking() {20 public override BinPacking<PackingPosition, CuboidPackingShape, CuboidPackingItem> NewBinPacking() { 21 21 return new BinPacking3D(BinMeasures); 22 22 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Container2DView.xaml.cs
r14046 r14048 33 33 private int selectedItemKey; 34 34 private Size renderSize; 35 private BinPacking< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> packing;36 public BinPacking< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> Packing {35 private BinPacking<BinPacking2D.PackingPosition, RectangularPackingShape, RectangularPackingItem> packing; 36 public BinPacking<BinPacking2D.PackingPosition, RectangularPackingShape, RectangularPackingItem> Packing { 37 37 get { return packing; } 38 38 set { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Container3DView.xaml.cs
r14046 r14048 35 35 private int selectedItemKey; 36 36 37 private BinPacking< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> packing;38 public BinPacking< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> Packing {37 private BinPacking<BinPacking3D.PackingPosition, CuboidPackingShape, CuboidPackingItem> packing; 38 public BinPacking<BinPacking3D.PackingPosition, CuboidPackingShape, CuboidPackingItem> Packing { 39 39 get { return packing; } 40 40 set { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlan2DView.cs
r14046 r14048 28 28 namespace HeuristicLab.Problems.BinPacking.Views { 29 29 [View("2-dimensional packing plan view")] 30 [Content(typeof(PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>), true)]30 [Content(typeof(PackingPlan<BinPacking2D.PackingPosition, RectangularPackingShape, RectangularPackingItem>), true)] 31 31 public partial class PackingPlan2DView : ItemView { 32 32 … … 35 35 } 36 36 37 public new PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> Content {38 get { return (PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem>)base.Content; }37 public new PackingPlan<BinPacking2D.PackingPosition, RectangularPackingShape, RectangularPackingItem> Content { 38 get { return (PackingPlan<BinPacking2D.PackingPosition, RectangularPackingShape, RectangularPackingItem>)base.Content; } 39 39 set { base.Content = value; } 40 40 } … … 56 56 } 57 57 58 private void UpdateState(PackingPlan< TwoDimensionalPacking, RectangularPackingShape, RectangularPackingItem> plan) {58 private void UpdateState(PackingPlan<BinPacking2D.PackingPosition, RectangularPackingShape, RectangularPackingItem> plan) { 59 59 int currentBin = (binSelection != null && binSelection.SelectedItem != null) ? (int)(binSelection.SelectedItem) : 0; 60 60 container2DView.Packing = plan.BinPackings[currentBin]; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlan3DView.cs
r14046 r14048 28 28 namespace HeuristicLab.Problems.BinPacking.Views { 29 29 [View("3-dimensional packing plan View")] 30 [Content(typeof(PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>), true)]30 [Content(typeof(PackingPlan<BinPacking3D.PackingPosition, CuboidPackingShape, CuboidPackingItem>), true)] 31 31 public partial class PackingPlan3DView : ItemView { 32 32 … … 35 35 } 36 36 37 public new PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem> Content {38 get { return (PackingPlan< ThreeDimensionalPacking, CuboidPackingShape, CuboidPackingItem>)base.Content; }37 public new PackingPlan<BinPacking3D.PackingPosition, CuboidPackingShape, CuboidPackingItem> Content { 38 get { return (PackingPlan<BinPacking3D.PackingPosition, CuboidPackingShape, CuboidPackingItem>)base.Content; } 39 39 set { base.Content = value; } 40 40 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Analyzers/BestBinPackingSolutionAnalyzer.cs
r14046 r14048 34 34 [StorableClass] 35 35 public class BestBinPackingSolutionAnalyzer<D, B, I> : BinPackingAnalyzer<D, B, I>, IStochasticOperator 36 where D : class, IPacking Dimensions36 where D : class, IPackingPosition 37 37 where B : PackingShape<D> 38 38 where I : PackingShape<D>, IPackingItem { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Analyzers/BinPackingAnalyzer.cs
r14046 r14048 33 33 [StorableClass] 34 34 public abstract class BinPackingAnalyzer<D, B, I> : SingleSuccessorOperator, IAnalyzer 35 where D : class, IPacking Dimensions35 where D : class, IPackingPosition 36 36 where B : PackingShape<D> 37 37 where I : PackingShape<D>, IPackingItem { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/BinPackingProblem.cs
r14046 r14048 38 38 [StorableClass] 39 39 public abstract class BinPackingProblem<D, B, I> : SingleObjectiveHeuristicOptimizationProblem<IPackingPlanEvaluationAlgorithm, IPackingSolutionCreator> 40 where D : class, IPacking Dimensions40 where D : class, IPackingPosition 41 41 where B : PackingShape<D>, new() 42 42 where I : PackingShape<D>, IPackingItem, new () { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs
r14046 r14048 32 32 [StorableClass] 33 33 public abstract class BinPacking<D,B,I> : Item 34 where D : class, IPacking Dimensions34 where D : class, IPackingPosition 35 35 where B : PackingShape<D> 36 36 where I : PackingShape<D>, IPackingItem { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs
r14046 r14048 38 38 [StorableClass] 39 39 public abstract class PackingPlan<D, B, I> :Item, IPackingPlan 40 where D : class, IPacking Dimensions40 where D : class, IPackingPosition 41 41 where B : PackingShape<D> 42 42 where I : PackingShape<D>, IPackingItem { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/BinUtilizationRegularIdenticalBinEvaluator.cs
r14046 r14048 31 31 [StorableClass] 32 32 public abstract class BinUtilizationRegularIdenticalBinEvaluator<D, B, I> : RegularSimpleRotationIdenticalBinPackingPlanEvaluator<D, B, I> 33 where D : class, IPacking Dimensions33 where D : class, IPackingPosition 34 34 where B : PackingShape<D> 35 35 where I : PackingShape<D>, IPackingItem { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/PackingPlanEvaluationAlgorithm.cs
r14046 r14048 34 34 public class PackingPlanEvaluationAlgorithm<E, D, B, I> : SingleSuccessorOperator, IPackingPlanEvaluationAlgorithm 35 35 where E : Item //E defines the used Encoding 36 where D : class, IPacking Dimensions36 where D : class, IPackingPosition 37 37 where B : PackingShape<D> 38 38 where I : PackingShape<D>, IPackingItem { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/PackingPlanEvaluator.cs
r14046 r14048 33 33 [StorableClass] 34 34 public abstract class PackingPlanEvaluator<D,B,I> : SingleSuccessorOperator, IPackingPlanEvaluator 35 where D : class, IPacking Dimensions35 where D : class, IPackingPosition 36 36 where B : PackingShape<D> 37 37 where I : PackingShape<D>, IPackingItem { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/PackingRatioRegularIdenticalBinEvaluator.cs
r14046 r14048 31 31 [StorableClass] 32 32 public abstract class PackingRatioRegularIdenticalBinEvaluator<D, B, I> : RegularSimpleRotationIdenticalBinPackingPlanEvaluator<D, B, I> 33 where D : class, IPacking Dimensions33 where D : class, IPackingPosition 34 34 where B : PackingShape<D> 35 35 where I : PackingShape<D>, IPackingItem { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/RegularSimpleRotationIdenticalBinPackingPlanEvaluator.cs
r14046 r14048 30 30 [StorableClass] 31 31 public abstract class RegularSimpleRotationIdenticalBinPackingPlanEvaluator<D, B, I> : PackingPlanEvaluator<D, B, I> 32 where D : class, IPacking Dimensions32 where D : class, IPackingPosition 33 33 where B : PackingShape<D> 34 34 where I : PackingShape<D>, IPackingItem { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj
r14045 r14048 262 262 <Compile Include="Instances\BPPORLIBDataDescriptor.cs" /> 263 263 <Compile Include="Instances\RealBPPData.cs" /> 264 <Compile Include="Interfaces\IPackingPosition.cs" /> 264 265 <Compile Include="Interfaces\IPackingSequenceMoveOperator.cs" /> 265 266 <Compile Include="Interfaces\IPackingMove.cs" /> … … 279 280 <Compile Include="Interfaces\IPackingPlanEvaluator.cs" /> 280 281 <Compile Include="Interfaces\IPackingShape.cs" /> 281 <Compile Include="Interfaces\IPackingDimensions.cs" />282 282 <Compile Include="PackingDimensions.cs" /> 283 283 <Compile Include="PackingMoveEvaluator.cs" /> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingPosition.cs
r14047 r14048 23 23 24 24 namespace HeuristicLab.Problems.BinPacking { 25 // TODO: this interface should contain positions26 public interface IPacking Dimensions: IItem {25 26 public interface IPackingPosition : IItem { 27 27 int AssignedBin { get; } 28 28 bool Rotated { get; } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingDimensions.cs
r14046 r14048 29 29 [StorableClass] 30 30 // PackingDimensions is immutable (and handled as value types concerning Equals and GetHashCode) 31 public abstract class Packing Dimensions : Item, IPackingDimensions{31 public abstract class PackingPosition : Item, IPackingPosition { 32 32 /// <summary> 33 33 /// The number of the bin to which the current item is assigned is stored in this variable. Counting starts at 0 !!! … … 49 49 50 50 [StorableConstructor] 51 protected Packing Dimensions(bool deserializing) : base(deserializing) { }52 protected Packing Dimensions(PackingDimensionsoriginal, Cloner cloner)51 protected PackingPosition(bool deserializing) : base(deserializing) { } 52 protected PackingPosition(PackingPosition original, Cloner cloner) 53 53 : base(original, cloner) { 54 54 assignedBin = original.AssignedBin; … … 56 56 } 57 57 58 protected Packing Dimensions(int assignedBin, bool rotated) {58 protected PackingPosition(int assignedBin, bool rotated) { 59 59 this.assignedBin = assignedBin; 60 60 this.rotated = rotated; … … 66 66 67 67 public override bool Equals(object obj) { 68 var other = obj as Packing Dimensions;68 var other = obj as PackingPosition; 69 69 if (other != null) 70 70 return (other.AssignedBin == this.AssignedBin && other.Rotated == this.Rotated); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingMoveEvaluator.cs
r14046 r14048 33 33 [StorableClass] 34 34 public abstract class PackingMoveEvaluator<D, B, I> : SingleSuccessorOperator, IPackingMoveEvaluator, IMoveOperator 35 where D : class, IPacking Dimensions35 where D : class, IPackingPosition 36 36 where B : PackingShape<D> 37 37 where I : PackingShape<D>, IPackingItem { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingShape.cs
r14046 r14048 32 32 [StorableClass] 33 33 public abstract class PackingShape<T> : Item, IPackingShape, IParameterizedItem 34 where T : class, IPacking Dimensions{34 where T : class, IPackingPosition { 35 35 public static Type PositionType { 36 36 get { return typeof(T); } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingSolutionDecoder.cs
r14046 r14048 34 34 [StorableClass] 35 35 public abstract class PackingSolutionDecoder<D, B, I> : SingleSuccessorOperator, IPackingSolutionDecoder 36 where D : class, IPacking Dimensions36 where D : class, IPackingPosition 37 37 where B : PackingShape<D> 38 38 where I : PackingShape<D>, IPackingItem {
Note: See TracChangeset
for help on using the changeset viewer.