Ignore:
Timestamp:
12/20/17 16:15:38 (23 months ago)
Author:
rhanghof
Message:

#2817:

  • Unittests
  • Bugfixes on the line projection based extreme point creation method
File:
1 edited

Legend:

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

    r15520 r15554  
    3434  [StorableClass]
    3535  public class BinPacking3D : BinPacking<PackingPosition, PackingShape, PackingItem> {
    36 
     36   
    3737    [Storable]
    38     public Dictionary<PackingPosition, ResidualSpace> ResidualSpaces { get; set; }
    39 
    40     [Storable]
    41     public SortedSet<PackingPosition> ExtremePoints { get; protected set; }
     38    public IDictionary<PackingPosition, IEnumerable<ResidualSpace>> ExtremePoints { get; protected set; }
    4239
    4340
    4441    public BinPacking3D(PackingShape binShape)
    4542      : base(binShape) {
    46       ExtremePoints = new SortedSet<PackingPosition>();
    47       ResidualSpaces = new Dictionary<PackingPosition, ResidualSpace>();
     43      ExtremePoints = new SortedList<PackingPosition, IEnumerable<ResidualSpace>>();
    4844     
    49       ExtremePoints.Add(binShape.Origin);
    50       ResidualSpaces.Add(binShape.Origin, new ResidualSpace(BinShape.Width, BinShape.Height, BinShape.Depth));
     45      ExtremePoints.Add(binShape.Origin, new List<ResidualSpace>() {ResidualSpace.Create(binShape.Width, binShape.Height, binShape.Depth)});
    5146    }
    5247
     
    5651    protected BinPacking3D(BinPacking3D original, Cloner cloner)
    5752      : base(original, cloner) {
    58       this.ResidualSpaces = new Dictionary<PackingPosition, ResidualSpace>();
    59       foreach (var o in original.ResidualSpaces)
    60         this.ResidualSpaces.Add(cloner.Clone(o.Key), ResidualSpace.Create(o.Value));
    61 
    62       this.ExtremePoints = new SortedSet<PackingPosition>(original.ExtremePoints.Select(p => cloner.Clone(p)));
     53
     54      this.ExtremePoints = new SortedList<PackingPosition, IEnumerable<ResidualSpace>>();
     55      foreach (var extremePoint in original.ExtremePoints) {
     56        var residualSpaces = new List<ResidualSpace>();
     57        foreach (var residualSpace in extremePoint.Value) {
     58          residualSpaces.Add(cloner.Clone(residualSpace));
     59        }
     60        ExtremePoints.Add(cloner.Clone(extremePoint.Key), residualSpaces);
     61      }
    6362    }
    6463
     
    6766    }
    6867
    69 
    70     [StorableHook(HookType.AfterDeserialization)]
    71     private void AfterDeserialization() {
    72       // BackwardsCompatibility3.3
    73       #region Backwards compatible code, remove with 3.4
    74       if (ResidualSpaces == null)
    75         ResidualSpaces = new Dictionary<PackingPosition, ResidualSpace>();
    76       #endregion
    77     }
    78 
    79 
    80 
     68   
    8169
    8270    /// <summary>
     
    9078      Positions[itemID] = position;
    9179      ExtremePoints.Remove(position);
    92       ResidualSpaces.Remove(position);
    9380    }
    9481
Note: See TracChangeset for help on using the changeset viewer.