Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/16/18 13:09:14 (7 years ago)
Author:
rhanghof
Message:

#2817:

  • Some bug fixes at the placing algorithm
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Packer/BinPackerMinRSLeft.cs

    r15838 r15844  
    9595    }
    9696
    97    
     97
    9898
    9999    /// <summary>
     
    107107    protected virtual void PackRemainingItems(ref IList<int> remainingIds, ref BinPacking3D packingBin, IList<PackingItem> items, ExtremePointCreationMethod epCreationMethod, bool useStackingConstraints) {
    108108      IExtremePointCreator extremePointCreator = ExtremePointCreatorFactory.CreateExtremePointCreator(epCreationMethod, useStackingConstraints);
    109      
     109
    110110      var remainingNotWeightSupportedItems = new List<int>();
    111111      foreach (var itemId in new List<int>(remainingIds)) {
     
    118118        // and try to find positions where they don't waste too much space.
    119119        // If there are no weight supporting items left the non supporting ones have to be treated as a supporting one.
    120         if (item.SupportedWeight <= 0 && useStackingConstraints && remainingIds.Any(x => items[x].SupportedWeight > 0)) {
     120        if (item.IsStackabel && item.SupportedWeight <= 0 && useStackingConstraints && remainingIds.Any(x => items[x].SupportedWeight > 0)) {
    121121          remainingNotWeightSupportedItems.Add(itemId);
    122122        } else if (!item.IsStackabel) {
     
    127127            remainingIds.Remove(itemId);
    128128          }
    129         } else  {
     129        } else {
    130130          PackingPosition position = FindPackingPositionForItem(clonedPackingBin, item, useStackingConstraints);
    131131          // if a valid packing position could be found, the current item can be added to the given bin
     
    203203        }
    204204      }
    205       var d =  rsds.Where(x => packingBin.IsPositionFeasible(x.Item, x.Position, useStackingConstraints)).FirstOrDefault();
     205      var d = rsds.FirstOrDefault(x => packingBin.IsPositionFeasible(x.Item, x.Position, useStackingConstraints));
    206206
    207207      if (d == null) {
    208208        return null;
    209209      }
    210 
     210     
    211211      packingItem.Rotated = orientation.Item2;
    212212      packingItem.Tilted = orientation.Item3;
     
    255255          $"Item: ({packingItem.Width} {packingItem.Depth} {packingItem.Height})");
    256256      }
    257            
     257
    258258      var rsds = CalculateResidalSpaceDifferences(packingBin, packingItem, useStackingConstraints).Where(x => x != null);
    259259      var rsd = rsds.FirstOrDefault();
     
    266266      packingItem.Rotated = rsd.Item.Rotated;
    267267      packingItem.Tilted = rsd.Item.Tilted;
    268      
     268
    269269      return rsd.Position;
    270270    }
     
    319319        }
    320320      }
    321       return rsds.Where(rsd => packingBin.IsPositionFeasible(rsd.Item, rsd.Position, useStackingConstraints)).FirstOrDefault();
     321
     322      // If the packer uses line projection it migth happen, that an extreme point right of the disired on will be chosen.
     323      // To avoid this, if there is an extreme point on the rigth side available this point will be returned.
     324      var possible = rsds.Where(rsd => packingBin.IsPositionFeasible(rsd.Item, rsd.Position, useStackingConstraints));
     325      var prevered = possible.FirstOrDefault();
     326
     327      return possible.Where(x => x.Position.Z == prevered.Position.Z && x.Position.Y == prevered.Position.Y).OrderBy(x => x.Position.X).FirstOrDefault();
    322328    }
    323329
     
    401407        return 0;
    402408      }
     409
     410      public override string ToString() {
     411        return string.Format("({1},{2},{3})", X, Y, Z);
     412      }
    403413    }
    404414
Note: See TracChangeset for help on using the changeset viewer.