Changeset 15230 for trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D
- Timestamp:
- 07/13/17 15:25:11 (7 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.BinPacking
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.BinPacking
-
Property
svn:mergeinfo
set to
/branches/BinPackingExtension/HeuristicLab.Problems.BinPacking merged eligible
-
Property
svn:mergeinfo
set to
-
trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/BinPacking2D.cs
r14916 r15230 88 88 }; 89 89 90 int epIndex = 0; 91 while (epIndex < ExtremePoints.Count && (!IsPositionFeasible(rotatedItem, ExtremePoints.ElementAt(epIndex)))) { epIndex++; } 92 93 if (epIndex < ExtremePoints.Count) { 94 var currentPoint = ExtremePoints.ElementAt(epIndex); 95 96 var result = new PackingPosition(currentPoint.AssignedBin, currentPoint.X, currentPoint.Y, rotated); 90 var ep = ExtremePoints.Where(x => IsPositionFeasible(rotatedItem, x, stackingConstraints)).FirstOrDefault(); 91 if (ep != null) { 92 var result = new PackingPosition(ep.AssignedBin, ep.X, ep.Y, rotated); 97 93 return result; 98 94 } 99 95 return null; 100 96 } 101 public override PackingPosition FindPositionBySliding(PackingItem item, bool rotated ) {97 public override PackingPosition FindPositionBySliding(PackingItem item, bool rotated, bool stackingConstraints) { 102 98 PackingPosition currentPosition = new PackingPosition(0, 103 99 BinShape.Width - (rotated ? item.Height : item.Width), 104 100 BinShape.Height - (rotated ? item.Width : item.Height), rotated); 105 101 //Slide the item as far as possible to the left 106 while (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition) )107 || IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition) )) {102 while (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition), stackingConstraints) 103 || IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition), stackingConstraints)) { 108 104 //Slide the item as far as possible to the bottom 109 while (IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition) )) {105 while (IsPositionFeasible(item, PackingPosition.MoveDown(currentPosition), stackingConstraints)) { 110 106 currentPosition = PackingPosition.MoveDown(currentPosition); 111 107 } 112 if (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition) ))108 if (IsPositionFeasible(item, PackingPosition.MoveLeft(currentPosition), stackingConstraints)) 113 109 currentPosition = PackingPosition.MoveLeft(currentPosition); 114 110 } 115 111 116 return IsPositionFeasible(item, currentPosition ) ? currentPosition : null;117 } 118 119 public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items ) {112 return IsPositionFeasible(item, currentPosition, stackingConstraints) ? currentPosition : null; 113 } 114 115 public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items, bool stackingConstraints) { 120 116 var temp = new List<int>(sequence); 121 117 for (int i = 0; i < temp.Count; i++) { 122 118 var item = items[temp[i]]; 123 var position = FindPositionBySliding(item, false );119 var position = FindPositionBySliding(item, false, stackingConstraints); 124 120 if (position != null) { 125 121 PackItem(temp[i], item, position); … … 128 124 } 129 125 } 130 public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items, Dictionary<int, bool> rotationArray ) {126 public override void SlidingBasedPacking(ref IList<int> sequence, IList<PackingItem> items, Dictionary<int, bool> rotationArray, bool stackingConstraints) { 131 127 var temp = new List<int>(sequence); 132 128 for (int i = 0; i < temp.Count; i++) { 133 129 var item = items[temp[i]]; 134 var position = FindPositionBySliding(item, rotationArray[temp[i]] );130 var position = FindPositionBySliding(item, rotationArray[temp[i]], stackingConstraints); 135 131 if (position != null) { 136 132 PackItem(temp[i], item, position); … … 150 146 } 151 147 } 148 152 149 public override void ExtremePointBasedPacking(ref IList<int> sequence, IList<PackingItem> items, bool stackingConstraints, Dictionary<int, bool> rotationArray) { 153 150 var temp = new List<int>(sequence); … … 186 183 throw new NotSupportedException(); 187 184 } 188 189 185 protected override void InitializeOccupationLayers() { 190 186 for (int i = 0; i * 10 <= BinShape.Width; i += 1) { -
trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/IntegerVectorEncoding/BottomLeftIntegerVectorDecoder.cs
r14167 r15230 47 47 48 48 protected override PackingPosition FindPositionForItem(BinPacking2D bp, PackingItem item) { 49 return bp.FindPositionBySliding(item, rotated: false );49 return bp.FindPositionBySliding(item, rotated: false, stackingConstraints: false); 50 50 } 51 51 … … 54 54 ref IList<int> remainingIDs, IList<PackingItem> items) { 55 55 var bp = new BinPacking2D(partialSolution.BinShape); 56 bp.SlidingBasedPacking(ref remainingIDs, items );56 bp.SlidingBasedPacking(ref remainingIDs, items, stackingConstraints: false); 57 57 return bp; 58 58 } -
trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/PermutationEncoding/BottomLeftPermutationDecoder.cs
r14167 r15230 46 46 while (remainingIDs.Count > 0) { 47 47 var bp = new BinPacking2D(binShape); 48 bp.SlidingBasedPacking(ref remainingIDs, items );48 bp.SlidingBasedPacking(ref remainingIDs, items, stackingConstraints: false); 49 49 result.Bins.Add(bp); 50 50 }
Note: See TracChangeset
for help on using the changeset viewer.