Changeset 15241
- Timestamp:
- 07/14/17 00:04:58 (7 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/BinPacking2D.cs
r15230 r15241 34 34 public BinPacking2D(PackingShape binShape) 35 35 : base(binShape) { 36 ExtremePoints = new SortedSet<PackingPosition>();37 36 ExtremePoints.Add(binShape.Origin); 38 37 InitializeOccupationLayers(); … … 41 40 [StorableConstructor] 42 41 protected BinPacking2D(bool deserializing) : base(deserializing) { } 43 protected BinPacking2D(BinPacking2D original, Cloner cloner) 44 : base(original, cloner) { 45 this.ExtremePoints = new SortedSet<PackingPosition>(original.ExtremePoints.Select(p => cloner.Clone(p))); 46 } 42 protected BinPacking2D(BinPacking2D original, Cloner cloner) : base(original, cloner) { } 47 43 public override IDeepCloneable Clone(Cloner cloner) { 48 44 return new BinPacking2D(this, cloner); -
trunk/sources/HeuristicLab.Problems.BinPacking/3.3/3D/BinPacking3D.cs
r15230 r15241 33 33 public class BinPacking3D : BinPacking<PackingPosition, PackingShape, PackingItem> { 34 34 35 [Storable] 36 public Dictionary<PackingPosition, Tuple<int, int, int>> ResidualSpace { get; protected set; } 37 35 38 public BinPacking3D(PackingShape binShape) 36 39 : base(binShape) { 37 ExtremePoints = new SortedSet<PackingPosition>();38 40 ResidualSpace = new Dictionary<PackingPosition, Tuple<int,int,int>>(); 39 41 AddExtremePoint(binShape.Origin); … … 44 46 protected BinPacking3D(BinPacking3D original, Cloner cloner) 45 47 : base(original, cloner) { 46 this.ExtremePoints = new SortedSet<PackingPosition>(original.ExtremePoints.Select(p => cloner.Clone(p)));47 48 this.ResidualSpace = new Dictionary<PackingPosition, Tuple<int, int, int>>(); 48 49 foreach (var o in original.ResidualSpace) … … 51 52 public override IDeepCloneable Clone(Cloner cloner) { 52 53 return new BinPacking3D(this, cloner); 54 } 55 56 57 [StorableHook(HookType.AfterDeserialization)] 58 private void AfterDeserialization() { 59 // BackwardsCompatibility3.3 60 #region Backwards compatible code, remove with 3.4 61 if (ResidualSpace == null) 62 ResidualSpace = new Dictionary<PackingPosition, Tuple<int, int, int>>(); 63 #endregion 64 } 65 66 public override void PackItem(int itemID, PackingItem item, PackingPosition position) { 67 ResidualSpace.Remove(position); 68 base.PackItem(itemID, item, position); 53 69 } 54 70 -
trunk/sources/HeuristicLab.Problems.BinPacking/3.3/BinPacking.cs
r15240 r15241 50 50 [Storable] 51 51 protected Dictionary<int, List<int>> OccupationLayers { get; set; } 52 53 [Storable] 54 public Dictionary<TPos, Tuple<int,int,int>> ResidualSpace { get; protected set; } 55 52 56 53 #endregion Properties 57 54 … … 65 62 Items = new ObservableDictionary<int, TItem>(); 66 63 BinShape = (TBin)binShape.Clone(); 64 ExtremePoints = new SortedSet<TPos>(); 67 65 OccupationLayers = new Dictionary<int, List<int>>(); 68 66 } … … 81 79 } 82 80 this.BinShape = (TBin)original.BinShape.Clone(cloner); 81 this.ExtremePoints = new SortedSet<TPos>(original.ExtremePoints.Select(p => cloner.Clone(p))); 83 82 this.OccupationLayers = new Dictionary<int, List<int>>(); 84 83 foreach (var kvp in original.OccupationLayers) { 85 84 OccupationLayers.Add(kvp.Key, new List<int>(kvp.Value)); 86 85 } 87 }88 89 [StorableHook(HookType.AfterDeserialization)]90 private void AfterDeserialization() {91 // BackwardsCompatibility3.392 #region Backwards compatible code, remove with 3.493 if (ResidualSpace == null)94 ResidualSpace = new Dictionary<TPos, Tuple<int, int, int>>();95 #endregion96 86 } 97 87 … … 110 100 Positions[itemID] = position; 111 101 ExtremePoints.Remove(position); 112 if (ResidualSpace != null) ResidualSpace.Remove(position);113 102 foreach (int id in Items.Select(x => x.Key)) 114 103 GenerateNewExtremePointsForNewItem(Items[id], Positions[id]);
Note: See TracChangeset
for help on using the changeset viewer.