Changeset 9598 for branches/HeuristicLab.BinPacking
- Timestamp:
- 06/07/13 15:35:12 (11 years ago)
- Location:
- branches/HeuristicLab.BinPacking
- Files:
-
- 3 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/PackingPlans/PackingPlan3DView.cs
r9593 r9598 44 44 } else { 45 45 Content.Name = "Packing Plan"; 46 for (int i = 0; i < Content.NrOfBins; i++) 47 binSelection.Items.Add(i); 46 int i = 0; 47 foreach (var bp in Content.BinPackings) 48 binSelection.Items.Add(i++ + " (" + Math.Round(bp.PackingDensity * 100, 2) + "%)"); 49 48 50 binSelection.SelectedIndex = 0; 49 51 UpdateModel(); … … 53 55 54 56 private void UpdateModel() { 55 int currentBin = (binSelection != null && binSelection.SelectedItem != null) ? (int)(binSelection.SelectedItem) : 0;57 int currentBin = (binSelection != null) ? (int)(binSelection.SelectedIndex) : 0; 56 58 var bin = Content.BinPackings[currentBin].BinMeasures; 57 59 packingPlan3D.InitializeContainer(bin.Width, bin.Height, bin.Depth); … … 71 73 itemSelection.SelectedIndex = -1; 72 74 itemSelection.Items.Clear(); 73 int currentBin = (binSelection != null && binSelection.SelectedItem != null) ? (int)(binSelection.SelectedItem) : 0;75 int currentBin = (binSelection != null) ? (int)(binSelection.SelectedIndex) : 0; 74 76 //for (int i = 0; i < Content.PackingItemPositions.Count; i++) { 75 77 // if (Content.PackingItemPositions[i].AssignedBin == currentBin) … … 106 108 } else { 107 109 Content.Name = "Packing Plan"; 108 for (int i = 0; i < Content.NrOfBins; i++) 109 binSelection.Items.Add(i); 110 int i = 0; 111 foreach (var bp in Content.BinPackings) 112 binSelection.Items.Add(i++ + " (" + Math.Round(bp.PackingDensity * 100, 2) + "%)"); 110 113 binSelection.SelectedIndex = 0; 111 114 UpdateModel(); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Plugin.cs
r9596 r9598 26 26 /// Plugin class for HeuristicLab.Problems.BinPacking.Views plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Problems.BinPacking.Views", "3.3.7.959 3")]28 [Plugin("HeuristicLab.Problems.BinPacking.Views", "3.3.7.9596")] 29 29 [PluginFile("HeuristicLab.Problems.BinPacking.Views-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Common", "3.3")] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Properties/AssemblyInfo.cs
r9596 r9598 54 54 // by using the '*' as shown below: 55 55 [assembly: AssemblyVersion("3.3.0.0")] 56 [assembly: AssemblyFileVersion("3.3.7.959 3")]56 [assembly: AssemblyFileVersion("3.3.7.9596")] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ISOContainerMultiComponentVectorDecoder3D.cs
r9596 r9598 112 112 } 113 113 114 115 114 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 116 115 var solution = encodedSolution as MultiComponentVectorEncoding; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/PackingSolutionDecoder.cs
r9596 r9598 70 70 Parameters.Add(new LookupParameter<ItemList<I>>("PackingItemMeasures", "Packing-item data taken from the bin-packing problem-instance.")); 71 71 Parameters.Add(new LookupParameter<B>("PackingBinMeasures", "Packing-bin data taken from the bin-packing problem-instance.")); 72 Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not." ));72 Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not.", new BoolValue(true))); 73 73 } 74 74 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs
r9596 r9598 105 105 } 106 106 107 108 public int PointOccupation(D position) { 109 foreach (var ipEntry in ItemPositions) { 110 if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position)) 111 return ipEntry.Key; 112 } 113 return -1; 114 } 107 115 public bool IsPointOccupied(D position) { 108 116 foreach (var ipEntry in ItemPositions) { … … 110 118 return true; 111 119 } 112 113 120 return false; 114 121 } 115 122 public bool IsPositionFeasible(I currentItem, D position) { 116 //In this case feasability is defined as following: 1. the item fits into the bin-borders; 2. the item does not collide with another already packed item123 //In this case feasability is defined as following: 1. the item fits into the bin-borders; 2. the point is supported by something; 3. the item does not collide with another already packed item 117 124 if (!BinMeasures.Encloses(position, currentItem)) 118 125 return false; … … 127 134 public abstract int ShortestPossibleSideFromPoint (D position); 128 135 public abstract bool IsStaticStable (I item, D position); 129 130 //public bool IsPositionFeasible1(I currentItem, D position) {131 // if (!BinMeasures.Encloses(position, currentItem))132 // return false;133 134 // return OccupiedPoints.IsPositionFeasible (currentItem, position);135 //}136 136 } 137 137 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking2D.cs
r9596 r9598 62 62 if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height) { 63 63 //Traversing down the y-axis 64 while (sourcePointX.Y > 0 && !IsPointOccupied(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y - 1))) {64 while (sourcePointX.Y > 0 && (-1).Equals(IsPointOccupied(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y - 1)))) { 65 65 sourcePointX.Y--; 66 66 } … … 75 75 if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height) { 76 76 //Traversing down the x-axis 77 while (sourcePointY.X > 0 && !IsPointOccupied(new TwoDimensionalPacking (0,sourcePointY.X - 1, sourcePointY.Y))) {77 while (sourcePointY.X > 0 && (-1).Equals(IsPointOccupied(new TwoDimensionalPacking (0,sourcePointY.X - 1, sourcePointY.Y)))) { 78 78 sourcePointY.X--; 79 79 } … … 166 166 } 167 167 168 169 168 public override int ShortestPossibleSideFromPoint(TwoDimensionalPacking position) { 170 169 int shortestSide = int.MaxValue; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking3D.cs
r9596 r9598 61 61 var sourcePointX = new ThreeDimensionalPacking(0, position.X + newWidth, position.Y, position.Z); 62 62 if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height && sourcePointX.Z < BinMeasures.Depth) { 63 //Traversing down the y-axis 64 int currentYValue = sourcePointX.Y; 65 while (currentYValue > 0 && !IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointX.X, currentYValue, sourcePointX.Z))) { 66 currentYValue--; 67 } 68 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointX.X, currentYValue, sourcePointX.Z)); 69 70 //Traversing down the z-axis 71 int currentZValue = sourcePointX.Z; 72 while (currentZValue > 0 && !IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointX.X, sourcePointX.Y, currentZValue - 1))) { 73 currentZValue--; 74 } 75 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, currentZValue)); 63 //Traversing down the y-axis 64 ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, sourcePointX.Z); 65 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown (current))) { 66 current = ThreeDimensionalPacking.MoveDown(current); 67 } 68 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 69 while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) { 70 current = ThreeDimensionalPacking.MoveLeft(current); 71 } 72 ExtremePoints.Add(current); 73 74 //Traversing down the z-axis 75 current = new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, sourcePointX.Z); 76 while (current.Z > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveBack (current))) { 77 current = ThreeDimensionalPacking.MoveBack(current); 78 } 79 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 80 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) { 81 current = ThreeDimensionalPacking.MoveDown(current); 82 } 83 ExtremePoints.Add(current); 76 84 } 77 85 … … 82 90 var sourcePointY = new ThreeDimensionalPacking(0, position.X, position.Y + newItem.Height, position.Z); 83 91 if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height && sourcePointY.Z < BinMeasures.Depth) { 84 //Traversing down the x-axis 85 int currentXValue = sourcePointY.X; 86 while (currentXValue > 0 && !IsPointOccupied(new ThreeDimensionalPacking (0, currentXValue - 1, sourcePointY.Y, sourcePointY.Z))) { 87 currentXValue--; 88 } 89 ExtremePoints.Add(new ThreeDimensionalPacking(0, currentXValue, sourcePointY.Y, sourcePointY.Z)); 90 91 //Traversing down the z-axis 92 int currentZValue = sourcePointY.Z; 93 while (currentZValue > 0 && !IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointY.X, sourcePointY.Y, currentZValue - 1))) { 94 currentZValue--; 95 } 96 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, currentZValue)); 92 //Traversing down the x-axis 93 ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, sourcePointY.Z); 94 while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) { 95 current = ThreeDimensionalPacking.MoveLeft(current); 96 } 97 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 98 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) { 99 current = ThreeDimensionalPacking.MoveDown(current); 100 } 101 ExtremePoints.Add(current); 102 103 //Traversing down the z-axis 104 current = new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, sourcePointY.Z); 105 while (current.Z > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveBack(current))) { 106 current = ThreeDimensionalPacking.MoveBack(current); 107 } 108 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 109 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) { 110 current = ThreeDimensionalPacking.MoveDown(current); 111 } 112 ExtremePoints.Add(current); 97 113 } 98 114 … … 104 120 var sourcePointZ = new ThreeDimensionalPacking(0, position.X, position.Y, position.Z + newDepth); 105 121 if (sourcePointZ.X < BinMeasures.Width && sourcePointZ.Y < BinMeasures.Height && sourcePointZ.Z < BinMeasures.Depth) { 106 //Traversing down the x-axis 107 int currentXValue = sourcePointZ.X; 108 while (currentXValue > 0 && !IsPointOccupied(new ThreeDimensionalPacking (0, currentXValue - 1, sourcePointZ.Y, sourcePointZ.Z))) { 109 currentXValue--; 110 } 111 ExtremePoints.Add(new ThreeDimensionalPacking(0, currentXValue, sourcePointZ.Y, sourcePointZ.Z)); 112 113 //Traversing down the y-axis 114 int currentYValue = sourcePointZ.Y; 115 while (currentYValue > 0 && !IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointZ.X, currentYValue, sourcePointZ.Z))) { 116 currentYValue--; 117 } 118 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointZ.X, currentYValue, sourcePointZ.Z)); 122 //Traversing down the x-axis 123 ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointZ.X, sourcePointZ.Y, sourcePointZ.Z); 124 while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) { 125 current = ThreeDimensionalPacking.MoveLeft(current); 126 } 127 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 128 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) { 129 current = ThreeDimensionalPacking.MoveDown(current); 130 } 131 ExtremePoints.Add(current); 132 133 //Traversing down the y-axis 134 current = new ThreeDimensionalPacking(0, sourcePointZ.X, sourcePointZ.Y, sourcePointZ.Z); 135 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) { 136 current = ThreeDimensionalPacking.MoveDown(current); 137 } 138 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 139 while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) { 140 current = ThreeDimensionalPacking.MoveLeft(current); 141 } 142 ExtremePoints.Add(current); 119 143 } 120 144 … … 122 146 OrderBy(ep => ep.Z). 123 147 ThenBy(ep => ep.X). 124 ThenBy(ep => ep.Y) .125 ThenBy(ep => ShortestPossibleSideFromPoint(ep)));148 ThenBy(ep => ep.Y)//.ThenBy(ep => ShortestPossibleSideFromPoint(ep)) 149 ); 126 150 } 127 151 … … 136 160 int epIndex = 0; 137 161 while (epIndex < ExtremePoints.Count && ( 138 !IsPositionFeasible(item, ExtremePoints.ElementAt(epIndex)) || (stackingConstraints && !IsStaticStable(item, ExtremePoints.ElementAt(epIndex))) 162 !IsPositionFeasible(item, ExtremePoints.ElementAt(epIndex)) 163 || !IsSupportedByAtLeastOnePoint(item, ExtremePoints.ElementAt(epIndex)) 164 || (stackingConstraints && !IsStaticStable(item, ExtremePoints.ElementAt(epIndex))) 165 || (stackingConstraints && !IsWeightSupported(item, ExtremePoints.ElementAt(epIndex))) 139 166 )) { epIndex++; } 140 167 … … 146 173 return null; 147 174 } 175 148 176 public override ThreeDimensionalPacking FindPositionBySliding(CuboidPackingItem measures, bool rotated) { 149 177 //Starting-position at upper right corner (=left bottom point of item-rectangle is at position item.width,item.height) … … 217 245 } 218 246 } 219 220 221 [Storable] 222 private bool depthWasDoubled = false; 223 public void DoubleDepth() { 224 if (!depthWasDoubled) { 225 var oldDepth = BinMeasures.Depth; 226 BinMeasures.Depth = BinMeasures.Depth * 2; 227 //OccupiedPoints.ChangeBinMeasures(BinMeasures); 228 depthWasDoubled = true; 229 } 230 } 231 247 232 248 public override int ShortestPossibleSideFromPoint(ThreeDimensionalPacking position) { 233 249 … … 265 281 266 282 if (IsPointOccupied (new ThreeDimensionalPacking (0, position.X, position.Y - 1, position.Z)) 267 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width - 1, position.Y - 1, position.Z))268 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X, position.Y - 1, position.Z + item.Depth - 1))269 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width - 1, position.Y - 1, position.Z + item.Depth - 1)))283 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width, position.Y - 1, position.Z)) 284 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X, position.Y - 1, position.Z + item.Depth)) 285 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width, position.Y - 1, position.Z + item.Depth))) 270 286 return true; 271 287 … … 290 306 return false; 291 307 } 308 309 310 [Storable] 311 private bool depthWasDoubled = false; 312 public void DoubleDepth() { 313 if (!depthWasDoubled) { 314 var oldDepth = BinMeasures.Depth; 315 BinMeasures.Depth = BinMeasures.Depth * 2; 316 //OccupiedPoints.ChangeBinMeasures(BinMeasures); 317 depthWasDoubled = true; 318 } 319 } 320 321 public bool IsSupportedByAtLeastOnePoint(CuboidPackingItem item, ThreeDimensionalPacking position) { 322 if (position.Y == 0) 323 return true; 324 325 int y = position.Y - 1; 326 for (int x = position.X; x < position.X + item.Width; x++) 327 for (int z = position.Z; z < position.Z + item.Depth; z++) 328 if (IsPointOccupied(new ThreeDimensionalPacking(0, x, y, z))) 329 return true; 330 331 return false; 332 } 333 public bool IsWeightSupported(CuboidPackingItem item, ThreeDimensionalPacking ep) { 334 if (ep.Y == 0) 335 return true; 336 337 if (ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X, ep.Y - 1, ep.Z))].SupportsStacking(item) 338 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width, ep.Y - 1, ep.Z))].SupportsStacking(item) 339 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X, ep.Y - 1, ep.Z + item.Depth))].SupportsStacking(item) 340 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width, ep.Y - 1, ep.Z + item.Depth))].SupportsStacking(item)) 341 return true; 342 343 return false; 344 } 292 345 } 293 346 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Plugin.cs
r9596 r9598 26 26 /// Plugin class for HeuristicLab.Problems.BinPacking plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.959 3")]28 [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.9596")] 29 29 [PluginFile("HeuristicLab.Problems.BinPacking-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Common", "3.3")] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/CuboidIdenticalBinPackingProblem.cs
r9563 r9598 145 145 Load(DefaultInstance); 146 146 } 147 148 protected override void RemoveTooBigItems() { 149 PackingItemMeasures.RemoveAll(pi => 150 !PackingBinMeasures.Encloses (new ThreeDimensionalPacking(0, 0, 0, 0, false), pi) && 151 !PackingBinMeasures.Encloses(new ThreeDimensionalPacking(0, 0, 0, 0, true), pi)); 152 } 147 153 #endregion 148 154 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/RectangularIdenticalBinPackingProblem.cs
r9563 r9598 139 139 Load(DefaultInstance); 140 140 } 141 142 protected override void RemoveTooBigItems() { 143 PackingItemMeasures.RemoveAll(pi => 144 !PackingBinMeasures.Encloses(new TwoDimensionalPacking(0, 0, 0, false), pi) && 145 !PackingBinMeasures.Encloses(new TwoDimensionalPacking(0, 0, 0, true), pi)); 146 } 141 147 #endregion 142 148 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Problem/RegularIdenticalBinPackingProblem.cs
r9563 r9598 43 43 using HeuristicLab.Problems.Instances; 44 44 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 45 using HeuristicLab.Problems.BinPacking.Dimensions; 45 46 46 47 namespace HeuristicLab.Problems.BinPacking.Problem { … … 100 101 ApplyHorizontalOrientation(); 101 102 SortItems(); 103 RemoveTooBigItems(); 102 104 PackingItemsParameter.Value.Value = PackingItemMeasures.Count; 103 105 LowerBoundParameter.Value.Value = CalculateLowerBound(); 104 106 } 107 protected abstract void RemoveTooBigItems(); 105 108 protected abstract void InitializeProblemData(); 106 109 protected abstract IPackingPlanEvaluator CreateDefaultEvaluator();
Note: See TracChangeset
for help on using the changeset viewer.