Changeset 9599
- Timestamp:
- 06/09/13 12:58:39 (11 years ago)
- Location:
- branches/HeuristicLab.BinPacking
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Plugin.cs
r9598 r9599 26 26 /// Plugin class for HeuristicLab.Problems.BinPacking.Views plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Problems.BinPacking.Views", "3.3.7.959 6")]28 [Plugin("HeuristicLab.Problems.BinPacking.Views", "3.3.7.9598")] 29 29 [PluginFile("HeuristicLab.Problems.BinPacking.Views-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Common", "3.3")] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Properties/AssemblyInfo.cs
r9598 r9599 54 54 // by using the '*' as shown below: 55 55 [assembly: AssemblyVersion("3.3.0.0")] 56 [assembly: AssemblyFileVersion("3.3.7.959 6")]56 [assembly: AssemblyFileVersion("3.3.7.9598")] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/BinBasedMultiComponentVectorCrossover.cs
r9596 r9599 46 46 47 47 int nrOfItems = parent1.NrOfItems; 48 48 49 bool[] itemAlreadyAssigned = new bool[nrOfItems]; 49 50 int nrOfBins = parent1.NrOfBins > parent2.NrOfBins ? parent2.NrOfBins : parent1.NrOfBins; … … 82 83 if (!itemAlreadyAssigned[itemID]) 83 84 child.PackingInformations[0].Add(new PackingInformation(itemID, random.Next(2) == 0 ? true : false)); 84 } 85 85 } 86 86 87 87 return child; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/SequenceBasedMultiComponentVectorCrossover.cs
r9596 r9599 92 92 child.PackingInformations[0].Add(new PackingInformation(itemID, random.Next(2) == 0 ? true : false)); 93 93 } 94 95 94 96 95 return child; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/ThreeWayMultiComponentVectorManipulator.cs
r9495 r9599 58 58 if (individual.NrOfBins > 1) 59 59 do { targetBin = random.Next(individual.NrOfBins); } 60 while (targetBin != affectedBin);60 while (targetBin == affectedBin); 61 61 individual.PackingInformations = SingleGroupingMove.GetVectorAfterMove(individual, affectedBin, affectedIndex, targetBin).PackingInformations; 62 62 } … … 67 67 if (nrOfItems > 1) 68 68 do { targetIndex = random.Next(nrOfItems); } 69 while (targetIndex != affectedIndex);69 while (targetIndex == affectedIndex); 70 70 individual.PackingInformations = ChangePositionMove.GetVectorAfterMove(individual, affectedBin, affectedIndex, targetIndex).PackingInformations; 71 71 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs
r9598 r9599 54 54 55 55 [Storable] 56 public HashSet<D> ExtremePoints { get; protected set; } 56 //public HashSet<D> ExtremePoints { get; protected set; } 57 public SortedSet<D> ExtremePoints { get; protected set; } 57 58 58 //[Storable] 59 //public OccupiedPoints<D, B, I> OccupiedPoints { get; protected set; } 59 [Storable] 60 protected Dictionary<int, List<int>> OccupationLayers { get; set; } 61 60 62 #endregion Properties 61 63 … … 64 66 ItemMeasures = new ObservableDictionary<int, I>(); 65 67 BinMeasures = (B)binMeasures.Clone(); 66 ExtremePoints = new HashSet<D>();67 ExtremePoints.Add(binMeasures.Origin);68 OccupationLayers = new Dictionary<int, List<int>>(); 69 InitializeOccupationLayers(); 68 70 } 71 69 72 70 73 [StorableConstructor] … … 75 78 this.ItemMeasures = new ObservableDictionary<int, I>(original.ItemMeasures); 76 79 this.BinMeasures = (B)original.BinMeasures.Clone(cloner); 80 this.OccupationLayers = new Dictionary<int, List<int>>(original.OccupationLayers); 77 81 } 78 82 … … 91 95 ItemPositions[itemID] = position; 92 96 ExtremePoints.Remove(position); 93 GenerateNewExtremePointsForNewItem(measures, position); 97 foreach (int id in ItemMeasures.Select(x => x.Key)) 98 GenerateNewExtremePointsForNewItem(ItemMeasures[id], ItemPositions[id]); 99 100 101 //GenerateNewExtremePointsForNewItem(measures, position); 94 102 //OccupiedPoints.OccupyPoints(measures, position, itemID); 103 104 AddNewItemToOccupationLayers(itemID, measures, position); 95 105 } 96 106 … … 107 117 108 118 public int PointOccupation(D position) { 109 foreach (var ipEntry in ItemPositions) { 110 if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position)) 111 return ipEntry.Key; 119 //foreach (var ipEntry in ItemPositions) { 120 // if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position)) 121 // return ipEntry.Key; 122 //} 123 foreach (var id in GetLayerItemIDs(position)) { 124 if (ItemMeasures[id].EnclosesPoint(ItemPositions[id], position)) 125 return id; 112 126 } 113 127 return -1; 114 128 } 129 115 130 public bool IsPointOccupied(D position) { 116 foreach (var ipEntry in ItemPositions) { 117 if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position)) 131 //foreach (var ipEntry in ItemPositions) { 132 // if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position)) 133 // return true; 134 //} 135 foreach (var id in GetLayerItemIDs(position)) { 136 if (ItemMeasures[id].EnclosesPoint(ItemPositions[id], position)) 118 137 return true; 119 138 } 120 139 return false; 121 140 } 122 public bool IsPositionFeasible(I currentItem, D position) {141 public bool IsPositionFeasible(I measures, D position) { 123 142 //In this case feasability is defined as following: 1. the item fits into the bin-borders; 2. the point is supported by something; 3. the item does not collide with another already packed item 124 if (!BinMeasures.Encloses(position, currentItem))143 if (!BinMeasures.Encloses(position, measures)) 125 144 return false; 126 145 127 foreach (var ipEntry in ItemPositions) { 128 if (ItemMeasures[ipEntry.Key].Overlaps(ipEntry.Value, position, currentItem)) 146 //foreach (var ipEntry in ItemPositions) { 147 // if (ItemMeasures[ipEntry.Key].Overlaps(ipEntry.Value, position, measures)) 148 // return false; 149 //} 150 foreach (var id in GetLayerItemIDs(measures, position)) { 151 if (ItemMeasures[id].Overlaps(ItemPositions[id], position, measures)) 129 152 return false; 130 153 } … … 133 156 } 134 157 public abstract int ShortestPossibleSideFromPoint (D position); 135 public abstract bool IsStaticStable (I item, D position); 158 public abstract bool IsStaticStable (I measures, D position); 159 160 161 protected abstract void InitializeOccupationLayers(); 162 protected abstract void AddNewItemToOccupationLayers(int itemID, I measures, D position); 163 protected abstract List<int> GetLayerItemIDs(D position); 164 protected abstract List<int> GetLayerItemIDs(I measures, D position); 136 165 } 137 166 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking2D.cs
r9598 r9599 41 41 public class BinPacking2D : BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> { 42 42 43 public BinPacking2D(RectangularPackingBin binMeasures) : base(binMeasures) { 44 //OccupiedPoints = new OccupiedPoints2D(binMeasures); 43 public BinPacking2D(RectangularPackingBin binMeasures) 44 : base(binMeasures) { 45 //ExtremePoints = new HashSet<TwoDimensionalPacking>(); 46 ExtremePoints = new SortedSet<TwoDimensionalPacking>(new EPComparer2D()); 47 ExtremePoints.Add(binMeasures.Origin); 45 48 } 46 49 [StorableConstructor] … … 48 51 protected BinPacking2D(BinPacking2D original, Cloner cloner) 49 52 : base(original, cloner) { 53 this.ExtremePoints = new SortedSet<TwoDimensionalPacking>(original.ExtremePoints, new EPComparer2D()); 50 54 } 51 55 public override IDeepCloneable Clone(Cloner cloner) { … … 62 66 if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height) { 63 67 //Traversing down the y-axis 64 while (sourcePointX.Y > 0 && (-1).Equals(IsPointOccupied(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y - 1)))) {68 while (sourcePointX.Y > 0 && !IsPointOccupied(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y - 1))) { 65 69 sourcePointX.Y--; 66 70 } … … 75 79 if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height) { 76 80 //Traversing down the x-axis 77 while (sourcePointY.X > 0 && (-1).Equals(IsPointOccupied(new TwoDimensionalPacking (0,sourcePointY.X - 1, sourcePointY.Y)))) {81 while (sourcePointY.X > 0 && !IsPointOccupied(new TwoDimensionalPacking (0,sourcePointY.X - 1, sourcePointY.Y))) { 78 82 sourcePointY.X--; 79 83 } … … 81 85 } 82 86 83 ExtremePoints = new HashSet<TwoDimensionalPacking>(ExtremePoints. 84 OrderBy(ep => ep.X). 85 ThenBy(ep => ep.Y). 86 ThenBy(ep => ShortestPossibleSideFromPoint(ep))); 87 //ExtremePoints.RemoveWhere(ep => IsPointOccupied(ep)); 88 89 //ExtremePoints = new HashSet<TwoDimensionalPacking>(ExtremePoints. 90 // OrderBy(ep => ep.X). 91 // ThenBy(ep => ep.Y). 92 // ThenBy(ep => ShortestPossibleSideFromPoint(ep))); 87 93 } 88 94 … … 190 196 throw new NotImplementedException(); 191 197 } 198 199 200 protected override void InitializeOccupationLayers() { 201 for (int i = 0; i*10 <= BinMeasures.Width; i += 1 ) { 202 OccupationLayers[i] = new List<int>(); 203 } 204 } 205 protected override void AddNewItemToOccupationLayers(int itemID, RectangularPackingItem measures, TwoDimensionalPacking position) { 206 int x1 = position.X / 10; 207 int x2 = (position.X + (position.Rotated ? measures.Height : measures.Width)) / 10; 208 209 for (int i = x1; i <= x2; i++) 210 OccupationLayers[i].Add(itemID); 211 } 212 protected override List<int> GetLayerItemIDs(TwoDimensionalPacking position) { 213 return OccupationLayers[position.X / 10]; 214 } 215 protected override List<int> GetLayerItemIDs(RectangularPackingItem measures, TwoDimensionalPacking position) { 216 List<int> result = new List<int> (); 217 int x1 = position.X / 10; 218 int x2 = (position.X + (position.Rotated ? measures.Height : measures.Width)) / 10; 219 220 for (int i = x1; i <= x2; i++) 221 result.AddRange(OccupationLayers[i]); 222 223 return result; 224 } 225 } 226 public class EPComparer2D : IComparer<TwoDimensionalPacking> { 227 public int Compare(TwoDimensionalPacking a, TwoDimensionalPacking b) { 228 int result = a.X.CompareTo(b.X); 229 if (result == 0) 230 result = a.Y.CompareTo(b.Y); 231 232 return result; 233 } 192 234 } 193 235 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking3D.cs
r9598 r9599 41 41 public class BinPacking3D : BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> { 42 42 43 public BinPacking3D(CuboidPackingBin binMeasures) : base(binMeasures) { 44 //OccupiedPoints = new OccupiedPoints3D(binMeasures); 43 public BinPacking3D(CuboidPackingBin binMeasures) 44 : base(binMeasures) { 45 //ExtremePoints = new HashSet<ThreeDimensionalPacking>(); 46 ExtremePoints = new SortedSet<ThreeDimensionalPacking>(new EPComparer3D()); 47 ExtremePoints.Add(binMeasures.Origin); 45 48 } 46 49 [StorableConstructor] … … 48 51 protected BinPacking3D(BinPacking3D original, Cloner cloner) 49 52 : base(original, cloner) { 50 this.depthWasDoubled = original.depthWasDoubled; 53 this.depthWasDoubled = original.depthWasDoubled; 54 this.ExtremePoints = new SortedSet<ThreeDimensionalPacking>(original.ExtremePoints, new EPComparer3D()); 51 55 } 52 56 public override IDeepCloneable Clone(Cloner cloner) { … … 63 67 //Traversing down the y-axis 64 68 ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, sourcePointX.Z); 65 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown (current))) {66 current = ThreeDimensionalPacking.MoveDown(current); 67 } 68 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 69 while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {69 while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown (current))) { 70 current = ThreeDimensionalPacking.MoveDown(current); 71 } 72 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 73 while (current.X > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) { 70 74 current = ThreeDimensionalPacking.MoveLeft(current); 71 75 } … … 74 78 //Traversing down the z-axis 75 79 current = new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, sourcePointX.Z); 76 while (current.Z > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveBack (current))) {80 while (current.Z > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveBack (current))) { 77 81 current = ThreeDimensionalPacking.MoveBack(current); 78 82 } 79 83 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 80 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {84 while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) { 81 85 current = ThreeDimensionalPacking.MoveDown(current); 82 86 } … … 92 96 //Traversing down the x-axis 93 97 ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, sourcePointY.Z); 94 while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {98 while (current.X > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) { 95 99 current = ThreeDimensionalPacking.MoveLeft(current); 96 100 } 97 101 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 98 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {102 while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) { 99 103 current = ThreeDimensionalPacking.MoveDown(current); 100 104 } … … 103 107 //Traversing down the z-axis 104 108 current = new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, sourcePointY.Z); 105 while (current.Z > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveBack(current))) {109 while (current.Z > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveBack(current))) { 106 110 current = ThreeDimensionalPacking.MoveBack(current); 107 111 } 108 112 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 109 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {113 while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) { 110 114 current = ThreeDimensionalPacking.MoveDown(current); 111 115 } … … 122 126 //Traversing down the x-axis 123 127 ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointZ.X, sourcePointZ.Y, sourcePointZ.Z); 124 while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {128 while (current.X > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) { 125 129 current = ThreeDimensionalPacking.MoveLeft(current); 126 130 } 127 131 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 128 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {132 while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) { 129 133 current = ThreeDimensionalPacking.MoveDown(current); 130 134 } … … 133 137 //Traversing down the y-axis 134 138 current = new ThreeDimensionalPacking(0, sourcePointZ.X, sourcePointZ.Y, sourcePointZ.Z); 135 while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {136 current = ThreeDimensionalPacking.MoveDown(current); 137 } 138 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 139 while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {139 while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) { 140 current = ThreeDimensionalPacking.MoveDown(current); 141 } 142 ExtremePoints.Add((ThreeDimensionalPacking)current.Clone()); 143 while (current.X > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) { 140 144 current = ThreeDimensionalPacking.MoveLeft(current); 141 145 } … … 143 147 } 144 148 145 ExtremePoints = new HashSet<ThreeDimensionalPacking>(ExtremePoints. 146 OrderBy(ep => ep.Z). 147 ThenBy(ep => ep.X). 148 ThenBy(ep => ep.Y)//.ThenBy(ep => ShortestPossibleSideFromPoint(ep)) 149 ); 149 //ExtremePoints.RemoveWhere(ep => IsPointOccupied (ep)); 150 151 //ExtremePoints = new HashSet<ThreeDimensionalPacking>(ExtremePoints. 152 // OrderBy(ep => ep.Z). 153 // ThenBy(ep => ep.X). 154 // ThenBy(ep => ep.Y)//.ThenBy(ep => ShortestPossibleSideFromPoint(ep)) 155 // ); 150 156 } 151 157 … … 281 287 282 288 if (IsPointOccupied (new ThreeDimensionalPacking (0, position.X, position.Y - 1, position.Z)) 283 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width , position.Y - 1, position.Z))284 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X, position.Y - 1, position.Z + item.Depth ))285 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width , position.Y - 1, position.Z + item.Depth)))289 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width-1, position.Y - 1, position.Z)) 290 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X, position.Y - 1, position.Z + item.Depth-1)) 291 && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width-1, position.Y - 1, position.Z + item.Depth-1))) 286 292 return true; 287 293 … … 307 313 } 308 314 309 310 315 [Storable] 311 316 private bool depthWasDoubled = false; … … 336 341 337 342 if (ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X, ep.Y - 1, ep.Z))].SupportsStacking(item) 338 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width , ep.Y - 1, ep.Z))].SupportsStacking(item)339 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X, ep.Y - 1, ep.Z + item.Depth ))].SupportsStacking(item)340 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width , ep.Y - 1, ep.Z + item.Depth))].SupportsStacking(item))343 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width-1, ep.Y - 1, ep.Z))].SupportsStacking(item) 344 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X, ep.Y - 1, ep.Z + item.Depth-1))].SupportsStacking(item) 345 && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width-1, ep.Y - 1, ep.Z + item.Depth-1))].SupportsStacking(item)) 341 346 return true; 342 347 343 348 return false; 349 } 350 351 352 protected override void InitializeOccupationLayers() { 353 for (int i = 0; i*10 <= BinMeasures.Depth; i += 1) { 354 OccupationLayers[i] = new List<int>(); 355 } 356 } 357 protected override void AddNewItemToOccupationLayers(int itemID, CuboidPackingItem measures, ThreeDimensionalPacking position) { 358 int z1 = position.Z / 10; 359 int z2 = (position.Z + (position.Rotated ? measures.Width : measures.Depth)) / 10; 360 361 for (int i = z1; i <= z2; i++) 362 OccupationLayers[i].Add(itemID); 363 } 364 protected override List<int> GetLayerItemIDs(ThreeDimensionalPacking position) { 365 return OccupationLayers[position.Z / 10]; 366 } 367 protected override List<int> GetLayerItemIDs(CuboidPackingItem measures, ThreeDimensionalPacking position) { 368 List<int> result = new List<int>(); 369 int z1 = position.Z / 10; 370 int z2 = (position.Z + (position.Rotated ? measures.Width : measures.Depth)) / 10; 371 372 for (int i = z1; i <= z2; i++) 373 result.AddRange(OccupationLayers[i]); 374 375 return result; 376 } 377 } 378 public class EPComparer3D : IComparer<ThreeDimensionalPacking> { 379 public int Compare(ThreeDimensionalPacking a, ThreeDimensionalPacking b) { 380 int result = a.Z.CompareTo (b.Z); 381 if (result == 0) 382 result = a.X.CompareTo (b.X); 383 if (result == 0) 384 result = a.Y.CompareTo(b.Y); 385 386 return result; 344 387 } 345 388 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs
r9596 r9599 38 38 using HeuristicLab.Encodings.PackingEncoding.GroupingVector; 39 39 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 40 using HeuristicLab.Encodings.IntegerVectorEncoding; 40 41 41 42 namespace HeuristicLab.Encodings.PackingEncoding.PackingPlan { … … 128 129 bp.PackItem(id, itemMeasures[id], position); 129 130 remainingIDs.Remove(id); 131 break; 130 132 } 131 133 } … … 142 144 } 143 145 UpdateBinPackings(); 146 147 var newSolution = new ObservableDictionary<int,ItemList<PackingInformation>> (); 148 foreach (var bp in BinPackings) { 149 int binIndex = newSolution.Count; 150 newSolution[binIndex] = new ItemList<PackingInformation>(); 151 foreach (var entry in bp.ItemPositions) 152 newSolution[binIndex].Add(new PackingInformation (entry.Key, entry.Value.Rotated)); 153 } 154 solution.PackingInformations = newSolution; 144 155 } 145 156 public void Pack(GroupingVectorEncoding solution, ItemList<I> itemMeasures) { … … 167 178 bp.PackItem(id, itemMeasures[id], position); 168 179 remainingIDs.Remove(id); 180 break; 169 181 } 170 182 } … … 181 193 } 182 194 UpdateBinPackings(); 195 196 var newSolution = new int[solution.GroupingVector.Length]; 197 int binIndex = 0; 198 foreach (var bp in BinPackings) { 199 foreach (var entry in bp.ItemPositions) 200 newSolution[entry.Key] = binIndex; 201 binIndex++; 202 } 203 solution.GroupingVector = new IntegerVector (newSolution); 183 204 } 184 205 public void Pack(PackingSequenceEncoding solution, ItemList<I> itemMeasures) { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingDimensions.cs
r9348 r9599 29 29 public interface IPackingDimensions : IItem { 30 30 Int32 AssignedBin { get; } 31 bool Rotated { get; } 31 32 } 32 33 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Plugin.cs
r9598 r9599 26 26 /// Plugin class for HeuristicLab.Problems.BinPacking plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.959 6")]28 [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.9598")] 29 29 [PluginFile("HeuristicLab.Problems.BinPacking-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Common", "3.3")] -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs
r9596 r9599 57 57 58 58 public override bool EnclosesPoint(ThreeDimensionalPacking myPosition, ThreeDimensionalPacking checkedPoint) { 59 var c = new CuboidDiagonal(myPosition, this); 60 return (c.x1 <= checkedPoint.X && 61 c.x2 >= checkedPoint.X && 62 c.y1 <= checkedPoint.Y && 63 c.y2 >= checkedPoint.Y && 64 c.z1 <= checkedPoint.Z && 65 c.z2 >= checkedPoint.Z); 59 return (myPosition.X <= checkedPoint.X && 60 (myPosition.X + (myPosition.Rotated ? Depth : Width) - 1) >= checkedPoint.X && 61 myPosition.Y <= checkedPoint.Y && 62 (myPosition.Y + Height - 1) >= checkedPoint.Y && 63 myPosition.Z <= checkedPoint.Z && 64 (myPosition.Z + (myPosition.Rotated ? Width : Depth) - 1) >= checkedPoint.Z); 66 65 } 67 66 public override bool Encloses(ThreeDimensionalPacking checkedPosition, PackingShape<ThreeDimensionalPacking> checkedShape) { … … 87 86 } 88 87 private bool Overlaps(CuboidDiagonal c1, CuboidDiagonal c2) { 89 return !(c1.x1 > =c2.x2 ||90 c1.y1 > =c2.y2 ||91 c1.z1 > =c2.z2 ||92 c1.x2 < =c2.x1 ||93 c1.y2 < =c2.y1 ||94 c1.z2 < =c2.z1);88 return !(c1.x1 > c2.x2 || 89 c1.y1 > c2.y2 || 90 c1.z1 > c2.z2 || 91 c1.x2 < c2.x1 || 92 c1.y2 < c2.y1 || 93 c1.z2 < c2.z1); 95 94 } 96 95 … … 175 174 y1 = myPosition.Y; 176 175 z1 = myPosition.Z; 177 x2 = myPosition.X + (myPosition.Rotated ? myShape.Depth : myShape.Width) ;178 y2 = myPosition.Y + myShape.Height ;179 z2 = myPosition.Z + (myPosition.Rotated ? myShape.Width : myShape.Depth) ;176 x2 = myPosition.X + (myPosition.Rotated ? myShape.Depth : myShape.Width) - 1; 177 y2 = myPosition.Y + myShape.Height - 1; 178 z2 = myPosition.Z + (myPosition.Rotated ? myShape.Width : myShape.Depth) - 1; 180 179 } 181 180 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/RectangularPackingShape.cs
r9596 r9599 52 52 53 53 public override bool EnclosesPoint(TwoDimensionalPacking myPosition, TwoDimensionalPacking checkedPoint) { 54 var r = new RectangleDiagonal(myPosition, this); 55 return (r.x1 <= checkedPoint.X && 56 r.x2 >= checkedPoint.X && 57 r.y1 <= checkedPoint.Y && 58 r.y2 >= checkedPoint.Y); 54 return (myPosition.X <= checkedPoint.X && 55 (myPosition.X + (myPosition.Rotated ? Height : Width) - 1) >= checkedPoint.X && 56 myPosition.Y <= checkedPoint.Y && 57 (myPosition.Y + (myPosition.Rotated ? Width : Height) - 1) >= checkedPoint.Y); 59 58 } 60 59 public override bool Encloses(TwoDimensionalPacking checkedPosition, PackingShape<TwoDimensionalPacking> checkedShape) { … … 78 77 } 79 78 private bool Overlaps(RectangleDiagonal r1, RectangleDiagonal r2) { 80 return !(r1.x1 > =r2.x2 ||81 r1.y1 > =r2.y2 ||82 r1.x2 < =r2.x1 ||83 r1.y2 < =r2.y1);79 return !(r1.x1 > r2.x2 || 80 r1.y1 > r2.y2 || 81 r1.x2 < r2.x1 || 82 r1.y2 < r2.y1); 84 83 } 85 84 … … 150 149 x1 = myPosition.X; 151 150 y1 = myPosition.Y; 152 x2 = myPosition.X + (myPosition.Rotated ? myShape.Height : myShape.Width) ;153 y2 = myPosition.Y + (myPosition.Rotated ? myShape.Width : myShape.Height) ;151 x2 = myPosition.X + (myPosition.Rotated ? myShape.Height : myShape.Width) - 1; 152 y2 = myPosition.Y + (myPosition.Rotated ? myShape.Width : myShape.Height) - 1; 154 153 } 155 154 }
Note: See TracChangeset
for help on using the changeset viewer.