- Timestamp:
- 06/02/13 04:26:26 (11 years ago)
- Location:
- branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders
- Files:
-
- 2 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftFunctions.cs
r9495 r9563 8 8 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 9 9 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 10 using HeuristicLab.Encodings.PermutationEncoding; 10 11 using HeuristicLab.Problems.BinPacking.Dimensions; 11 12 using HeuristicLab.Problems.BinPacking.Interfaces; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftGroupingVectorDecoder.cs
r9495 r9563 44 44 TwoDimensionalPacking, 45 45 RectangularPackingBin, 46 RectangularPackingItem> {46 RectangularPackingItem>, I2DGVDecoder { 47 47 48 48 public BottomLeftGroupingVectorDecoder() … … 60 60 61 61 62 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {62 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 63 63 64 64 var solution = encodedSolution as GroupingVectorEncoding; … … 66 66 67 67 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures, itemMeasures); 69 69 70 70 result.PackingItemPositions = BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftMultiComponentVectorDecoder.cs
r9495 r9563 44 44 TwoDimensionalPacking, 45 45 RectangularPackingBin, 46 RectangularPackingItem> {46 RectangularPackingItem>, I2DMCVDecoder { 47 47 48 48 public BottomLeftMultiComponentVectorDecoder() … … 60 60 61 61 62 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {62 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 63 63 64 64 var solution = encodedSolution as MultiComponentVectorEncoding; … … 66 66 67 67 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures, itemMeasures); 69 69 70 70 result.PackingItemPositions = BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftPackingSequenceDecoder.cs
r9495 r9563 43 43 TwoDimensionalPacking, 44 44 RectangularPackingBin, 45 RectangularPackingItem> {45 RectangularPackingItem>, I2DPSDecoder { 46 46 47 47 public BottomLeftPackingSequenceDecoder() … … 59 59 60 60 61 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {61 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 62 62 63 63 var solution = encodedSolution as PackingSequenceEncoding; … … 65 65 66 66 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 67 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);67 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures, itemMeasures); 68 68 69 69 result.PackingItemPositions = BottomLeftFunctions.BottomLeftPacking (solution, binMeasures, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointGroupingVectorDecoder2D.cs
r9495 r9563 44 44 TwoDimensionalPacking, 45 45 RectangularPackingBin, 46 RectangularPackingItem> {46 RectangularPackingItem>, I2DGVDecoder { 47 47 48 48 public ExtremePointGroupingVectorDecoder2D () … … 67 67 } 68 68 69 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {69 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 70 70 71 71 var solution = encodedSolution as GroupingVectorEncoding; 72 72 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); 73 73 74 return Decode(solution, PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);74 return Decode(solution, binMeasures, itemMeasures); 75 75 } 76 76 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointMultiComponentVectorDecoder2D.cs
r9495 r9563 45 45 TwoDimensionalPacking, 46 46 RectangularPackingBin, 47 RectangularPackingItem> {47 RectangularPackingItem>, I2DMCVDecoder { 48 48 49 49 public ExtremePointMultiComponentVectorDecoder2D () … … 68 68 } 69 69 70 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {70 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 71 71 72 72 var solution = encodedSolution as MultiComponentVectorEncoding; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointPackingSequenceDecoder2D.cs
r9495 r9563 43 43 TwoDimensionalPacking, 44 44 RectangularPackingBin, 45 RectangularPackingItem> {45 RectangularPackingItem>, I2DPSDecoder { 46 46 47 47 public ExtremePointPackingSequenceDecoder2D () … … 58 58 59 59 60 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) {60 public override PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 61 61 62 62 var solution = encodedSolution as PackingSequenceEncoding; … … 64 64 65 65 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 66 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);66 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures, itemMeasures); 67 67 68 result.PackingItemPositions = ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, PackingItemMeasuresParameter.ActualValue, PackingBinMeasuresParameter.ActualValue);68 result.PackingItemPositions = ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures); 69 69 70 70 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointsFunctions2D.cs
r9495 r9563 8 8 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 9 9 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 10 using HeuristicLab.Encodings.PermutationEncoding; 10 11 using HeuristicLab.Problems.BinPacking.Dimensions; 11 12 using HeuristicLab.Problems.BinPacking.Interfaces; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftFunctions.cs
r9495 r9563 8 8 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 9 9 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 10 using HeuristicLab.Encodings.PermutationEncoding; 10 11 using HeuristicLab.Problems.BinPacking.Dimensions; 11 12 using HeuristicLab.Problems.BinPacking.Interfaces; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftGroupingVectorDecoder.cs
r9495 r9563 43 43 ThreeDimensionalPacking, 44 44 CuboidPackingBin, 45 CuboidPackingItem> {45 CuboidPackingItem>, I3DGVDecoder { 46 46 47 47 public DeepestBottomLeftGroupingVectorDecoder() … … 59 59 60 60 61 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {61 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 62 62 63 63 var solution = encodedSolution as GroupingVectorEncoding; … … 65 65 66 66 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>( 67 PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);67 binMeasures, itemMeasures); 68 68 69 69 ObservableDictionary<int, ThreeDimensionalPacking> packingPositions = DeepestBottomLeftFunctions.DeepestLeftBottomPacking( 70 70 solution, 71 PackingBinMeasuresParameter.ActualValue,72 PackingItemMeasuresParameter.ActualValue);71 binMeasures, 72 itemMeasures); 73 73 74 74 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftMultiComponentVectorDecoder.cs
r9495 r9563 44 44 ThreeDimensionalPacking, 45 45 CuboidPackingBin, 46 CuboidPackingItem> {46 CuboidPackingItem>, I3DMCVDecoder { 47 47 48 48 public DeepestBottomLeftMultiComponentVectorDecoder() … … 60 60 61 61 62 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {62 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 63 63 64 64 var solution = encodedSolution as MultiComponentVectorEncoding; … … 66 66 67 67 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 68 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);68 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures, itemMeasures); 69 69 70 70 result.PackingItemPositions = DeepestBottomLeftFunctions.DeepestLeftBottomPacking (solution, binMeasures, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftPackingSequenceDecoder.cs
r9495 r9563 43 43 ThreeDimensionalPacking, 44 44 CuboidPackingBin, 45 CuboidPackingItem> {45 CuboidPackingItem>, I3DPSDecoder { 46 46 47 47 public DeepestBottomLeftPackingSequenceDecoder() … … 59 59 60 60 61 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {61 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 62 62 63 63 var solution = encodedSolution as PackingSequenceEncoding; … … 65 65 66 66 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 67 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);67 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures, itemMeasures); 68 68 69 69 result.PackingItemPositions = DeepestBottomLeftFunctions.DeepestLeftBottomPacking (solution, binMeasures, itemMeasures); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointGroupingVectorDecoder3D.cs
r9495 r9563 44 44 ThreeDimensionalPacking, 45 45 CuboidPackingBin, 46 CuboidPackingItem> {46 CuboidPackingItem>, I3DGVDecoder { 47 47 48 48 public ExtremePointGroupingVectorDecoder3D () … … 67 67 } 68 68 69 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {69 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 70 70 71 71 var solution = encodedSolution as GroupingVectorEncoding; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointMultiComponentVectorDecoder3D.cs
r9495 r9563 45 45 ThreeDimensionalPacking, 46 46 CuboidPackingBin, 47 CuboidPackingItem> {47 CuboidPackingItem>, I3DMCVDecoder { 48 48 49 49 public ExtremePointMultiComponentVectorDecoder3D () … … 68 68 } 69 69 70 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {70 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 71 71 72 72 var solution = encodedSolution as MultiComponentVectorEncoding; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointPackingSequenceDecoder3D.cs
r9495 r9563 43 43 ThreeDimensionalPacking, 44 44 CuboidPackingBin, 45 CuboidPackingItem> {45 CuboidPackingItem>, I3DPSDecoder { 46 46 47 47 public ExtremePointPackingSequenceDecoder3D () … … 58 58 59 59 60 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(I PackingSolutionEncodingencodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {60 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 61 61 62 62 var solution = encodedSolution as PackingSequenceEncoding; … … 64 64 65 65 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 66 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>( PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);66 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures, itemMeasures); 67 67 68 result.PackingItemPositions = ExtremePointsFunctions3D.ExtremePointBasedPacking(solution, PackingItemMeasuresParameter.ActualValue, PackingBinMeasuresParameter.ActualValue);68 result.PackingItemPositions = ExtremePointsFunctions3D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures); 69 69 70 70 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointsFunctions3D.cs
r9495 r9563 9 9 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 10 10 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 11 using HeuristicLab.Encodings.PermutationEncoding; 11 12 using HeuristicLab.Problems.BinPacking.Dimensions; 12 13 using HeuristicLab.Problems.BinPacking.Interfaces; … … 221 222 return FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePoints, occupiedPoints, itemPositions, false); 222 223 } 224 public static ThreeDimensionalPacking FindExtremePointForItemUsingMaterialAndWeightConstraint(int itemIndex, ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures, 225 HashSet<ThreeDimensionalPacking> extremePoints, List<int[, ,]> occupiedPoints, ObservableDictionary<int, ThreeDimensionalPacking> itemPositions, bool rotated) { 226 227 var itemFromList = itemMeasures[itemIndex]; 228 CuboidPackingItem item = new CuboidPackingItem( 229 rotated ? itemFromList.Depth : itemFromList.Width, 230 itemFromList.Height, 231 rotated ? itemFromList.Width : itemFromList.Depth, 232 itemFromList.TargetBin, itemFromList.Weight, itemFromList.Material); 233 234 int epIndex = 0; 235 while (epIndex < extremePoints.Count && 236 (!DeepestBottomLeftFunctions.IsPositionFeasible(binMeasures, extremePoints.ElementAt(epIndex).AssignedBin, item, extremePoints.ElementAt(epIndex), itemPositions, itemMeasures) || 237 !IsStaticStable(occupiedPoints[extremePoints.ElementAt(epIndex).AssignedBin], item, extremePoints.ElementAt(epIndex)) || 238 !WeightIsSupported(occupiedPoints[extremePoints.ElementAt(epIndex).AssignedBin], item, extremePoints.ElementAt(epIndex), itemMeasures))) { epIndex++; } 239 240 if (epIndex < extremePoints.Count) { 241 var result = extremePoints.ElementAt(epIndex); 242 result.Rotated = rotated; 243 return result; 244 } 245 return null; 246 } 223 247 public static ThreeDimensionalPacking FindExtremePointForItem(int itemIndex, ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures, 224 248 HashSet<ThreeDimensionalPacking> extremePoints, List<int[,,]> occupiedPoints, ObservableDictionary<int, ThreeDimensionalPacking> itemPositions, bool rotated) { … … 228 252 rotated ? itemFromList.Depth : itemFromList.Width, 229 253 itemFromList.Height, 230 rotated ? itemFromList.Width : itemFromList.Depth, 254 rotated ? itemFromList.Width : itemFromList.Depth, 231 255 itemFromList.TargetBin); 232 256 … … 280 304 return false; 281 305 } 306 public static bool WeightIsSupported(int[, ,] occupiedPoints, CuboidPackingItem item, ThreeDimensionalPacking ep, ItemList<CuboidPackingItem> items) { 307 //Static stability is given, if item is placed on the ground 308 if (ep.Y == 0) 309 return true; 310 311 if (items[occupiedPoints[ep.X, ep.Y - 1, ep.Z]].SupportsStacking(item) 312 && items[occupiedPoints[ep.X + item.Width - 1, ep.Y - 1, ep.Z]].SupportsStacking(item) 313 && items[occupiedPoints[ep.X, ep.Y - 1, ep.Z + item.Depth - 1]].SupportsStacking(item) 314 && items[occupiedPoints[ep.X + item.Width - 1, ep.Y - 1, ep.Z + item.Depth - 1]].SupportsStacking(item)) 315 return true; 316 317 //int groundCount = 0; 318 //for (int x = ep.X; x < ep.X + item.Width - 1; x++) { 319 // for (int z = ep.Z; z < ep.Z + item.Depth - 1; z++) { 320 // if (occupiedPoints[x,ep.Y-1, z] != -1) 321 // groundCount++; 322 // } 323 //} 324 //double stableGround = (double)(groundCount) / (double)(item.Width * item.Depth); 325 //if (stableGround > 0.75) 326 // return true; 327 328 return false; 329 } 282 330 public static List<int[, ,]> OccupyPointsForNewItem(List<int[, ,]> occupiedPoints, CuboidPackingItem newItem, ThreeDimensionalPacking position, int itemIndex) { 283 331 int width = position.Rotated ? newItem.Depth : newItem.Width; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ISOContainerMultiComponentVectorDecoder3D.cs
r9495 r9563 40 40 41 41 namespace HeuristicLab.Problems.BinPacking.Decoders { 42 [Item("I dentical bin, three dimensional, extreme points baseddecoder for the MultiComponentVector encoding.", "<Description missing...>")]42 [Item("ISO container decoder for the MultiComponentVector encoding.", "<Description missing...>")] 43 43 [StorableClass] 44 public class ISOContainerMultiComponentVectorDecoder3D : IdenticalBinPackingSolutionDecoder<44 public class ISOContainerMultiComponentVectorDecoder3D : PackingSolutionDecoder< 45 45 ThreeDimensionalPacking, 46 46 CuboidPackingBin, 47 CuboidPackingItem, 48 MultipleBinSizePackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>> { 47 CuboidPackingItem>, I3DMCVDecoder { 49 48 50 49 public ISOContainerMultiComponentVectorDecoder3D () … … 60 59 } 61 60 62 public static MultipleBinSizePackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {61 public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 63 62 64 MultipleBinSizePackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result =65 new MultipleBinSizePackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(new ObservableDictionary<int, CuboidPackingBin>(), itemMeasures);63 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 64 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(new ObservableDictionary<int, CuboidPackingBin>(), itemMeasures); 66 65 67 66 #region Preperations 68 67 int nrOfBins = solution.NrOfBins; 69 70 //Get all indexes of items for every bin according to grouping-vector 68 71 69 Dictionary<int, List<PackingInformation>> unpackedItemIndexesPerBin = new Dictionary<int, List<PackingInformation>>(); 72 Dictionary<int, HashSet<ThreeDimensionalPacking>> extremePointsForBin = new Dictionary<int, HashSet<ThreeDimensionalPacking>>(); 70 Dictionary<int, HashSet<ThreeDimensionalPacking>> extremePointsForBin = new Dictionary<int, HashSet<ThreeDimensionalPacking>>(); 71 ObservableDictionary<int, CuboidPackingBin> resultingBinMeasures = new ObservableDictionary<int, CuboidPackingBin>(); 73 72 var occupiedPoints = new List<int[, ,]>(); 74 73 … … 79 78 extremePointsForBin[i].Add(new ThreeDimensionalPacking(i, 0, 0, 0, false)); 80 79 occupiedPoints = ExtremePointsFunctions3D.IncreaseBinCountForOccupiedPoints(occupiedPoints, binMeasures); 80 resultingBinMeasures[i] = new CuboidPackingBin(binMeasures.Width, binMeasures.Height, binMeasures.Depth); 81 81 } 82 82 … … 95 95 var item = itemMeasures[itemIndex]; 96 96 97 extremePointsForBin[binNr] = ExtremePointsFunctions3D.OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, binMeasures); 98 var positionFound = ExtremePointsFunctions3D.FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 97 extremePointsForBin[binNr] = ExtremePointsFunctions3D.OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, resultingBinMeasures[binNr]); 98 var positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 99 100 if (positionFound == null && resultingBinMeasures[binNr].Depth.Equals(binMeasures.Depth)) { 101 occupiedPoints = DoubleDepthForBinNr(occupiedPoints, ref resultingBinMeasures, binNr); 102 positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 103 } 104 99 105 if (positionFound != null) { 100 106 extremePointsForBin[binNr].Remove(positionFound); 101 107 itemPositions[itemIndex] = positionFound; 102 108 occupiedPoints = ExtremePointsFunctions3D.OccupyPointsForNewItem(occupiedPoints, item, positionFound, itemIndex); 103 extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, binMeasures);109 extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, resultingBinMeasures[binNr]); 104 110 } else { 105 111 remainingItems.Add(unpackedItems[i]); 106 //solution.PackingInformations[binNr].Remove(unpackedItems[i]);112 solution.PackingInformations[binNr].Remove(unpackedItems[i]); 107 113 } 108 114 } … … 119 125 var item = itemMeasures[itemIndex]; 120 126 121 extremePointsForBin[binNr] = ExtremePointsFunctions3D.OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, binMeasures); 122 var positionFound = ExtremePointsFunctions3D.FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 127 extremePointsForBin[binNr] = ExtremePointsFunctions3D.OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, resultingBinMeasures[binNr]); 128 var positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 129 130 131 if (positionFound == null && resultingBinMeasures[binNr].Depth.Equals(binMeasures.Depth)) { 132 occupiedPoints = DoubleDepthForBinNr(occupiedPoints, ref resultingBinMeasures, binNr); 133 positionFound = ExtremePointsFunctions3D.FindExtremePointForItemUsingMaterialAndWeightConstraint(itemIndex, itemMeasures, resultingBinMeasures[binNr], extremePointsForBin[binNr], occupiedPoints, itemPositions, unpackedItems[i].Rotated); 134 } 135 123 136 if (positionFound != null) { 124 137 extremePointsForBin[binNr].Remove(positionFound); 125 138 itemPositions[itemIndex] = positionFound; 126 139 occupiedPoints = ExtremePointsFunctions3D.OccupyPointsForNewItem(occupiedPoints, item, positionFound, itemIndex); 127 extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, binMeasures);140 extremePointsForBin[binNr] = ExtremePointsFunctions3D.GenerateNewExtremePointsForNewItem(extremePointsForBin[binNr], occupiedPoints, item, positionFound, resultingBinMeasures[binNr]); 128 141 remainingItems.Remove(unpackedItems[i]); 129 //solution.PackingInformations[binNr].Add(unpackedItems[i]);142 solution.PackingInformations[binNr].Add(unpackedItems[i]); 130 143 } 131 144 } … … 134 147 extremePointsForBin[nrOfBins].Add(new ThreeDimensionalPacking(nrOfBins, 0, 0, 0, false)); 135 148 occupiedPoints = ExtremePointsFunctions3D.IncreaseBinCountForOccupiedPoints(occupiedPoints, binMeasures); 136 //solution.PackingInformations[nrOfBins] = new ItemList<PackingInformation>(); 149 resultingBinMeasures[nrOfBins] = new CuboidPackingBin(binMeasures.Width, binMeasures.Height, binMeasures.Depth); 150 solution.PackingInformations[nrOfBins] = new ItemList<PackingInformation>(); 137 151 nrOfBins++; 138 152 } 139 153 } 140 154 141 return itemPositions; 142 143 155 result.PackingItemPositions = itemPositions; 156 result.PackingBinMeasures = resultingBinMeasures; 144 157 return result; 145 158 } 146 159 147 protected override MultipleBinSizePackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IPackingSolutionEncoding encodedSolution) { 160 private static List<int[, ,]> DoubleDepthForBinNr(List<int[, ,]> occupiedPoints, ref ObservableDictionary<int, CuboidPackingBin> binMeasures, int binNr) { 161 var oldDepth = binMeasures[binNr].Depth; 162 binMeasures[binNr].Depth = binMeasures[binNr].Depth * 2; 163 var newBinOccupation = new int[binMeasures[binNr].Width, binMeasures[binNr].Height, binMeasures[binNr].Depth]; 164 for (int w = 0; w < binMeasures[binNr].Width; w++) { 165 for (int h = 0; h < binMeasures[binNr].Height; h++) { 166 for (int d = 0; d < binMeasures[binNr].Depth; d++) { 167 if (d < oldDepth) 168 newBinOccupation[w, h, d] = occupiedPoints[binNr][w, h, d]; 169 else 170 newBinOccupation[w, h, d] = -1; 171 } 172 } 173 } 174 175 occupiedPoints[binNr] = newBinOccupation; 176 return occupiedPoints; 177 } 178 179 180 181 182 public override PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> CreatePackingPlanFromEncoding(IItem encodedSolution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 148 183 149 184 var solution = encodedSolution as MultiComponentVectorEncoding; 150 185 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector"); 151 186 152 return Decode(solution, PackingBinMeasuresParameter.ActualValue, PackingItemMeasuresParameter.ActualValue);187 return Decode(solution, binMeasures, itemMeasures); 153 188 } 154 189 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/PackingSolutionDecoder.cs
r9495 r9563 47 47 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 48 48 } 49 p ublicILookupParameter<ItemList<I>> PackingItemMeasuresParameter {49 private ILookupParameter<ItemList<I>> PackingItemMeasuresParameter { 50 50 get { return (LookupParameter<ItemList<I>>)Parameters["PackingItemMeasures"]; } 51 51 } 52 p ublicILookupParameter<B> PackingBinMeasuresParameter {52 private ILookupParameter<B> PackingBinMeasuresParameter { 53 53 get { return (LookupParameter<B>)Parameters["PackingBinMeasures"]; } 54 54 } 55 public ILookupParameter<I PackingSolutionEncoding> EncodedSolutionParameter {56 get { return (ILookupParameter<I PackingSolutionEncoding>)Parameters["EncodedSolution"]; }55 public ILookupParameter<IItem> EncodedSolutionParameter { 56 get { return (ILookupParameter<IItem>)Parameters["EncodedSolution"]; } 57 57 } 58 58 public ILookupParameter<PackingPlan<D,B,I>> PackingPlanParameter { … … 62 62 63 63 public PackingSolutionDecoder() : base() { 64 Parameters.Add(new LookupParameter<I PackingSolutionEncoding>("EncodedSolution", "The new bin-packing solution represented as encoding."));64 Parameters.Add(new LookupParameter<IItem>("EncodedSolution", "The new bin-packing solution represented as encoding.")); 65 65 Parameters.Add(new LookupParameter<PackingPlan<D, B, I>>("PackingPlan", "The decoded bin-packing solution represented as generalized packing plan.")); 66 66 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); … … 75 75 } 76 76 77 public abstract PackingPlan<D, B, I> CreatePackingPlanFromEncoding(I PackingSolutionEncodingsolution, B binMeasures, ItemList<I> itemMeasures);77 public abstract PackingPlan<D, B, I> CreatePackingPlanFromEncoding(IItem solution, B binMeasures, ItemList<I> itemMeasures); 78 78 79 79 public override IOperation Apply() {
Note: See TracChangeset
for help on using the changeset viewer.