- Timestamp:
- 07/12/16 19:54:35 (8 years ago)
- Location:
- branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3
- Files:
-
- 15 edited
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.