Changeset 14146 for branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans
- Timestamp:
- 07/21/16 10:19:55 (8 years ago)
- Location:
- branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs
r14128 r14146 31 31 [Item("BinPacking", "Represents a single-bin packing for a bin-packing problem.")] 32 32 [StorableClass] 33 public abstract class BinPacking<D, B,I>: Item33 public abstract class BinPacking<D, B, I> : Item 34 34 where D : class, IPackingPosition 35 35 where B : PackingShape<D> 36 where I : PackingShape<D> , IPackingItem{36 where I : PackingShape<D> { 37 37 #region Properties 38 38 [Storable] 39 public ObservableDictionary<int, D> ItemPositions { get; private set; } 39 public ObservableDictionary<int, D> ItemPositions { get; private set; } 40 40 41 41 [Storable] … … 43 43 44 44 [Storable] 45 public B BinMeasures { get; private set; } 45 public B BinMeasures { get; private set; } 46 46 47 47 [Storable] … … 53 53 #endregion Properties 54 54 55 protected BinPacking(B binMeasures) : base() { 55 protected BinPacking(B binMeasures) 56 : base() { 56 57 ItemPositions = new ObservableDictionary<int, D>(); 57 58 ItemMeasures = new ObservableDictionary<int, I>(); … … 64 65 [StorableConstructor] 65 66 protected BinPacking(bool deserializing) : base(deserializing) { } 66 protected BinPacking(BinPacking<D, B,I> original, Cloner cloner)67 protected BinPacking(BinPacking<D, B, I> original, Cloner cloner) 67 68 : base(original, cloner) { 68 69 this.ItemPositions = new ObservableDictionary<int, D>(original.ItemPositions); 69 70 this.ItemMeasures = new ObservableDictionary<int, I>(original.ItemMeasures); 70 71 71 this.BinMeasures = (B)original.BinMeasures.Clone(cloner); 72 this.OccupationLayers = new Dictionary<int, List<int>>(original.OccupationLayers); 72 73 } 73 74 74 75 protected abstract void GenerateNewExtremePointsForNewItem(I measures, D position); 75 76 … … 77 78 public abstract D FindPositionBySliding(I measures, bool rotated); 78 79 79 public abstract void SlidingBasedPacking(ref List<int> sequence, ItemList<I> itemMeasures);80 public abstract void SlidingBasedPacking(ref List<int> sequence, ItemList<I> itemMeasures, Dictionary<int, bool> rotationArray);81 public abstract void ExtremePointBasedPacking(ref List<int> sequence, ItemList<I> itemMeasures, bool stackingConstraints);82 public abstract void ExtremePointBasedPacking(ref List<int> sequence, ItemList<I> itemMeasures, bool stackingConstraints, Dictionary<int, bool> rotationArray);80 public abstract void SlidingBasedPacking(ref IList<int> sequence, IList<I> itemMeasures); 81 public abstract void SlidingBasedPacking(ref IList<int> sequence, IList<I> itemMeasures, Dictionary<int, bool> rotationArray); 82 public abstract void ExtremePointBasedPacking(ref IList<int> sequence, IList<I> itemMeasures, bool stackingConstraints); 83 public abstract void ExtremePointBasedPacking(ref IList<int> sequence, IList<I> itemMeasures, bool stackingConstraints, Dictionary<int, bool> rotationArray); 83 84 84 85 public void PackItem(int itemID, I measures, D position) { … … 88 89 foreach (int id in ItemMeasures.Select(x => x.Key)) 89 90 GenerateNewExtremePointsForNewItem(ItemMeasures[id], ItemPositions[id]); 90 91 92 //GenerateNewExtremePointsForNewItem(measures, position);93 //OccupiedPoints.OccupyPoints(measures, position, itemID);94 91 95 92 AddNewItemToOccupationLayers(itemID, measures, position); 96 93 } 97 94 98 public double PackingDensity { 95 public double PackingDensity { 99 96 get { 100 97 double result = 0; … … 108 105 109 106 public int PointOccupation(D position) { 110 //foreach (var ipEntry in ItemPositions) {111 // if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position))112 // return ipEntry.Key;113 //}114 107 foreach (var id in GetLayerItemIDs(position)) { 115 108 if (ItemMeasures[id].EnclosesPoint(ItemPositions[id], position)) … … 120 113 121 114 public bool IsPointOccupied(D position) { 122 //foreach (var ipEntry in ItemPositions) {123 // if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position))124 // return true;125 //}126 115 foreach (var id in GetLayerItemIDs(position)) { 127 116 if (ItemMeasures[id].EnclosesPoint(ItemPositions[id], position)) … … 135 124 return false; 136 125 137 //foreach (var ipEntry in ItemPositions) {138 // if (ItemMeasures[ipEntry.Key].Overlaps(ipEntry.Value, position, measures))139 // return false;140 //}141 126 foreach (var id in GetLayerItemIDs(measures, position)) { 142 127 if (ItemMeasures[id].Overlaps(ItemPositions[id], position, measures)) … … 146 131 return true; 147 132 } 148 public abstract int ShortestPossibleSideFromPoint 149 public abstract bool IsStaticStable 133 public abstract int ShortestPossibleSideFromPoint(D position); 134 public abstract bool IsStaticStable(I measures, D position); 150 135 151 136 … … 154 139 protected abstract List<int> GetLayerItemIDs(D position); 155 140 protected abstract List<int> GetLayerItemIDs(I measures, D position); 156 } 141 } 157 142 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs
r14128 r14146 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 28 27 using HeuristicLab.Data; 29 28 using HeuristicLab.Collections; 30 using HeuristicLab.Encodings.IntegerVectorEncoding;31 29 using HeuristicLab.Problems.BinPacking; 32 using HeuristicLab.Encodings.PermutationEncoding;33 30 34 31 namespace HeuristicLab.Encodings.PackingEncoding {
Note: See TracChangeset
for help on using the changeset viewer.