Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/13/17 09:47:49 (6 years ago)
Author:
rhanghof
Message:

#2817:

  • Changed the calculation algorithm for creating extreme points by using line based projection
  • Changed the calculation of the residual spaces for line based projection
File:
1 edited

Legend:

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

    r15488 r15520  
    1515  /// </summary>
    1616  public class PointProjectionBasedEPCreator : ExtremePointCreator {
    17     public override void UpdateExtremePoints(BinPacking3D binPacking, PackingItem item, PackingPosition position) {
    18       GenerateNewExtremePointsForNewItem(binPacking, item, position);
     17    protected override void UpdateExtremePoints(BinPacking3D binPacking, PackingItem item, PackingPosition position) {
     18      GenerateNewExtremePointsForItem(binPacking, item, position);
    1919
    2020      // if an item is fit in below, before, or left of another its extreme points have to be regenerated
    2121      foreach (var above in GetItemsAbove(binPacking, position)) {
    22         GenerateNewExtremePointsForNewItem(binPacking, above.Item2, above.Item1);
     22        GenerateNewExtremePointsForItem(binPacking, above.Item2, above.Item1);
    2323      }
    2424      foreach (var front in GetItemsInfront(binPacking, position)) {
    25         GenerateNewExtremePointsForNewItem(binPacking, front.Item2, front.Item1);
     25        GenerateNewExtremePointsForItem(binPacking, front.Item2, front.Item1);
    2626      }
    2727      foreach (var right in GetItemsOnRight(binPacking, position)) {
    28         GenerateNewExtremePointsForNewItem(binPacking, right.Item2, right.Item1);
     28        GenerateNewExtremePointsForItem(binPacking, right.Item2, right.Item1);
    2929      }
    3030    }
    3131   
    32     public override void UpdateResidualSpace(BinPacking3D binPacking, PackingItem item, PackingPosition position) {
     32    protected override void UpdateResidualSpace(BinPacking3D binPacking, PackingItem item, PackingPosition position) {
    3333      foreach (var ep in binPacking.ExtremePoints.ToList()) {
    34         var rs = binPacking.ResidualSpace[ep];
     34        var rs = binPacking.ResidualSpaces[ep];
    3535        var depth = position.Rotated ? item.Width : item.Depth;
    3636        var width = position.Rotated ? item.Depth : item.Width;
     
    3939          if (ep.X <= position.X && ep.Y >= position.Y && ep.Y < position.Y + item.Height) {
    4040            var diff = position.X - ep.X;
    41             var newRSX = Math.Min(rs.Item1, diff);
    42             rs = Tuple.Create(newRSX, rs.Item2, rs.Item3);
     41            var newRSX = Math.Min(rs.Width, diff);
     42            rs = ResidualSpace.Create(newRSX, rs.Height, rs.Depth);
    4343            changed = true;
    4444          }
    4545          if (ep.Y <= position.Y && ep.X >= position.X && ep.X < position.X + width) {
    4646            var diff = position.Y - ep.Y;
    47             var newRSY = Math.Min(rs.Item2, diff);
    48             rs = Tuple.Create(rs.Item1, newRSY, rs.Item3);
     47            var newRSY = Math.Min(rs.Height, diff);
     48            rs = ResidualSpace.Create(rs.Width, newRSY, rs.Depth);
    4949            changed = true;
    5050          }
     
    5555            ep.X >= position.X && ep.X < position.X + width) {
    5656          var diff = position.Z - ep.Z;
    57           var newRSZ = Math.Min(rs.Item3, diff);
    58           rs = Tuple.Create(rs.Item1, rs.Item2, newRSZ);
     57          var newRSZ = Math.Min(rs.Depth, diff);
     58          rs = ResidualSpace.Create(rs.Width, rs.Height, newRSZ);
    5959          changed = true;
    6060        }
    6161
    6262        if (changed) {
    63           if (IsNonZero(rs) && !IsWithinResidualSpaceOfAnotherExtremePoint(binPacking, new Vector3D(ep), rs)) {
    64             binPacking.ResidualSpace[ep] = rs;
     63          if (!rs.IsZero() && !IsWithinResidualSpaceOfAnotherExtremePoint(binPacking, new Vector3D(ep), rs)) {
     64            binPacking.ResidualSpaces[ep] = rs;
    6565          } else {
    6666            binPacking.ExtremePoints.Remove(ep);
    67             binPacking.ResidualSpace.Remove(ep);
     67            binPacking.ResidualSpaces.Remove(ep);
    6868          }
    6969        }
     
    8383      if (binPacking.ExtremePoints.Add(position)) {
    8484        var rs = CalculateResidualSpace(binPacking, new Vector3D(position));
    85         binPacking.ResidualSpace.Add(position, rs);
     85        binPacking.ResidualSpaces.Add(position, rs);
    8686        // Check if the existing extreme points are shadowed by the new point
    8787        // This is, their residual space fit entirely into the residual space of the new point
    8888        foreach (var ep in binPacking.ExtremePoints.Where(x => x != position && new Vector3D(x).IsInside(position, rs)).ToList()) {
    89           if (IsWithinResidualSpaceOfAnotherExtremePoint(new Vector3D(ep), binPacking.ResidualSpace[ep], position, rs)) {
     89          if (IsWithinResidualSpaceOfAnotherExtremePoint(new Vector3D(ep), binPacking.ResidualSpaces[ep], position, rs)) {
    9090            binPacking.ExtremePoints.Remove(ep);
    91             binPacking.ResidualSpace.Remove(ep);
     91            binPacking.ResidualSpaces.Remove(ep);
    9292          }
    9393        }
Note: See TracChangeset for help on using the changeset viewer.