Changeset 15822 for branches/2817-BinPackingSpeedup
- Timestamp:
- 02/28/18 15:33:30 (7 years ago)
- Location:
- branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointCreation/PointProjectionBasedEPCreator.cs
r15820 r15822 50 50 } 51 51 52 // generate all new extreme points parallel. This speeds up the creator. 53 var items = binPacking.Items.OrderBy(x => x.Value.Layer); 54 Parallel.ForEach(items.Where(x => x.Value.Layer < item.Layer), i => { 55 PackingItem it = i.Value; 56 PackingPosition pos = binPacking.Positions[i.Key]; 57 GenerateNewExtremePointsForItem(binPacking, it, pos); 58 }); 59 60 Parallel.ForEach(items.Where(x => x.Value.Layer >= item.Layer), i => { 52 // generate all new extreme points parallel. This speeds up the creator. 53 Parallel.ForEach(binPacking.Items, i => { 61 54 PackingItem it = i.Value; 62 55 PackingPosition pos = binPacking.Positions[i.Key]; -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointPruning/ExtremePointPruning.cs
r15820 r15822 47 47 } 48 48 49 public void PruneExtremePoints(BinPacking3D binPacking, int layer) {49 public void PruneExtremePoints(BinPacking3D binPacking, int sequenceNumber) { 50 50 var pruningPositions = new List<KeyValuePair<int, PackingPosition>>(); 51 51 var pruning = new Dictionary<BinPacking3D, List<KeyValuePair<int, PackingPosition>>>(); 52 52 pruning.Add(binPacking, pruningPositions); 53 foreach (var item in binPacking.Items.Where(x => x.Value. Layer <= layer)) {53 foreach (var item in binPacking.Items.Where(x => x.Value.SequenceGroup <= sequenceNumber)) { 54 54 pruningPositions.Add(new KeyValuePair<int, PackingPosition>(item.Key, binPacking.Positions[item.Key])); 55 55 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointPruning/IExtremePointPruning.cs
r15820 r15822 50 50 /// <param name="binPacking"></param> 51 51 /// <param name="layer" 52 void PruneExtremePoints(BinPacking3D binPacking, int layer);52 void PruneExtremePoints(BinPacking3D binPacking, int sequenceNumber); 53 53 } 54 54 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Instances/ThreeDInstanceParser.cs
r15731 r15822 56 56 var tilt = GetNextInteger(reader); 57 57 for (var i = 0; i < pieces; i++) { 58 PackingItem item = new PackingItem(width, height, length, Bin, weight, material) {58 PackingItem item = new PackingItem(width, height, length, Bin, weight, 0, material) { 59 59 RotateEnabled = rotate == 0 ? false : true, 60 60 TiltEnabled = tilt == 0 ? false : true, -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPacker.cs
r15731 r15822 94 94 packingItem.Height, 95 95 packingItem.Depth, 96 packingItem.TargetBin, packingItem.Weight, packingItem.Layer); 96 packingItem.TargetBin, 97 packingItem.Weight, 98 packingItem.SequenceGroup, 99 packingItem.Layer); 97 100 98 101 // The extremepoints are sortet by Y / Z / X -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPackerMinRSLeft.cs
r15820 r15822 112 112 var item = items[itemId]; 113 113 var clonedPackingBin = packingBin.Clone() as BinPacking3D; 114 ExtremePointPruningFactory.CreatePruning(ExtremePointPruningMethod.PruneBehind).PruneExtremePoints(clonedPackingBin, item. Layer- 1);114 ExtremePointPruningFactory.CreatePruning(ExtremePointPruningMethod.PruneBehind).PruneExtremePoints(clonedPackingBin, item.SequenceGroup - 1); 115 115 116 116 // If an item doesn't support any weight it should have a minimum waste of the residual space. -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/PackingItem.cs
r15820 r15822 45 45 } 46 46 47 public IFixedValueParameter<IntValue> SequenceGroupParameter { 48 get { return (IFixedValueParameter<IntValue>)Parameters["SequenceGroup"]; } 49 } 50 47 51 public IFixedValueParameter<IntValue> IdParameter { 48 52 get { return (IFixedValueParameter<IntValue>)Parameters["Id"]; } … … 64 68 } 65 69 70 public int SequenceGroup { 71 get { return SequenceGroupParameter.Value.Value; } 72 set { SequenceGroupParameter.Value.Value = value; } 73 } 74 66 75 public int Id { 67 76 get { return IdParameter.Value.Value; } … … 324 333 : base() { 325 334 Parameters.Add(new ValueParameter<PackingShape>("TargetBin")); 326 Parameters.Add(new FixedValueParameter<DoubleValue>("Weight")); 335 Parameters.Add(new FixedValueParameter<DoubleValue>("Weight")); 327 336 Parameters.Add(new FixedValueParameter<IntValue>("Layer")); 337 Parameters.Add(new FixedValueParameter<IntValue>("SequenceGroup")); 328 338 Parameters.Add(new FixedValueParameter<IntValue>("Id")); 329 339 … … 356 366 } 357 367 358 public PackingItem(int width, int height, int depth, PackingShape targetBin, double weight, int layer)368 public PackingItem(int width, int height, int depth, PackingShape targetBin, double weight, int sequenceNumber, int layer) 359 369 : this(width, height, depth, targetBin) { 360 370 this.Weight = weight; 361 371 this.Layer = layer; 362 } 363 364 372 this.SequenceGroup = sequenceNumber; 373 } 365 374 366 375 public PackingItem(PackingItem packingItem) : this() { … … 371 380 Weight = packingItem.Weight; 372 381 Layer = packingItem.Layer; 382 SequenceGroup = packingItem.SequenceGroup; 373 383 Id = packingItem.Id; 374 384 Rotated = packingItem.Rotated; -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Sorting/PermutationPackingItemSorter.cs
r15731 r15822 136 136 return new Permutation(PermutationTypes.Absolute, 137 137 items.Select((v, i) => new { Index = i, Item = v }) 138 .OrderBy(x => x.Item. Layer)138 .OrderBy(x => x.Item.SequenceGroup) 139 139 .ThenByDescending(x => x.Item.Depth * x.Item.Width * x.Item.Height) 140 140 .ThenByDescending(x => x.Item.Height) … … 150 150 return new Permutation(PermutationTypes.Absolute, 151 151 items.Select((v, i) => new { Index = i, Item = v }) 152 .OrderBy(x => x.Item. Layer)152 .OrderBy(x => x.Item.SequenceGroup) 153 153 .ThenByDescending(x => x.Item.Height) 154 154 .ThenByDescending(x => x.Item.Depth * x.Item.Width * x.Item.Height) … … 164 164 return new Permutation(PermutationTypes.Absolute, 165 165 items.Select((v, i) => new { Index = i, Item = v }) 166 .OrderBy(x => x.Item. Layer)166 .OrderBy(x => x.Item.SequenceGroup) 167 167 .ThenByDescending(x => x.Item.Depth * x.Item.Width) 168 168 .ThenByDescending(x => x.Item.Height) … … 178 178 return new Permutation(PermutationTypes.Absolute, 179 179 items.Select((v, i) => new { Index = i, Item = v }) 180 .OrderBy(x => x.Item. Layer)180 .OrderBy(x => x.Item.SequenceGroup) 181 181 .ThenByDescending(x => x.Item.Height) 182 182 .ThenByDescending(x => x.Item.Depth * x.Item.Width) … … 198 198 items.Select((v, i) => new { Index = i, Item = v, ClusterId = (int)(Math.Ceiling(v.Width * v.Depth / clusterRange)) }) 199 199 .GroupBy(x => x.ClusterId) 200 .Select(x => new { Cluster = x.Key, Items = x.OrderBy(z => z.Item. Layer).ThenByDescending(y => y.Item.Height).ToList() })200 .Select(x => new { Cluster = x.Key, Items = x.OrderBy(z => z.Item.SequenceGroup).ThenByDescending(y => y.Item.Height).ToList() }) 201 201 .OrderByDescending(x => x.Cluster) 202 202 .SelectMany(x => x.Items) … … 218 218 items.Select((v, i) => new { Index = i, Item = v, ClusterId = (int)(Math.Ceiling(v.Height / clusterRange2)) }) 219 219 .GroupBy(x => x.ClusterId) 220 .Select(x => new { Cluster = x.Key, Items = x.OrderBy(z => z.Item. Layer).ThenByDescending(y => y.Item.Depth * y.Item.Width).ToList() })220 .Select(x => new { Cluster = x.Key, Items = x.OrderBy(z => z.Item.SequenceGroup).ThenByDescending(y => y.Item.Depth * y.Item.Width).ToList() }) 221 221 .OrderByDescending(x => x.Cluster) 222 222 .SelectMany(x => x.Items)
Note: See TracChangeset
for help on using the changeset viewer.