Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/12/18 14:19:06 (7 years ago)
Author:
rhanghof
Message:

#2817:

  • Fixed a bug at creating the extreme points with the point projection based method.
Location:
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointCreation
Files:
3 edited

Legend:

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

    r15617 r15838  
    232232    /// <returns></returns>
    233233    protected bool IsWithinResidualSpaceOfAnotherExtremePoint(BinPacking3D binPacking, Vector3D pos, IEnumerable<ResidualSpace> residualSpaces) {
    234       foreach (var residualSpace in residualSpaces) {
    235         if (IsWithinResidualSpaceOfAnotherExtremePoint(binPacking, pos, residualSpace)) {
    236           return true;
    237         }
    238       }
    239       return false;
     234      return residualSpaces.Any(x => IsWithinResidualSpaceOfAnotherExtremePoint(binPacking, pos, x));
    240235    }
    241236
     
    262257    /// <returns></returns>
    263258    protected virtual bool IsWithinResidualSpaceOfAnotherExtremePoint(Vector3D pos, ResidualSpace rsPos, PackingPosition ep, ResidualSpace rsEp) {
    264       /*old implementation
    265       return rsEp.Width >= pos.X - ep.X + rsPos.Width
    266           && rsEp.Height >= pos.Y - ep.Y + rsPos.Height
    267           && rsEp.Depth >= pos.Z - ep.Z + rsPos.Depth;*/
    268 
    269259      var x = pos.X >= ep.X && pos.X + rsPos.Width <= ep.X + rsEp.Width;
    270260      var y = pos.Y >= ep.Y && pos.Y + rsPos.Height <= ep.Y + rsEp.Height;
     
    294284                             .Select(x => x.Intersect(line))
    295285                             .Where(x => x != null && x.Z <= pos.Z);
    296       if (m.Where(x => x != null).Any()) {
    297         return m.MaxItems(x => x.Y).First();
     286      if (m.Any(x => x != null)) {
     287        return m.MaxItems(x => x.Z).FirstOrDefault();
    298288      }
    299289      return null;
     
    307297                  .Select(x => x.Intersect(line))
    308298                  .Where(x => x != null && x.X <= pos.X);
    309       if (m.Where(x => x != null).Any()) {
    310         return m.MaxItems(x => x.Y).First();
     299      if (m.Any(x => x != null)) {
     300        return m.MaxItems(x => x.X).FirstOrDefault();
    311301      }
    312302      return null;
     
    320310                  .Select(x => x.Intersect(line))
    321311                  .Where(x => x != null && x.Y <= pos.Y);
    322       if (m.Where(x => x != null).Any()) {
    323         return m.MaxItems(x => x.Y).First();
     312      if (m.Any(x => x != null)) {
     313        return m.MaxItems(x => x.Y).FirstOrDefault();
    324314      }
    325315      return null;
     
    333323                  .Select(x => x.Intersect(line))
    334324                  .Where(x => x != null && x.Z >= pos.Z);
    335       if (m.Where(x => x != null).Any()) {
    336         return m.MaxItems(x => x.Y).First();
     325      if (m.Any(x => x != null)) {
     326        return m.MinItems(x => x.Z).FirstOrDefault();
    337327      }
    338328      return null;
     
    346336                  .Select(x => x.Intersect(line))
    347337                  .Where(x => x != null && x.X >= pos.X);
    348       if (m.Where(x => x != null).Any()) {
    349         return m.MaxItems(x => x.Y).First();
     338      if (m.Any(x => x != null)) {
     339        return m.MinItems(x => x.X).FirstOrDefault();
    350340      }
    351341      return null;
     
    359349                  .Select(x => x.Intersect(line))
    360350                  .Where(x => x != null && x.Y >= pos.Y);
    361       if (m.Where(x => x != null).Any()) {
    362         return m.MaxItems(x => x.Y).First();
     351      if (m.Any(x => x != null)) {
     352        return m.MinItems(x => x.Y).FirstOrDefault();
    363353      }
    364354      return null;
  • branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointCreation/ExtremePointCreatorFactory.cs

    r15617 r15838  
    2828namespace HeuristicLab.Problems.BinPacking3D.ExtremePointCreation {
    2929  public static class ExtremePointCreatorFactory {
    30     public static IExtremePointCreator CreateExtremePointCreator(ExtremePointCreationMethod epGenerationMethod, bool useStackingConstraints) {
    31       if (epGenerationMethod == ExtremePointCreationMethod.PointProjection) {
     30   
     31    /// <summary>
     32    /// Returns an extreme point creator depending on the given creation method.
     33    /// </summary>
     34    /// <param name="epCreationMethod"></param>
     35    /// <param name="useStackingConstraints"></param>
     36    /// <returns></returns>
     37    public static IExtremePointCreator CreateExtremePointCreator(ExtremePointCreationMethod epCreationMethod, bool useStackingConstraints) {
     38      if (epCreationMethod == ExtremePointCreationMethod.PointProjection) {
    3239        return new PointProjectionBasedEPCreator();
    33       } else if (epGenerationMethod == ExtremePointCreationMethod.LineProjection) {
     40      } else if (epCreationMethod == ExtremePointCreationMethod.LineProjection) {
    3441        return new LineProjectionBasedEPCreator();
    3542      }
  • branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointCreation/PointProjectionBasedEPCreator.cs

    r15822 r15838  
    5656        GenerateNewExtremePointsForItem(binPacking, it, pos);
    5757      });
    58 
     58     
    5959      // remove not needed extreme points.
    6060      foreach (var extremePoint in binPacking.ExtremePoints.ToList()) {
Note: See TracChangeset for help on using the changeset viewer.