- Timestamp:
- 02/28/18 14:05:31 (7 years ago)
- Location:
- branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointCreation/PointProjectionBasedEPCreator.cs
r15731 r15820 49 49 return; 50 50 } 51 51 52 52 // generate all new extreme points parallel. This speeds up the creator. 53 53 var items = binPacking.Items.OrderBy(x => x.Value.Layer); … … 57 57 GenerateNewExtremePointsForItem(binPacking, it, pos); 58 58 }); 59 ExtremePointPruningFactory.CreatePruning().PruneExtremePoints(ExtremePointPruningMethod.PruneBehind, new List<BinPacking3D>() { binPacking }); 60 59 61 60 Parallel.ForEach(items.Where(x => x.Value.Layer >= item.Layer), i => { 62 61 PackingItem it = i.Value; … … 64 63 GenerateNewExtremePointsForItem(binPacking, it, pos); 65 64 }); 66 65 67 66 // remove not needed extreme points. 68 67 foreach (var extremePoint in binPacking.ExtremePoints.ToList()) { -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointPruning/ExtremePointPruning.cs
r15731 r15820 28 28 namespace HeuristicLab.Problems.BinPacking3D.ExtremePointPruning { 29 29 internal class ExtremePointPruning : IExtremePointPruning { 30 public void PruneExtremePoints(ExtremePointPruningMethod pruningMethod, PackingShape bin, Dictionary<BinPacking3D, List<KeyValuePair<int, PackingPosition>>> positions) { 31 if (pruningMethod == ExtremePointPruningMethod.PruneBehind) { 32 PruneExtremePointsBehind(bin, positions); 33 } 30 public void PruneExtremePoints(PackingShape bin, Dictionary<BinPacking3D, List<KeyValuePair<int, PackingPosition>>> positions) { 31 PruneExtremePointsBehind(bin, positions); 34 32 } 35 33 36 public void PruneExtremePoints( ExtremePointPruningMethod pruningMethod,IList<BinPacking3D> binPackings) {34 public void PruneExtremePoints(IList<BinPacking3D> binPackings) { 37 35 if (binPackings.Count <= 0) { 38 36 return; … … 47 45 } 48 46 PruneExtremePointsBehind(binPackings[0].BinShape, fixedPositions); 47 } 48 49 public void PruneExtremePoints(BinPacking3D binPacking, int layer) { 50 var pruningPositions = new List<KeyValuePair<int, PackingPosition>>(); 51 var pruning = new Dictionary<BinPacking3D, List<KeyValuePair<int, PackingPosition>>>(); 52 pruning.Add(binPacking, pruningPositions); 53 foreach (var item in binPacking.Items.Where(x => x.Value.Layer <= layer)) { 54 pruningPositions.Add(new KeyValuePair<int, PackingPosition>(item.Key, binPacking.Positions[item.Key])); 55 } 56 57 PruneExtremePointsBehind(binPacking.BinShape, pruning); 49 58 } 50 59 -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointPruning/ExtremePointPruningFactory.cs
r15618 r15820 28 28 namespace HeuristicLab.Problems.BinPacking3D.ExtremePointPruning { 29 29 public static class ExtremePointPruningFactory { 30 public static IExtremePointPruning CreatePruning( ) {30 public static IExtremePointPruning CreatePruning(ExtremePointPruningMethod pruningMethod) { 31 31 return new ExtremePointPruning(); 32 32 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointPruning/IExtremePointPruning.cs
r15618 r15820 35 35 /// <param name="bin"></param> 36 36 /// <param name="positions"></param> 37 void PruneExtremePoints( ExtremePointPruningMethod pruningMethod,PackingShape bin, Dictionary<BinPacking3D, List<KeyValuePair<int, PackingPosition>>> positions);37 void PruneExtremePoints(PackingShape bin, Dictionary<BinPacking3D, List<KeyValuePair<int, PackingPosition>>> positions); 38 38 39 39 /// <summary> … … 42 42 /// <param name="pruningMethod"></param> 43 43 /// <param name="bins"></param> 44 void PruneExtremePoints(ExtremePointPruningMethod pruningMethod, IList<BinPacking3D> binPackings); 44 void PruneExtremePoints(IList<BinPacking3D> binPackings); 45 46 /// <summary> 47 /// Prunes the extreme points of the given bins depending on the given pruning method. 48 /// </summary> 49 /// <param name="pruningMethod"></param> 50 /// <param name="binPacking"></param> 51 /// <param name="layer" 52 void PruneExtremePoints(BinPacking3D binPacking, int layer); 45 53 } 46 54 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPackerFirstFit.cs
r15652 r15820 63 63 } 64 64 65 ExtremePointPruningFactory.CreatePruning( ).PruneExtremePoints(epPruningMethod,packingList);65 ExtremePointPruningFactory.CreatePruning(epPruningMethod).PruneExtremePoints(packingList); 66 66 return packingList; 67 67 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPackerFormClosure.cs
r15801 r15820 44 44 45 45 46 46 private bool ItemFitsBinShapeWidth(int itemId, PackingItem item, PackingShape binShape) { 47 47 item.Rotated = false; 48 48 item.Tilted = false; -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPackerFreeVolumeBestFit.cs
r15652 r15820 95 95 } 96 96 } 97 ExtremePointPruningFactory.CreatePruning( ).PruneExtremePoints(epPruningMethod,packingList);97 ExtremePointPruningFactory.CreatePruning(epPruningMethod).PruneExtremePoints(packingList); 98 98 return packingList.ToList(); 99 99 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPackerMinRSLeft.cs
r15801 r15820 68 68 } 69 69 70 ExtremePointPruningFactory.CreatePruning( ).PruneExtremePoints(epPruningMethod,packingList);70 ExtremePointPruningFactory.CreatePruning(epPruningMethod).PruneExtremePoints(packingList); 71 71 72 72 return packingList; … … 92 92 } 93 93 94 ExtremePointPruningFactory.CreatePruning( ).PruneExtremePoints(epPruningMethod,packingList);94 ExtremePointPruningFactory.CreatePruning(epPruningMethod).PruneExtremePoints(packingList); 95 95 } 96 96 … … 107 107 protected virtual void PackRemainingItems(ref IList<int> remainingIds, ref BinPacking3D packingBin, IList<PackingItem> items, ExtremePointCreationMethod epCreationMethod, bool useStackingConstraints) { 108 108 IExtremePointCreator extremePointCreator = ExtremePointCreatorFactory.CreateExtremePointCreator(epCreationMethod, useStackingConstraints); 109 109 110 110 var remainingNotWeightSupportedItems = new List<int>(); 111 111 foreach (var itemId in new List<int>(remainingIds)) { 112 var item = items[itemId]; 112 var item = items[itemId]; 113 var clonedPackingBin = packingBin.Clone() as BinPacking3D; 114 ExtremePointPruningFactory.CreatePruning(ExtremePointPruningMethod.PruneBehind).PruneExtremePoints(clonedPackingBin, item.Layer - 1); 113 115 114 116 // If an item doesn't support any weight it should have a minimum waste of the residual space. … … 119 121 remainingNotWeightSupportedItems.Add(itemId); 120 122 } else if (!item.IsStackabel) { 121 PackingPosition position = FindPackingPositionForNotStackableItem( packingBin, item, useStackingConstraints);123 PackingPosition position = FindPackingPositionForNotStackableItem(clonedPackingBin, item, useStackingConstraints); 122 124 // if a valid packing position could be found, the current item can be added to the given bin 123 125 if (position != null) { … … 126 128 } 127 129 } else { 128 PackingPosition position = FindPackingPositionForItem( packingBin, item, useStackingConstraints);130 PackingPosition position = FindPackingPositionForItem(clonedPackingBin, item, useStackingConstraints); 129 131 // if a valid packing position could be found, the current item can be added to the given bin 130 132 if (position != null) { … … 140 142 PackingPosition position = null; 141 143 if (weightSupportedLeft) { 142 position = FindPackingPositionForWeightUnsupportedItem( packingBin, item, useStackingConstraints);144 position = FindPackingPositionForWeightUnsupportedItem(clonedPackingBin, item, useStackingConstraints); 143 145 } else { 144 position = FindPackingPositionForItem( packingBin, item, useStackingConstraints);146 position = FindPackingPositionForItem(clonedPackingBin, item, useStackingConstraints); 145 147 } 146 148 -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPackerResidualSpaceBestFit.cs
r15652 r15820 88 88 } 89 89 90 ExtremePointPruningFactory.CreatePruning( ).PruneExtremePoints(epPruningMethod,packingList);90 ExtremePointPruningFactory.CreatePruning(epPruningMethod).PruneExtremePoints(packingList); 91 91 return packingList; 92 92 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/PackingItem.cs
r15770 r15820 45 45 } 46 46 47 public IFixedValueParameter<IntValue> IdParameter { 48 get { return (IFixedValueParameter<IntValue>)Parameters["Id"]; } 49 } 50 47 51 public PackingShape TargetBin { 48 52 get { return TargetBinParameter.Value; } … … 58 62 get { return LayerParameter.Value.Value; } 59 63 set { LayerParameter.Value.Value = value; } 64 } 65 66 public int Id { 67 get { return IdParameter.Value.Value; } 68 set { IdParameter.Value.Value = value; } 60 69 } 61 70 … … 300 309 return SupportedWeight >= weigth; 301 310 } 311 312 313 302 314 #endregion 303 315 … … 314 326 Parameters.Add(new FixedValueParameter<DoubleValue>("Weight")); 315 327 Parameters.Add(new FixedValueParameter<IntValue>("Layer")); 328 Parameters.Add(new FixedValueParameter<IntValue>("Id")); 316 329 317 330 … … 358 371 Weight = packingItem.Weight; 359 372 Layer = packingItem.Layer; 373 Id = packingItem.Id; 360 374 Rotated = packingItem.Rotated; 361 375 Tilted = packingItem.Tilted;
Note: See TracChangeset
for help on using the changeset viewer.