- Timestamp:
- 06/06/13 03:12:42 (12 years ago)
- Location:
- branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3
- Files:
-
- 8 added
- 2 deleted
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Analyzers/BestBinPackingSolutionAnalyzer.cs
r9563 r9593 93 93 !max && bestSolution.Quality.Value > qualities[i].Value) { 94 94 bestSolution.Quality.Value = qualities[i].Value; 95 bestSolution.PackingItemPositions = new ObservableDictionary<int, D> (solutions[i].PackingItemPositions); 96 bestSolution.PackingBinMeasures = new ObservableDictionary<int, B>(solutions[i].PackingBinMeasures); 95 //bestSolution.PackingItemPositions = new ObservableDictionary<int, D> (solutions[i].PackingItemPositions); 96 //bestSolution.PackingBinMeasures = new ObservableDictionary<int, B>(solutions[i].PackingBinMeasures); 97 bestSolution.BinPackings = new ObservableList<BinPacking<D, B, I>>(solutions[i].BinPackings); 97 98 } 98 99 } 99 100 string binUtilKey = "Overall Bin Utilization"; 100 101 DoubleValue binUtil = BinUtilizationRegularIdenticalBinEvaluator<D, B, I>.CalculateBinUtilization(bestSolution); 101 if (!results.ContainsKey( "Overall Bin Utilization"))102 if (!results.ContainsKey(binUtilKey)) 102 103 results.Add(new Result(binUtilKey, binUtil)); 103 104 else 104 105 results[binUtilKey].Value = binUtil; 106 107 108 string nocKey = "Nr Of Containers"; 109 if (!results.ContainsKey(nocKey)) 110 results.Add(new Result(nocKey, new IntValue (bestSolution.NrOfBins))); 111 else 112 results[nocKey].Value = new IntValue (bestSolution.NrOfBins); 105 113 106 114 return base.Apply(); -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftFunctions.cs
r9563 r9593 7 7 using HeuristicLab.Encodings.PackingEncoding.GroupingVector; 8 8 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 9 using HeuristicLab.Encodings.PackingEncoding.PackingPlan; 9 10 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 10 11 using HeuristicLab.Encodings.PermutationEncoding; … … 18 19 public static class BottomLeftFunctions { 19 20 20 21 public static Observable Dictionary<int, TwoDimensionalPacking> BottomLeftPacking(21 /* 22 public static ObservableList<BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>> BottomLeftPacking( 22 23 MultiComponentVectorEncoding solution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 23 24 int nrOfBins = solution.NrOfBins; … … 30 31 } 31 32 32 ObservableDictionary<int, TwoDimensionalPacking> packingPositions = new ObservableDictionary<int, TwoDimensionalPacking>();33 ObservableDictionary<int, TwoDimensionalPacking> itemPositions = new ObservableDictionary<int, TwoDimensionalPacking>(); 33 34 var remainingItems = new List<PackingInformation>(); 34 35 … … 42 43 TwoDimensionalPacking position = null; 43 44 44 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, packingPositions, itemMeasures, unpackedItems[i].Rotated);45 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, itemPositions, itemMeasures, unpackedItems[i].Rotated); 45 46 46 47 if (position == null) { 47 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, packingPositions, itemMeasures, !unpackedItems[i].Rotated); 48 } 49 if (position == null) { 50 remainingItems.Add(unpackedItems[i]); 48 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, itemPositions, itemMeasures, !unpackedItems[i].Rotated); 49 } 50 if (position == null) { 51 remainingItems.Add(unpackedItems[i]); 52 solution.PackingInformations[binNr].Remove(unpackedItems[i]); 51 53 } else { 52 packingPositions[itemIndex] = position; 53 solution.PackingInformations[binNr].Remove(unpackedItems[i]); 54 itemPositions[itemIndex] = position; 54 55 solution.PackingInformations[binNr].Find(pi => pi.ItemID == itemIndex).Rotated = position.Rotated; 55 56 } … … 67 68 68 69 //Look for space in current bin 69 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, packingPositions, itemMeasures, unpackedItems[i].Rotated);70 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, itemPositions, itemMeasures, unpackedItems[i].Rotated); 70 71 71 72 if (position == null) { 72 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, packingPositions, itemMeasures, !unpackedItems[i].Rotated);73 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, itemPositions, itemMeasures, !unpackedItems[i].Rotated); 73 74 } 74 75 if (position != null) { 75 packingPositions[itemIndex] = position;76 itemPositions[itemIndex] = position; 76 77 remainingItems.Remove(unpackedItems[i]); 77 78 solution.PackingInformations[binNr].Add(unpackedItems[i]); … … 85 86 } 86 87 87 return packingPositions;88 } 89 90 public static Observable Dictionary<int, TwoDimensionalPacking> BottomLeftPacking(88 return BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 89 } 90 91 public static ObservableList<BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>> BottomLeftPacking( 91 92 GroupingVectorEncoding solution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 92 93 … … 104 105 } 105 106 106 ObservableDictionary<int, TwoDimensionalPacking> packingPositions = new ObservableDictionary<int, TwoDimensionalPacking>();107 ObservableDictionary<int, TwoDimensionalPacking> itemPositions = new ObservableDictionary<int, TwoDimensionalPacking>(); 107 108 var remainingItems = new List<int>(); 108 109 … … 117 118 118 119 //Look for space in current bin 119 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, packingPositions, itemMeasures);120 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, itemPositions, itemMeasures); 120 121 121 122 //Did not find enough space in current bin … … 123 124 remainingItems.Add(itemIndex); 124 125 } else 125 packingPositions[itemIndex] = position;126 itemPositions[itemIndex] = position; 126 127 } 127 128 } … … 137 138 138 139 //Look for space in current bin 139 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, packingPositions, itemMeasures);140 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, itemPositions, itemMeasures); 140 141 141 142 if (position != null) { 142 packingPositions[itemIndex] = position;143 itemPositions[itemIndex] = position; 143 144 remainingItems.Remove(itemIndex); 144 145 solution.GroupingVector[itemIndex] = binNr; … … 150 151 } 151 152 152 return packingPositions;153 } 154 155 public static Observable Dictionary<int, TwoDimensionalPacking> BottomLeftPacking(153 return BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 154 } 155 156 public static ObservableList<BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>> BottomLeftPacking( 156 157 PackingSequenceEncoding solution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 157 158 158 ObservableDictionary<int, TwoDimensionalPacking> packingPositions = new ObservableDictionary<int, TwoDimensionalPacking>();159 ObservableDictionary<int, TwoDimensionalPacking> itemPositions = new ObservableDictionary<int, TwoDimensionalPacking>(); 159 160 int nrOfBins = 1; 160 161 for (int i = 0; i < solution.PackingSequence.Length; i++) { … … 163 164 //Look for space in existing bins 164 165 for (int binNr = 0; binNr < nrOfBins; binNr++) { 165 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, packingPositions, itemMeasures);166 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, binNr, item, itemPositions, itemMeasures); 166 167 if (position != null) 167 168 break; … … 170 171 if (position == null) { 171 172 nrOfBins++; 172 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, nrOfBins - 1, item, packingPositions, itemMeasures);173 position = BottomLeftFunctions.BottomLeftPosition(binMeasures, nrOfBins - 1, item, itemPositions, itemMeasures); 173 174 } 174 175 … … 176 177 position = new TwoDimensionalPacking(-1, 0, 0); 177 178 178 packingPositions[solution.PackingSequence[i]] = position; 179 } 180 181 return packingPositions; 182 } 183 184 private static TwoDimensionalPacking BottomLeftPosition(RectangularPackingBin binMeasures, int binNr, RectangularPackingItem currentItem, ObservableDictionary<int, TwoDimensionalPacking> itemPositions, ItemList<RectangularPackingItem> itemMeasures) { 179 itemPositions[solution.PackingSequence[i]] = position; 180 } 181 182 return BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 183 } 184 185 */ 186 public static TwoDimensionalPacking BottomLeftPosition(RectangularPackingBin binMeasures, int binNr, RectangularPackingItem currentItem, ObservableDictionary<int, TwoDimensionalPacking> itemPositions, ItemList<RectangularPackingItem> itemMeasures) { 185 187 return BottomLeftPosition(binMeasures, binNr, currentItem, itemPositions, itemMeasures, false); 186 188 } 187 p rivatestatic TwoDimensionalPacking BottomLeftPosition(RectangularPackingBin binMeasures, int binNr, RectangularPackingItem currentItem, ObservableDictionary<int, TwoDimensionalPacking> itemPositions, ItemList<RectangularPackingItem> itemMeasures, bool rotated) {189 public static TwoDimensionalPacking BottomLeftPosition(RectangularPackingBin binMeasures, int binNr, RectangularPackingItem currentItem, ObservableDictionary<int, TwoDimensionalPacking> itemPositions, ItemList<RectangularPackingItem> itemMeasures, bool rotated) { 188 190 TwoDimensionalPacking currentPosition = new TwoDimensionalPacking(binNr, 189 191 binMeasures.Width - (rotated ? currentItem.Height : currentItem.Width), -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftGroupingVectorDecoder.cs
r9563 r9593 66 66 67 67 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures , itemMeasures);68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 69 69 70 result. PackingItemPositions =BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures);70 result.BinPackings = TwoDimensionalPackingFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); //BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); 71 71 return result; 72 72 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftMultiComponentVectorDecoder.cs
r9563 r9593 66 66 67 67 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures , itemMeasures);69 70 result. PackingItemPositions =BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures);68 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 69 70 result.BinPackings = TwoDimensionalPackingFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); //BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); 71 71 72 72 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/BL/BottomLeftPackingSequenceDecoder.cs
r9563 r9593 65 65 66 66 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 67 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures , itemMeasures);67 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 68 68 69 result. PackingItemPositions = BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures);69 result.BinPackings = TwoDimensionalPackingFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); //BottomLeftFunctions.BottomLeftPacking(solution, binMeasures, itemMeasures); 70 70 71 71 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointGroupingVectorDecoder2D.cs
r9563 r9593 60 60 public static PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> Decode(GroupingVectorEncoding solution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 61 61 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 62 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures , itemMeasures);62 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 63 63 64 result. PackingItemPositions =ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);64 result.BinPackings = TwoDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);//ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures); 65 65 66 66 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointMultiComponentVectorDecoder2D.cs
r9563 r9593 61 61 public static PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> Decode(MultiComponentVectorEncoding solution, RectangularPackingBin binMeasures, ItemList<RectangularPackingItem> itemMeasures) { 62 62 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 63 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures , itemMeasures);63 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 64 64 65 result. PackingItemPositions =ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);65 result.BinPackings = TwoDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);//ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures); 66 66 67 67 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointPackingSequenceDecoder2D.cs
r9563 r9593 64 64 65 65 PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> result = 66 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures , itemMeasures);66 new PackingPlan<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>(binMeasures); 67 67 68 result. PackingItemPositions =ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);68 result.BinPackings = TwoDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);//ExtremPointsFunctions2D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures); 69 69 70 70 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/2D/EP/ExtremePointsFunctions2D.cs
r9563 r9593 7 7 using HeuristicLab.Encodings.PackingEncoding.GroupingVector; 8 8 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 9 using HeuristicLab.Encodings.PackingEncoding.PackingPlan; 9 10 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 10 11 using HeuristicLab.Encodings.PermutationEncoding; … … 21 22 22 23 23 public static Observable Dictionary<int, TwoDimensionalPacking> ExtremePointBasedPacking(MultiComponentVectorEncoding solution,24 public static ObservableList<BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>> ExtremePointBasedPacking(MultiComponentVectorEncoding solution, 24 25 ItemList<RectangularPackingItem> itemMeasures, RectangularPackingBin binMeasures) { 25 26 … … 98 99 } 99 100 100 return itemPositions;101 } 102 103 104 public static Observable Dictionary<int, TwoDimensionalPacking> ExtremePointBasedPacking(GroupingVectorEncoding solution,101 return BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 102 } 103 104 105 public static ObservableList<BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>> ExtremePointBasedPacking(GroupingVectorEncoding solution, 105 106 ItemList<RectangularPackingItem> itemMeasures, RectangularPackingBin binMeasures) { 106 107 … … 180 181 } 181 182 182 return itemPositions;183 } 184 185 186 public static Observable Dictionary<int, TwoDimensionalPacking> ExtremePointBasedPacking(PackingSequenceEncoding solution,183 return BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 184 } 185 186 187 public static ObservableList<BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>> ExtremePointBasedPacking(PackingSequenceEncoding solution, 187 188 ItemList<RectangularPackingItem> itemMeasures, RectangularPackingBin binMeasures) { 188 189 … … 215 216 } 216 217 217 return itemPositions;218 } 219 220 221 p rivatestatic TwoDimensionalPacking FindExtremePointForItem(int itemIndex, ItemList<RectangularPackingItem> itemMeasures, RectangularPackingBin binMeasures,218 return BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 219 } 220 221 222 public static TwoDimensionalPacking FindExtremePointForItem(int itemIndex, ItemList<RectangularPackingItem> itemMeasures, RectangularPackingBin binMeasures, 222 223 HashSet<TwoDimensionalPacking> extremePoints, List<int[,]> occupiedPoints, ObservableDictionary<int, TwoDimensionalPacking> itemPositions) { 223 224 return FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePoints, occupiedPoints, itemPositions, false); 224 225 } 225 p rivatestatic TwoDimensionalPacking FindExtremePointForItem(int itemIndex, ItemList<RectangularPackingItem> itemMeasures, RectangularPackingBin binMeasures,226 public static TwoDimensionalPacking FindExtremePointForItem(int itemIndex, ItemList<RectangularPackingItem> itemMeasures, RectangularPackingBin binMeasures, 226 227 HashSet<TwoDimensionalPacking> extremePoints, List<int[,]> occupiedPoints, ObservableDictionary<int, TwoDimensionalPacking> itemPositions, bool rotated) { 227 228 … … 233 234 234 235 int epIndex = 0; 235 while (epIndex < extremePoints.Count && 236 while (epIndex < extremePoints.Count && 237 //(!IsPositionFeasible(binMeasures, item, extremePoints.ElementAt(epIndex), occupiedPoints))) 236 238 (!BottomLeftFunctions.IsPositionFeasible(binMeasures, extremePoints.ElementAt(epIndex).AssignedBin, item, extremePoints.ElementAt(epIndex), itemPositions, itemMeasures))) 237 239 { epIndex++; } … … 244 246 return null; 245 247 } 246 p rivatestatic List<int[,]> IncreaseBinCountForOccupiedPoints(List<int[,]> occupiedPoints, RectangularPackingBin binMeasures) {248 public static List<int[,]> IncreaseBinCountForOccupiedPoints(List<int[,]> occupiedPoints, RectangularPackingBin binMeasures) { 247 249 occupiedPoints.Add(new int[binMeasures.Width, binMeasures.Height]); 248 250 int lastIndex = occupiedPoints.Count - 1; … … 254 256 return occupiedPoints; 255 257 } 256 p rivatestatic List<int[,]> OccupyPointsForNewItem(List<int[,]> occupiedPoints, RectangularPackingItem newItem, TwoDimensionalPacking position, int itemIndex) {258 public static List<int[,]> OccupyPointsForNewItem(List<int[,]> occupiedPoints, RectangularPackingItem newItem, TwoDimensionalPacking position, int itemIndex) { 257 259 int width = position.Rotated ? newItem.Height : newItem.Width; 258 260 int height = position.Rotated ? newItem.Width : newItem.Height; … … 264 266 return occupiedPoints; 265 267 } 266 p rivatestatic HashSet<TwoDimensionalPacking> GenerateNewExtremePointsForNewItem(HashSet<TwoDimensionalPacking> extremePoints, List<int[,]> occupiedPoints,268 public static HashSet<TwoDimensionalPacking> GenerateNewExtremePointsForNewItem(HashSet<TwoDimensionalPacking> extremePoints, List<int[,]> occupiedPoints, 267 269 RectangularPackingItem newItem, TwoDimensionalPacking position, RectangularPackingBin binMeasures) { 268 270 int currentBin = position.AssignedBin; … … 321 323 return shortestSide; 322 324 } 325 326 323 327 } 324 328 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftFunctions.cs
r9563 r9593 7 7 using HeuristicLab.Encodings.PackingEncoding.GroupingVector; 8 8 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 9 using HeuristicLab.Encodings.PackingEncoding.PackingPlan; 9 10 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 10 11 using HeuristicLab.Encodings.PermutationEncoding; … … 18 19 public static class DeepestBottomLeftFunctions { 19 20 20 public static Observable Dictionary<int, ThreeDimensionalPacking> DeepestLeftBottomPacking(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {21 public static ObservableList<BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>> DeepestLeftBottomPacking(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 21 22 int nrOfBins = solution.NrOfBins; 22 23 … … 28 29 } 29 30 30 ObservableDictionary<int, ThreeDimensionalPacking> packingPositions = new ObservableDictionary<int, ThreeDimensionalPacking>();31 ObservableDictionary<int, ThreeDimensionalPacking> itemPositions = new ObservableDictionary<int, ThreeDimensionalPacking>(); 31 32 var remainingItems = new List<PackingInformation>(); 32 33 … … 40 41 ThreeDimensionalPacking position = null; 41 42 42 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, packingPositions, itemMeasures, unpackedItems[i].Rotated);43 44 if (position == null) { 45 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, packingPositions, itemMeasures, !unpackedItems[i].Rotated);43 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, itemPositions, itemMeasures, unpackedItems[i].Rotated); 44 45 if (position == null) { 46 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, itemPositions, itemMeasures, !unpackedItems[i].Rotated); 46 47 } 47 48 if (position == null) { … … 49 50 solution.PackingInformations[binNr].Remove(unpackedItems[i]); 50 51 } else { 51 packingPositions[itemIndex] = position;52 itemPositions[itemIndex] = position; 52 53 solution.PackingInformations[binNr].Find(pi => pi.ItemID == itemIndex).Rotated = position.Rotated; 53 54 } … … 65 66 66 67 //Look for space in current bin 67 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, packingPositions, itemMeasures, unpackedItems[i].Rotated);68 69 if (position == null) { 70 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, packingPositions, itemMeasures, !unpackedItems[i].Rotated);68 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, itemPositions, itemMeasures, unpackedItems[i].Rotated); 69 70 if (position == null) { 71 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, itemPositions, itemMeasures, !unpackedItems[i].Rotated); 71 72 } 72 73 if (position != null) { 73 packingPositions[itemIndex] = position;74 itemPositions[itemIndex] = position; 74 75 remainingItems.Remove(unpackedItems[i]); 75 76 solution.PackingInformations[binNr].Add(unpackedItems[i]); … … 83 84 } 84 85 85 return packingPositions;86 } 87 88 public static Observable Dictionary<int, ThreeDimensionalPacking> DeepestLeftBottomPacking(GroupingVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {86 return BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 87 } 88 89 public static ObservableList<BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>> DeepestLeftBottomPacking(GroupingVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 89 90 int nrOfBins = solution.GroupingVector.Max() + 1; 90 91 … … 100 101 } 101 102 102 ObservableDictionary<int, ThreeDimensionalPacking> packingPositions = new ObservableDictionary<int, ThreeDimensionalPacking>();103 ObservableDictionary<int, ThreeDimensionalPacking> itemPositions = new ObservableDictionary<int, ThreeDimensionalPacking>(); 103 104 var remainingItems = new List<int>(); 104 105 … … 112 113 ThreeDimensionalPacking position = null; 113 114 114 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, packingPositions, itemMeasures);115 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, itemPositions, itemMeasures); 115 116 116 117 if (position == null) { 117 118 remainingItems.Add(itemIndex); 118 119 } else 119 packingPositions[itemIndex] = position;120 itemPositions[itemIndex] = position; 120 121 } 121 122 } … … 131 132 132 133 //Look for space in current bin 133 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, packingPositions, itemMeasures);134 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, itemPositions, itemMeasures); 134 135 135 136 if (position != null) { 136 packingPositions[itemIndex] = position;137 itemPositions[itemIndex] = position; 137 138 remainingItems.Remove(itemIndex); 138 139 //solution.GroupingVector[itemIndex] = binNr; … … 144 145 } 145 146 146 return packingPositions;147 } 148 149 public static Observable Dictionary<int, ThreeDimensionalPacking> DeepestLeftBottomPacking(PackingSequenceEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) {150 ObservableDictionary<int, ThreeDimensionalPacking> packingPositions = new ObservableDictionary<int, ThreeDimensionalPacking>();147 return BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 148 } 149 150 public static ObservableList<BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>> DeepestLeftBottomPacking(PackingSequenceEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures) { 151 ObservableDictionary<int, ThreeDimensionalPacking> itemPositions = new ObservableDictionary<int, ThreeDimensionalPacking>(); 151 152 int nrOfBins = 1; 152 153 for (int i = 0; i < solution.PackingSequence.Length; i++) { … … 155 156 //Look for space in existing bins 156 157 for (int binNr = 0; binNr < nrOfBins; binNr++) { 157 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, packingPositions, itemMeasures);158 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, binNr, item, itemPositions, itemMeasures); 158 159 if (position != null) 159 160 break; … … 162 163 if (position == null) { 163 164 nrOfBins++; 164 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, nrOfBins - 1, item, packingPositions, itemMeasures);165 position = DeepestBottomLeftFunctions.DeepestLeftBottomPosition(binMeasures, nrOfBins - 1, item, itemPositions, itemMeasures); 165 166 } 166 167 … … 168 169 position = new ThreeDimensionalPacking(-1, 0, 0, 0); 169 170 170 packingPositions[solution.PackingSequence[i]] = position;171 } 172 173 return packingPositions;171 itemPositions[solution.PackingSequence[i]] = position; 172 } 173 174 return BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 174 175 } 175 176 … … 204 205 } 205 206 207 208 206 209 public static bool IsPositionFeasible(CuboidPackingBin binMeasures, int binNr, CuboidPackingItem currentItem, 207 210 ThreeDimensionalPacking currentPosition, ObservableDictionary<int, ThreeDimensionalPacking> itemPositions, ItemList<CuboidPackingItem> itemMeasures) { … … 233 236 } 234 237 235 236 237 238 } 238 239 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftGroupingVectorDecoder.cs
r9563 r9593 64 64 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); 65 65 66 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>( 67 binMeasures, itemMeasures); 66 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 68 67 69 ObservableDictionary<int, ThreeDimensionalPacking> packingPositions = DeepestBottomLeftFunctions.DeepestLeftBottomPacking( 70 solution, 71 binMeasures, 72 itemMeasures); 73 74 75 result.PackingItemPositions = packingPositions; 68 result.BinPackings = ThreeDimensionalPackingFunctions.DeepestLeftBottomPacking(solution, binMeasures, itemMeasures); 76 69 77 70 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftMultiComponentVectorDecoder.cs
r9563 r9593 66 66 67 67 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 68 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures , itemMeasures);69 70 result. PackingItemPositions = DeepestBottomLeftFunctions.DeepestLeftBottomPacking(solution, binMeasures, itemMeasures);68 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 69 70 result.BinPackings = ThreeDimensionalPackingFunctions.DeepestLeftBottomPacking(solution, binMeasures, itemMeasures); 71 71 72 72 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/DBL/DeepestBottomLeftPackingSequenceDecoder.cs
r9563 r9593 65 65 66 66 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 67 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures , itemMeasures);67 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 68 68 69 result. PackingItemPositions = DeepestBottomLeftFunctions.DeepestLeftBottomPacking(solution, binMeasures, itemMeasures);69 result.BinPackings = ThreeDimensionalPackingFunctions.DeepestLeftBottomPacking(solution, binMeasures, itemMeasures); 70 70 71 71 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointGroupingVectorDecoder3D.cs
r9563 r9593 37 37 using HeuristicLab.Problems.BinPacking.Interfaces; 38 38 using HeuristicLab.Encodings.PackingEncoding.GroupingVector; 39 using HeuristicLab.Parameters; 39 40 40 41 namespace HeuristicLab.Problems.BinPacking.Decoders { … … 46 47 CuboidPackingItem>, I3DGVDecoder { 47 48 49 public ValueParameter<BoolValue> StackingConstraintsParameter { 50 get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; } 51 } 52 48 53 public ExtremePointGroupingVectorDecoder3D () 49 54 : base() { 55 Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not.")); 50 56 } 51 57 [StorableConstructor] … … 58 64 } 59 65 60 public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(GroupingVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures ) {66 public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(GroupingVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures, bool stackingConstraints) { 61 67 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 62 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures , itemMeasures);68 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 63 69 64 result. PackingItemPositions = ExtremePointsFunctions3D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);70 result.BinPackings = ThreeDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures, stackingConstraints); 65 71 66 72 return result; … … 72 78 if (solution == null) throw new InvalidOperationException("Encoding is not of type GroupingVector"); 73 79 74 return Decode(solution, binMeasures, itemMeasures );80 return Decode(solution, binMeasures, itemMeasures, StackingConstraintsParameter.Value.Value); 75 81 } 76 82 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointMultiComponentVectorDecoder3D.cs
r9563 r9593 38 38 using HeuristicLab.Encodings.PackingEncoding.GroupingVector; 39 39 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 40 using HeuristicLab.Parameters; 40 41 41 42 namespace HeuristicLab.Problems.BinPacking.Decoders { … … 47 48 CuboidPackingItem>, I3DMCVDecoder { 48 49 50 public ValueParameter<BoolValue> StackingConstraintsParameter { 51 get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; } 52 } 53 49 54 public ExtremePointMultiComponentVectorDecoder3D () 50 55 : base() { 56 Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not.")); 51 57 } 52 58 [StorableConstructor] … … 59 65 } 60 66 61 public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures ) {67 public static PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> Decode(MultiComponentVectorEncoding solution, CuboidPackingBin binMeasures, ItemList<CuboidPackingItem> itemMeasures, bool stackingConstraints) { 62 68 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 63 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures , itemMeasures);69 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 64 70 65 result. PackingItemPositions = ExtremePointsFunctions3D.ExtremePointBasedPacking(ref solution, itemMeasures, binMeasures);71 result.BinPackings = ThreeDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures, stackingConstraints); 66 72 67 73 return result; … … 73 79 if (solution == null) throw new InvalidOperationException("Encoding is not of type MultiComponentVector"); 74 80 75 return Decode(solution, binMeasures, itemMeasures );81 return Decode(solution, binMeasures, itemMeasures, StackingConstraintsParameter.Value.Value); 76 82 } 77 83 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointPackingSequenceDecoder3D.cs
r9563 r9593 36 36 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 37 37 using HeuristicLab.Problems.BinPacking.Interfaces; 38 using HeuristicLab.Parameters; 38 39 39 40 namespace HeuristicLab.Problems.BinPacking.Decoders { … … 45 46 CuboidPackingItem>, I3DPSDecoder { 46 47 48 public ValueParameter<BoolValue> StackingConstraintsParameter { 49 get { return (ValueParameter<BoolValue>)Parameters["StackingConstraint"]; } 50 } 51 47 52 public ExtremePointPackingSequenceDecoder3D () 48 53 : base() { 54 Parameters.Add(new ValueParameter<BoolValue>("StackingConstraint", "A flag determining whether stackingconstraints should be enforced or not.")); 49 55 } 50 56 [StorableConstructor] … … 64 70 65 71 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 66 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures , itemMeasures);72 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(binMeasures); 67 73 68 result. PackingItemPositions = ExtremePointsFunctions3D.ExtremePointBasedPacking(solution, itemMeasures, binMeasures);74 result.BinPackings = ThreeDimensionalPackingFunctions.ExtremePointBasedPacking(solution, itemMeasures, binMeasures, StackingConstraintsParameter.Value.Value); 69 75 70 76 return result; -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ExtremePointsFunctions3D.cs
r9563 r9593 8 8 using HeuristicLab.Encodings.PackingEncoding.GroupingVector; 9 9 using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector; 10 using HeuristicLab.Encodings.PackingEncoding.PackingPlan; 10 11 using HeuristicLab.Encodings.PackingEncoding.PackingSequence; 11 12 using HeuristicLab.Encodings.PermutationEncoding; … … 20 21 21 22 22 public static Observable Dictionary<int, ThreeDimensionalPacking> ExtremePointBasedPacking(ref MultiComponentVectorEncoding solution,23 ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures ) {23 public static ObservableList<BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>> ExtremePointBasedPacking(ref MultiComponentVectorEncoding solution, 24 ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures, bool stackingConstraints) { 24 25 25 26 #region Preperations … … 97 98 } 98 99 99 return itemPositions;100 } 101 102 103 public static Observable Dictionary<int, ThreeDimensionalPacking> ExtremePointBasedPacking(GroupingVectorEncoding solution,104 ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures ) {100 return BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 101 } 102 103 104 public static ObservableList<BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>> ExtremePointBasedPacking(GroupingVectorEncoding solution, 105 ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures, bool stackingConstraints) { 105 106 106 107 #region Preperations … … 139 140 140 141 extremePointsForBin[binNr] = OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, binMeasures); 141 var positionFound = FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions );142 var positionFound = FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions, stackingConstraints); 142 143 if (positionFound != null) { 143 144 extremePointsForBin[binNr].Remove(positionFound); … … 162 163 163 164 extremePointsForBin[binNr] = OrderExtremePoints(extremePointsForBin[binNr], occupiedPoints, binMeasures); 164 var positionFound = FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions );165 var positionFound = FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePointsForBin[binNr], occupiedPoints, itemPositions, stackingConstraints); 165 166 if (positionFound != null) { 166 167 extremePointsForBin[binNr].Remove(positionFound); … … 179 180 } 180 181 181 return itemPositions;182 } 183 184 185 public static Observable Dictionary<int, ThreeDimensionalPacking> ExtremePointBasedPacking(PackingSequenceEncoding solution,186 ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures ) {182 return BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 183 } 184 185 186 public static ObservableList<BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>> ExtremePointBasedPacking(PackingSequenceEncoding solution, 187 ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures, bool stackingConstraints) { 187 188 188 189 #region Preperations … … 200 201 var item = itemMeasures[itemIndex]; 201 202 extremePoints = OrderExtremePoints(extremePoints, occupiedPoints, binMeasures); 202 var positionFound = FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePoints, occupiedPoints, itemPositions );203 var positionFound = FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePoints, occupiedPoints, itemPositions, stackingConstraints); 203 204 if (positionFound != null) { 204 205 extremePoints.Remove(positionFound); … … 214 215 } 215 216 216 return itemPositions; 217 } 217 return BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>.GetBinPackings(itemPositions, binMeasures, itemMeasures, nrOfBins); 218 } 219 220 218 221 219 222 220 223 public static ThreeDimensionalPacking FindExtremePointForItem(int itemIndex, ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures, 221 HashSet<ThreeDimensionalPacking> extremePoints, List<int[, ,]> occupiedPoints, ObservableDictionary<int, ThreeDimensionalPacking> itemPositions) { 222 return FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePoints, occupiedPoints, itemPositions, false); 223 } 224 HashSet<ThreeDimensionalPacking> extremePoints, List<int[, ,]> occupiedPoints, ObservableDictionary<int, ThreeDimensionalPacking> itemPositions, bool stackingConstraints) { 225 return FindExtremePointForItem(itemIndex, itemMeasures, binMeasures, extremePoints, occupiedPoints, itemPositions, stackingConstraints, false); 226 } 227 public static ThreeDimensionalPacking FindExtremePointForItem(int itemIndex, ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures, 228 HashSet<ThreeDimensionalPacking> extremePoints, List<int[, ,]> occupiedPoints, ObservableDictionary<int, ThreeDimensionalPacking> itemPositions, bool stackingConstraints, bool rotated) { 229 230 var itemFromList = itemMeasures[itemIndex]; 231 CuboidPackingItem item = new CuboidPackingItem( 232 rotated ? itemFromList.Depth : itemFromList.Width, 233 itemFromList.Height, 234 rotated ? itemFromList.Width : itemFromList.Depth, 235 itemFromList.TargetBin); 236 237 int epIndex = 0; 238 while (epIndex < extremePoints.Count && 239 //(!IsPositionFeasible(binMeasures, item, extremePoints.ElementAt(epIndex), occupiedPoints) || 240 (!DeepestBottomLeftFunctions.IsPositionFeasible(binMeasures, extremePoints.ElementAt(epIndex).AssignedBin, item, extremePoints.ElementAt(epIndex), itemPositions, itemMeasures) || 241 (stackingConstraints && !IsStaticStable(occupiedPoints[extremePoints.ElementAt(epIndex).AssignedBin], item, extremePoints.ElementAt(epIndex))))) 242 { epIndex++; } 243 244 if (epIndex < extremePoints.Count) { 245 var result = extremePoints.ElementAt(epIndex); 246 result.Rotated = rotated; 247 return result; 248 } 249 return null; 250 } 251 252 224 253 public static ThreeDimensionalPacking FindExtremePointForItemUsingMaterialAndWeightConstraint(int itemIndex, ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures, 225 254 HashSet<ThreeDimensionalPacking> extremePoints, List<int[, ,]> occupiedPoints, ObservableDictionary<int, ThreeDimensionalPacking> itemPositions, bool rotated) { … … 234 263 int epIndex = 0; 235 264 while (epIndex < extremePoints.Count && 265 //(!IsPositionFeasible(binMeasures, item, extremePoints.ElementAt(epIndex), occupiedPoints) || 236 266 (!DeepestBottomLeftFunctions.IsPositionFeasible(binMeasures, extremePoints.ElementAt(epIndex).AssignedBin, item, extremePoints.ElementAt(epIndex), itemPositions, itemMeasures) || 237 267 !IsStaticStable(occupiedPoints[extremePoints.ElementAt(epIndex).AssignedBin], item, extremePoints.ElementAt(epIndex)) || … … 243 273 return result; 244 274 } 245 return null;246 }247 public static ThreeDimensionalPacking FindExtremePointForItem(int itemIndex, ItemList<CuboidPackingItem> itemMeasures, CuboidPackingBin binMeasures,248 HashSet<ThreeDimensionalPacking> extremePoints, List<int[,,]> occupiedPoints, ObservableDictionary<int, ThreeDimensionalPacking> itemPositions, bool rotated) {249 250 var itemFromList = itemMeasures[itemIndex];251 CuboidPackingItem item = new CuboidPackingItem(252 rotated ? itemFromList.Depth : itemFromList.Width,253 itemFromList.Height,254 rotated ? itemFromList.Width : itemFromList.Depth,255 itemFromList.TargetBin);256 257 int epIndex = 0;258 while (epIndex < extremePoints.Count &&259 (!DeepestBottomLeftFunctions.IsPositionFeasible(binMeasures, extremePoints.ElementAt(epIndex).AssignedBin, item, extremePoints.ElementAt(epIndex), itemPositions, itemMeasures) ||260 !IsStaticStable(occupiedPoints[extremePoints.ElementAt(epIndex).AssignedBin], item, extremePoints.ElementAt(epIndex))))261 { epIndex++; }262 263 if (epIndex < extremePoints.Count) {264 var result = extremePoints.ElementAt(epIndex);265 result.Rotated = rotated;266 return result;267 }268 275 return null; 269 276 } … … 439 446 return shortestSide; 440 447 } 448 449 441 450 } 442 451 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Decoders/3D/EP/ISOContainerMultiComponentVectorDecoder3D.cs
r9563 r9593 62 62 63 63 PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> result = 64 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>( new ObservableDictionary<int, CuboidPackingBin>(), itemMeasures);65 64 new PackingPlan<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>(); 65 /* 66 66 #region Preperations 67 67 int nrOfBins = solution.NrOfBins; … … 153 153 } 154 154 155 result.PackingItemPositions = itemPositions; 156 result.PackingBinMeasures = resultingBinMeasures; 155 result.BinPackings = BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>.GetBinPackings(itemPositions, resultingBinMeasures, itemMeasures, nrOfBins); */ 157 156 return result; 158 157 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/GroupingVector/GroupingVectorRandomCreator.cs
r9563 r9593 64 64 public static GroupingVectorEncoding Apply(int items, int lowerBound, IRandom random) { 65 65 var solution = new GroupingVectorEncoding(); 66 66 solution.GroupingVector = new IntegerVector(items, random, 0, lowerBound + 1); 67 67 return solution; 68 68 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/Moves/Triple/Moves/MCVTripleMove.cs
r9563 r9593 102 102 return true; 103 103 } else { 104 if ((Index == actualAttribute.Index &&TargetIndex == actualAttribute.TargetIndex)104 if ((Index == actualAttribute.Index || TargetIndex == actualAttribute.TargetIndex) 105 105 && MultiComponentVector.PackingInformations[OldGroup][Index].ItemID == actualAttribute.ItemID 106 106 //&& Rotation == actualAttribute.Rotation -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/MultiComponentVectorRandomCreator.cs
r9563 r9593 70 70 var solution = new MultiComponentVectorEncoding(); 71 71 if (sortedSequence) 72 solution.PackingInformations = PackingInformation.CreateDictionaryRandomlyWithSortedSequence(items, lowerBound, random);72 solution.PackingInformations = PackingInformation.CreateDictionaryRandomlyWithSortedSequence(items, /*lowerBound*/ 1, random); 73 73 else 74 solution.PackingInformations = PackingInformation.CreateDictionaryRandomly(items, lowerBound, random);74 solution.PackingInformations = PackingInformation.CreateDictionaryRandomly(items, /*lowerBound*/ 1, random); 75 75 return solution; 76 76 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/SequenceBasedMultiComponentVectorCrossover.cs
r9563 r9593 44 44 public override MultiComponentVectorEncoding Cross(IRandom random, MultiComponentVectorEncoding parent1, MultiComponentVectorEncoding parent2) { 45 45 MultiComponentVectorEncoding child = new MultiComponentVectorEncoding (); 46 46 47 int nrOfItems = parent1.NrOfItems; 48 bool[] itemAlreadyAssigned = new bool[nrOfItems]; 49 int nrOfBins = parent1.NrOfBins > parent2.NrOfBins ? parent2.NrOfBins : parent1.NrOfBins; 50 int swappedBin = random.Next(nrOfBins); 51 52 for (int binNr = 0; binNr < nrOfBins; binNr++) { 53 54 var newBin = new ItemList<PackingInformation>(); 55 var currentParent = binNr == swappedBin ? parent1 : parent2; 56 57 int nrOfItemsInBin = currentParent.PackingInformations[binNr].Count; 58 for (int i = 0; i < nrOfItemsInBin; i++) { 59 PackingInformation pi = new PackingInformation(currentParent.PackingInformations[binNr][i]); 60 if (!itemAlreadyAssigned[pi.ItemID]) { 61 itemAlreadyAssigned[pi.ItemID] = true; 62 newBin.Add(new PackingInformation(pi)); 63 } 64 } 65 66 child.PackingInformations[binNr] = newBin; 67 } 68 69 for (int itemID = 0; itemID < nrOfItems; itemID++) { 70 if (!itemAlreadyAssigned[itemID]) 71 child.PackingInformations[0].Add(new PackingInformation(itemID, random.Next(2) == 0 ? true : false)); 72 } 47 73 48 74 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs
r9563 r9593 33 33 using HeuristicLab.Data; 34 34 using HeuristicLab.Collections; 35 using HeuristicLab.Problems.BinPacking.Dimensions; 36 using HeuristicLab.Problems.BinPacking.PackingBin; 35 37 36 38 namespace HeuristicLab.Encodings.PackingEncoding.PackingPlan { … … 45 47 public int NrOfBins { 46 48 get { 47 if ( PackingItemPositions != null)48 return PackingItemPositions.Select(p => p.Value.AssignedBin).Max() + 1;49 if (BinPackings != null) 50 return BinPackings.Count; 49 51 else return 0; 50 52 } … … 52 54 53 55 [Storable] 54 public ObservableDictionary<int, D> PackingItemPositions { get; set; } 55 [Storable] 56 public ObservableDictionary<int, B> PackingBinMeasures { get; set; } 57 58 [Storable] 59 public ItemList<I> PackingItemMeasures { 60 get; 61 set; 62 } 56 public ObservableList<BinPacking<D, B, I>> BinPackings { get; set; } 57 63 58 [Storable] 64 59 private DoubleValue quality; … … 76 71 #endregion 77 72 78 public PackingPlan(B binMeasures, ItemList<I> itemMeasures) 73 public PackingPlan(B binMeasures) 74 : this(){ 75 //this.BinPackings.Add(new BinPacking<D,B,I> ()); 76 } 77 public PackingPlan() 79 78 : base() { 80 this.PackingItemMeasures = new ItemList<I> (itemMeasures); 81 this.PackingBinMeasures = new ObservableDictionary<int, B>(); 82 this.PackingBinMeasures[0] = binMeasures; 83 } 84 public PackingPlan(ObservableDictionary<int, B> binMeasures, ItemList<I> itemMeasures) 85 : base() { 86 this.PackingItemMeasures = itemMeasures; 87 this.PackingBinMeasures = binMeasures; 79 this.BinPackings = new ObservableList<BinPacking<D, B,I>>(); 88 80 } 89 81 … … 92 84 protected PackingPlan(PackingPlan<D,B,I> original, Cloner cloner) 93 85 : base(original, cloner) { 94 PackingItemPositions = new ObservableDictionary<int, D>(original.PackingItemPositions); 95 PackingBinMeasures = new ObservableDictionary<int, B>(original.PackingBinMeasures); 96 PackingItemMeasures = original.PackingItemMeasures; 86 this.BinPackings = new ObservableList<BinPacking<D, B, I>>(original.BinPackings); 97 87 } 98 88 public override IDeepCloneable Clone(Cloner cloner) { 99 89 return new PackingPlan<D,B,I>(this, cloner); 100 90 } 101 102 public B GetPackingBinMeasuresForBinNr(int binNr) { 103 if (PackingBinMeasures.ContainsKey(binNr)) 104 return PackingBinMeasures[binNr]; 105 else 106 return PackingBinMeasures[0]; 107 } 108 91 109 92 110 93 #region Events … … 125 108 } 126 109 127 public event EventHandler PackingItemPositionChanged;128 private void On PackingItemPositionChanged() {129 var changed = PackingItemPositionChanged;110 public event EventHandler BinPackingsChanged; 111 private void OnBinPackingsChanged() { 112 var changed = BinPackingsChanged; 130 113 if (changed != null) 131 114 changed(this, EventArgs.Empty); 132 115 } 133 private void Register PackingItemPositionEvents() {134 PackingItemPositions.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(PackingItemPosition_PropertyChanged);135 } 136 private void Deregister PackingItemPositionEvents() {137 PackingItemPositions.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(PackingItemPosition_PropertyChanged);138 } 139 private void PackingItemPosition_PropertyChanged(object sender, EventArgs e) {140 On PackingItemPositionChanged();116 private void RegisterBinPackingsEvents() { 117 BinPackings.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(BinPackings_PropertyChanged); 118 } 119 private void DeregisterBinPackingsEvents() { 120 BinPackings.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(BinPackings_PropertyChanged); 121 } 122 private void BinPackings_PropertyChanged(object sender, EventArgs e) { 123 OnBinPackingsChanged(); 141 124 } 142 125 #endregion 143 126 } 127 128 [Item("BinPacking", "Represents a single-bin packing for a bin-packing problem.")] 129 [StorableClass] 130 public abstract class BinPacking<D,B,I> : Item 131 where D : class, IPackingDimensions 132 where B : PackingShape<D>, IPackingBin 133 where I : PackingShape<D>, IPackingItem { 134 135 [Storable] 136 public ObservableDictionary<int, D> ItemPositions { get; private set; } 137 138 [Storable] 139 public B BinMeasures { get; private set; } 140 141 [Storable] 142 public ObservableDictionary<int, I> ItemMeasures { get; private set; } 143 144 [Storable] 145 public HashSet<D> ExtremePoints { get; protected set; } 146 147 [Storable] 148 public OccupiedPoints<D, I> OccupiedPoints { get; protected set; } 149 150 public BinPacking(B binMeasures) : base() { 151 ItemPositions = new ObservableDictionary<int, D>(); 152 ItemMeasures = new ObservableDictionary<int, I>(); 153 BinMeasures = (B)binMeasures.Clone(); 154 ExtremePoints = new HashSet<D>(); 155 ExtremePoints.Add(binMeasures.Origin); 156 } 157 158 [StorableConstructor] 159 protected BinPacking(bool deserializing) : base(deserializing) { } 160 protected BinPacking(BinPacking<D,B,I> original, Cloner cloner) 161 : base(original, cloner) { 162 this.ItemPositions = new ObservableDictionary<int, D>(original.ItemPositions); 163 this.ItemMeasures = new ObservableDictionary<int, I>(original.ItemMeasures); 164 this.BinMeasures = (B)original.BinMeasures.Clone(cloner); 165 } 166 167 168 protected abstract void GenerateNewExtremePointsForNewItem(I measures, D position); 169 public abstract D FindExtremePointForItem(I measures, bool rotated, bool stackingConstraint); 170 public abstract D FindPositionBySliding(I measures, bool rotated); 171 public void PackItem(int itemID, I measures, D position) { 172 ItemMeasures[itemID] = measures; 173 ItemPositions[itemID] = position; 174 ExtremePoints.Remove(position); 175 GenerateNewExtremePointsForNewItem(measures, position); 176 OccupiedPoints.OccupyPoints(measures, position, itemID); 177 } 178 179 180 public double PackingDensity { 181 get { 182 double result = 0; 183 foreach (var entry in ItemMeasures) 184 result += entry.Value.MultipliedMeasures; 185 result /= BinMeasures.MultipliedMeasures; 186 return result; 187 } 188 } 189 190 public bool IsPositionFeasible1(I currentItem, D currentPosition) { 191 //In this case feasability is defined as following: 1. the item fits into the bin-borders; 2. the item does not collide with another already packed item 192 if (!BinMeasures.Encloses(currentPosition, currentItem)) 193 return false; 194 195 foreach (var ipEntry in ItemPositions) { 196 if (ItemMeasures[ipEntry.Key].Overlaps(ipEntry.Value, currentPosition, currentItem)) 197 return false; 198 } 199 200 return true; 201 } 202 public bool IsPositionFeasible(I currentItem, D position) { 203 if (!BinMeasures.Encloses(position, currentItem)) 204 return false; 205 206 return OccupiedPoints.IsPositionFeasible (currentItem, position); 207 } 208 } 209 210 211 212 213 214 [Item("BinPacking2D", "Represents a single-bin packing for a 2D bin-packing problem.")] 215 [StorableClass] 216 public class BinPacking2D : BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> { 217 218 public BinPacking2D(RectangularPackingBin binMeasures) : base(binMeasures) { 219 OccupiedPoints = new OccupiedPoints2D(binMeasures); 220 } 221 [StorableConstructor] 222 protected BinPacking2D(bool deserializing) : base(deserializing) { } 223 protected BinPacking2D(BinPacking2D original, Cloner cloner) 224 : base(original, cloner) { 225 } 226 public override IDeepCloneable Clone(Cloner cloner) { 227 return new BinPacking2D(this, cloner); 228 } 229 230 protected override void GenerateNewExtremePointsForNewItem(RectangularPackingItem newItem, TwoDimensionalPacking position) { 231 232 int newWidth = position.Rotated ? newItem.Height : newItem.Width; 233 int newHeight = position.Rotated ? newItem.Width : newItem.Height; 234 235 //Find ExtremePoints beginning from sourcepointX 236 var sourcePointX = new TwoDimensionalPacking(0, position.X + newWidth, position.Y); 237 if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height) { 238 //Traversing down the y-axis 239 while (sourcePointX.Y > 0 && !OccupiedPoints.IsPointOccupied(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y - 1))) { 240 sourcePointX.Y--; 241 } 242 ExtremePoints.Add(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y)); 243 } 244 245 246 247 248 //Find ExtremePoints beginning from sourcepointY 249 var sourcePointY = new TwoDimensionalPacking(0, position.X, position.Y + newItem.Height); 250 if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height) { 251 //Traversing down the x-axis 252 while (sourcePointY.X > 0 && !OccupiedPoints.IsPointOccupied(new TwoDimensionalPacking (0,sourcePointY.X - 1, sourcePointY.Y))) { 253 sourcePointY.X--; 254 } 255 ExtremePoints.Add(new TwoDimensionalPacking(0, sourcePointY.X, sourcePointY.Y)); 256 } 257 258 ExtremePoints = new HashSet<TwoDimensionalPacking>(ExtremePoints. 259 OrderBy(ep => ep.AssignedBin). 260 ThenBy(ep => ep.X). 261 ThenBy(ep => ep.Y). 262 ThenBy(ep => OccupiedPoints.ShortestPossibleSideFromEP(ep))); 263 } 264 265 public override TwoDimensionalPacking FindExtremePointForItem(RectangularPackingItem measures, bool rotated, bool stackingConstraint) { 266 RectangularPackingItem item = new RectangularPackingItem( 267 rotated ? measures.Height : measures.Width, 268 rotated ? measures.Width : measures.Height, 269 measures.TargetBin); 270 271 int epIndex = 0; 272 while (epIndex < ExtremePoints.Count && (!IsPositionFeasible(item, ExtremePoints.ElementAt(epIndex)))) { epIndex++; } 273 274 if (epIndex < ExtremePoints.Count) { 275 var result = ExtremePoints.ElementAt(epIndex); 276 result.Rotated = rotated; 277 return result; 278 } 279 return null; 280 } 281 public override TwoDimensionalPacking FindPositionBySliding(RectangularPackingItem measures, bool rotated) { 282 TwoDimensionalPacking currentPosition = new TwoDimensionalPacking(0, 283 BinMeasures.Width - (rotated ? measures.Height : measures.Width), 284 BinMeasures.Height - (rotated ? measures.Width : measures.Height), rotated); 285 //Slide the item as far as possible to the left 286 while (IsPositionFeasible(measures, MoveLeft(currentPosition)) 287 || IsPositionFeasible(measures, MoveDown(currentPosition))) { 288 //Slide the item as far as possible to the bottom 289 while (IsPositionFeasible(measures, MoveDown(currentPosition))) { 290 currentPosition = MoveDown(currentPosition); 291 } 292 if (IsPositionFeasible(measures, MoveLeft(currentPosition))) 293 currentPosition = MoveLeft(currentPosition); 294 } 295 296 return IsPositionFeasible(measures, currentPosition) ? currentPosition : null; 297 } 298 private static TwoDimensionalPacking MoveLeft(TwoDimensionalPacking original) { 299 return new TwoDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Rotated); 300 } 301 private static TwoDimensionalPacking MoveDown(TwoDimensionalPacking original) { 302 return new TwoDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Rotated); 303 } 304 } 305 306 307 308 [Item("BinPacking3D", "Represents a single-bin packing for a 3D bin-packing problem.")] 309 [StorableClass] 310 public class BinPacking3D : BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> { 311 312 313 public BinPacking3D(CuboidPackingBin binMeasures) : base(binMeasures) { 314 OccupiedPoints = new OccupiedPoints3D(binMeasures); 315 } 316 [StorableConstructor] 317 protected BinPacking3D(bool deserializing) : base(deserializing) { } 318 protected BinPacking3D(BinPacking3D original, Cloner cloner) 319 : base(original, cloner) { 320 } 321 public override IDeepCloneable Clone(Cloner cloner) { 322 return new BinPacking3D(this, cloner); 323 } 324 325 protected override void GenerateNewExtremePointsForNewItem(CuboidPackingItem newItem, ThreeDimensionalPacking position) { 326 int newWidth = position.Rotated ? newItem.Depth : newItem.Width; 327 int newDepth = position.Rotated ? newItem.Width : newItem.Depth; 328 329 //Find ExtremePoints beginning from sourcepointX 330 var sourcePointX = new ThreeDimensionalPacking(0, position.X + newWidth, position.Y, position.Z); 331 if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height && sourcePointX.Z < BinMeasures.Depth) { 332 //Traversing down the y-axis 333 int currentYValue = sourcePointX.Y; 334 while (currentYValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointX.X, currentYValue, sourcePointX.Z))) { 335 currentYValue--; 336 } 337 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointX.X, currentYValue, sourcePointX.Z)); 338 339 //Traversing down the z-axis 340 int currentZValue = sourcePointX.Z; 341 while (currentZValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointX.X, sourcePointX.Y, currentZValue - 1))) { 342 currentZValue--; 343 } 344 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, currentZValue)); 345 } 346 347 348 349 350 //Find ExtremePoints beginning from sourcepointY 351 var sourcePointY = new ThreeDimensionalPacking(0, position.X, position.Y + newItem.Height, position.Z); 352 if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height && sourcePointY.Z < BinMeasures.Depth) { 353 //Traversing down the x-axis 354 int currentXValue = sourcePointY.X; 355 while (currentXValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, currentXValue - 1, sourcePointY.Y, sourcePointY.Z))) { 356 currentXValue--; 357 } 358 ExtremePoints.Add(new ThreeDimensionalPacking(0, currentXValue, sourcePointY.Y, sourcePointY.Z)); 359 360 //Traversing down the z-axis 361 int currentZValue = sourcePointY.Z; 362 while (currentZValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointY.X, sourcePointY.Y, currentZValue - 1))) { 363 currentZValue--; 364 } 365 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, currentZValue)); 366 } 367 368 369 370 371 372 //Find ExtremePoints beginning from sourcepointZ 373 var sourcePointZ = new ThreeDimensionalPacking(0, position.X, position.Y, position.Z + newDepth); 374 if (sourcePointZ.X < BinMeasures.Width && sourcePointZ.Y < BinMeasures.Height && sourcePointZ.Z < BinMeasures.Depth) { 375 //Traversing down the x-axis 376 int currentXValue = sourcePointZ.X; 377 while (currentXValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, currentXValue - 1, sourcePointZ.Y, sourcePointZ.Z))) { 378 currentXValue--; 379 } 380 ExtremePoints.Add(new ThreeDimensionalPacking(0, currentXValue, sourcePointZ.Y, sourcePointZ.Z)); 381 382 //Traversing down the y-axis 383 int currentYValue = sourcePointZ.Y; 384 while (currentYValue > 0 && !OccupiedPoints.IsPointOccupied(new ThreeDimensionalPacking (0, sourcePointZ.X, currentYValue, sourcePointZ.Z))) { 385 currentYValue--; 386 } 387 ExtremePoints.Add(new ThreeDimensionalPacking(0, sourcePointZ.X, currentYValue, sourcePointZ.Z)); 388 } 389 390 ExtremePoints = new HashSet<ThreeDimensionalPacking>(ExtremePoints. 391 OrderBy(ep => ep.AssignedBin). 392 ThenBy(ep => ep.Z). 393 ThenBy(ep => ep.X). 394 ThenBy(ep => ep.Y). 395 ThenBy(ep => OccupiedPoints.ShortestPossibleSideFromEP(ep))); 396 } 397 398 public override ThreeDimensionalPacking FindExtremePointForItem(CuboidPackingItem measures, bool rotated, bool stackingConstraint) { 399 400 CuboidPackingItem item = new CuboidPackingItem( 401 rotated ? measures.Depth : measures.Width, 402 measures.Height, 403 rotated ? measures.Width : measures.Depth, 404 measures.TargetBin); 405 406 int epIndex = 0; 407 while (epIndex < ExtremePoints.Count && ( 408 !IsPositionFeasible(item, ExtremePoints.ElementAt(epIndex)) || (stackingConstraint && !OccupiedPoints.IsStaticStable(item, ExtremePoints.ElementAt(epIndex))) 409 )) { epIndex++; } 410 411 if (epIndex < ExtremePoints.Count) { 412 var result = ExtremePoints.ElementAt(epIndex); 413 result.Rotated = rotated; 414 return result; 415 } 416 return null; 417 } 418 public override ThreeDimensionalPacking FindPositionBySliding(CuboidPackingItem measures, bool rotated) { 419 //Starting-position at upper right corner (=left bottom point of item-rectangle is at position item.width,item.height) 420 ThreeDimensionalPacking currentPosition = new ThreeDimensionalPacking(0, 421 BinMeasures.Width - (rotated ? measures.Depth : measures.Width), 422 BinMeasures.Height - measures.Height, 423 BinMeasures.Depth - (rotated ? measures.Width : measures.Depth), rotated); 424 //Slide the item as far as possible to the bottom 425 while (IsPositionFeasible(measures, MoveDown(currentPosition)) 426 || IsPositionFeasible(measures, MoveLeft(currentPosition)) 427 || IsPositionFeasible(measures, MoveBack(currentPosition))) { 428 //Slide the item as far as possible to the left 429 while (IsPositionFeasible(measures, MoveLeft(currentPosition)) 430 || IsPositionFeasible(measures, MoveBack(currentPosition))) { 431 //Slide the item as far as possible to the back 432 while (IsPositionFeasible(measures, MoveBack(currentPosition))) { 433 currentPosition = MoveBack(currentPosition); 434 } 435 if (IsPositionFeasible(measures, MoveLeft(currentPosition))) 436 currentPosition = MoveLeft(currentPosition); 437 } 438 if (IsPositionFeasible(measures, MoveDown(currentPosition))) 439 currentPosition = MoveDown(currentPosition); 440 } 441 442 return IsPositionFeasible(measures, currentPosition) ? currentPosition : null; 443 } 444 private static ThreeDimensionalPacking MoveLeft(ThreeDimensionalPacking original) { 445 return new ThreeDimensionalPacking(original.AssignedBin, original.X - 1, original.Y, original.Z, original.Rotated); 446 } 447 private static ThreeDimensionalPacking MoveDown(ThreeDimensionalPacking original) { 448 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y - 1, original.Z, original.Rotated); 449 } 450 private static ThreeDimensionalPacking MoveBack(ThreeDimensionalPacking original) { 451 return new ThreeDimensionalPacking(original.AssignedBin, original.X, original.Y, original.Z - 1, original.Rotated); 452 } 453 } 454 455 456 144 457 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/PackingSequenceOrderCrossover.cs
r9563 r9593 43 43 public override PackingSequenceEncoding Cross(IRandom random, PackingSequenceEncoding parent1, PackingSequenceEncoding parent2) { 44 44 PackingSequenceEncoding result = new PackingSequenceEncoding(); 45 result.PackingSequence = OrderCrossover 2.Apply(random, parent1.PackingSequence, parent2.PackingSequence);45 result.PackingSequence = OrderCrossover.Apply(random, parent1.PackingSequence, parent2.PackingSequence); 46 46 return result; 47 47 } -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/Abstract/BinUtilizationRegularIdenticalBinEvaluator.cs
r9563 r9593 90 90 91 91 for (int i = 0; i < nrOfBins; i++) { 92 double usableSpace = plan. GetPackingBinMeasuresForBinNr(i).MultipliedMeasures;93 var indexes = plan.PackingItemPositions.Select((Value, Index) => new { Value, Index }).Where(s => s.Value.Value.AssignedBin == i).Select(s => s.Index);94 var packedItemsInThisBin = plan.PackingItemMeasures.Select((Value, Index) => new { Value, Index }).Where(s => indexes.Contains(s.Index));95 double usedSpaceInThisBin = packedItemsInThisBin.Select(s => s.Value.MultipliedMeasures).Sum();92 double usableSpace = plan.BinPackings[i].BinMeasures.MultipliedMeasures; 93 //var indexes = plan.PackingItemPositions.Select((Value, Index) => new { Value, Index }).Where(s => s.Value.Value.AssignedBin == i).Select(s => s.Index); 94 //var packedItemsInThisBin = plan.PackingItemMeasures.Select((Value, Index) => new { Value, Index }).Where(s => indexes.Contains(s.Index)); 95 //double usedSpaceInThisBin = packedItemsInThisBin.Select(s => s.Value.MultipliedMeasures).Sum(); 96 96 //result += (usedSpaceInThisBin / usableSpace); 97 97 totalUsableSpace += usableSpace; 98 totalUsedSpace += usedSpaceInThisBin; 98 //totalUsedSpace += usedSpaceInThisBin; 99 totalUsedSpace += plan.BinPackings[i].PackingDensity * usableSpace; 99 100 } 100 101 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Evaluators/Abstract/PackingRatioRegularIdenticalBinEvaluator.cs
r9563 r9593 89 89 for (int i = 0; i < nrOfBins; i++) { 90 90 //C 91 double usableSpace = plan.GetPackingBinMeasuresForBinNr(0).MultipliedMeasures;//plan.GetPackingBinMeasuresForBinNr(i).MultipliedMeasures;92 var indexes = plan.PackingItemPositions.Select((Value, Index) => new { Value, Index }).Where(s => s.Value.Value.AssignedBin == i).Select(s => s.Index);93 var packedItemsInThisBin = plan.PackingItemMeasures.Select((Value, Index) => new { Value, Index }).Where(s => indexes.Contains(s.Index));91 //double usableSpace = plan.GetPackingBinMeasuresForBinNr(0).MultipliedMeasures;//plan.GetPackingBinMeasuresForBinNr(i).MultipliedMeasures; 92 //var indexes = plan.PackingItemPositions.Select((Value, Index) => new { Value, Index }).Where(s => s.Value.Value.AssignedBin == i).Select(s => s.Index); 93 //var packedItemsInThisBin = plan.PackingItemMeasures.Select((Value, Index) => new { Value, Index }).Where(s => indexes.Contains(s.Index)); 94 94 //Fi 95 double usedSpaceInThisBin = packedItemsInThisBin.Select(s => s.Value.MultipliedMeasures).Sum();95 //double usedSpaceInThisBin = packedItemsInThisBin.Select(s => s.Value.MultipliedMeasures).Sum(); 96 96 //k = 2 --> (Fi/C)*(Fi/C) 97 result += (((usedSpaceInThisBin) / (usableSpace)) * ((usedSpaceInThisBin) / (usableSpace))) / (i*i + 1); 97 //result += (((usedSpaceInThisBin) / (usableSpace)) * ((usedSpaceInThisBin) / (usableSpace))) / (i*i + 1); 98 var PD = plan.BinPackings[i].PackingDensity; 99 result += (PD * PD) / (i + 1); 98 100 } 99 101 -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj
r9563 r9593 166 166 <Compile Include="Analyzers\BinPackingAnalyzer.cs" /> 167 167 <Compile Include="Decoders\2D\BL\BottomLeftMultiComponentVectorDecoder.cs" /> 168 <Compile Include="Decoders\2D\ BL\BottomLeftFunctions.cs" />168 <Compile Include="Decoders\2D\TwoDimensionalPackingFunctions.cs" /> 169 169 <Compile Include="Decoders\2D\EP\ExtremePointGroupingVectorDecoder2D.cs" /> 170 170 <Compile Include="Decoders\2D\EP\ExtremePointMultiComponentVectorDecoder2D.cs" /> 171 171 <Compile Include="Decoders\2D\EP\ExtremePointPackingSequenceDecoder2D.cs" /> 172 <Compile Include="Decoders\ 2D\EP\ExtremePointsFunctions2D.cs" />172 <Compile Include="Decoders\3D\ThreeDimensionalPackingFunctions.cs" /> 173 173 <Compile Include="Decoders\3D\EP\ExtremePointMultiComponentVectorDecoder3D.cs" /> 174 174 <Compile Include="Decoders\3D\EP\ExtremePointGroupingVectorDecoder3D.cs" /> 175 175 <Compile Include="Decoders\3D\EP\ExtremePointPackingSequenceDecoder3D.cs" /> 176 176 <Compile Include="Decoders\3D\DBL\DeepestBottomLeftMultiComponentVectorDecoder.cs" /> 177 <Compile Include="Decoders\3D\DBL\DeepestBottomLeftFunctions.cs" />178 <Compile Include="Decoders\3D\EP\ExtremePointsFunctions3D.cs" />179 177 <Compile Include="Decoders\3D\DBL\DeepestBottomLeftGroupingVectorDecoder.cs" /> 180 178 <Compile Include="Decoders\2D\BL\BottomLeftGroupingVectorDecoder.cs" /> … … 182 180 <Compile Include="Decoders\2D\BL\BottomLeftPackingSequenceDecoder.cs" /> 183 181 <Compile Include="Decoders\3D\EP\ISOContainerMultiComponentVectorDecoder3D.cs" /> 182 <Compile Include="Decoders\SequentialPackingFunctions.cs"> 183 <SubType>Code</SubType> 184 </Compile> 184 185 <Compile Include="Decoders\PackingSolutionDecoder.cs" /> 186 <Compile Include="Dimensions\OccupiedPoints3D.cs" /> 187 <Compile Include="Dimensions\OccupiedPoints2D.cs" /> 188 <Compile Include="Dimensions\OccupiedPoints.cs" /> 185 189 <Compile Include="Encodings\GroupingVector\GroupingVectorSwap2Manipulator.cs" /> 186 190 <Compile Include="Encodings\GroupingVector\GroupingVectorSinglePointCrossover.cs" /> … … 243 247 <Compile Include="Encodings\PackingSequence\Moves\Insertion\InsertionMoveAttribute.cs" /> 244 248 <Compile Include="Encodings\PackingSequence\Moves\Insertion\InsertionMoveGenerator.cs" /> 245 <Compile Include="Encodings\PackingSequence\PackingSequenceInsertionManipulator.cs" /> 246 <Compile Include="Encodings\PackingSequence\PackingSequenceSwap2Manipulator.cs" /> 249 <Compile Include="Encodings\PackingSequence\PackingSequenceInversionManipulator.cs" /> 247 250 <Compile Include="Encodings\PackingSequence\PackingSequencePartiallyMatchedCrossover.cs" /> 248 251 <Compile Include="Encodings\PackingSequence\PackingSequenceOrderCrossover.cs" /> … … 268 271 </Compile> 269 272 <Compile Include="Encodings\PackingSequence\PackingSequenceRandomCreator.cs" /> 273 <Compile Include="Encodings\PackingSequence\PackingSequenceScrambleManipulator.cs" /> 270 274 <Compile Include="Encodings\PackingSolutionCreator.cs" /> 271 275 <Compile Include="Encodings\PackingSolutionCrossover.cs" /> -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Plugin.cs
r9563 r9593 26 26 /// Plugin class for HeuristicLab.Problems.BinPacking plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.9 495")]28 [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.9563")] 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
r9563 r9593 53 53 54 54 #region Helpers 55 public int MultipliedMeasures { get { return Width * Height * Depth; } } 55 public override ThreeDimensionalPacking Origin { get { return new ThreeDimensionalPacking(0, 0, 0, 0); } } 56 public override int MultipliedMeasures { get { return Width * Height * Depth; } } 56 57 57 58 public override bool Encloses(ThreeDimensionalPacking checkedPosition, PackingShape<ThreeDimensionalPacking> checkedShape) { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/PackingShape.cs
r9348 r9593 43 43 public abstract void InitializeFromMeasures(int[] measures); 44 44 public abstract int[] ToArray(); 45 public abstract int MultipliedMeasures { get; } 46 public abstract D Origin { get; } 45 47 46 48 public PackingShape(int[] measures) { -
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/RectangularPackingShape.cs
r9440 r9593 48 48 49 49 #region Helpers 50 public int MultipliedMeasures { get { return Height * Width; } } 50 public override TwoDimensionalPacking Origin { get { return new TwoDimensionalPacking(0, 0, 0); } } 51 public override int MultipliedMeasures { get { return Height * Width; } } 51 52 52 53 public override bool Encloses(TwoDimensionalPacking checkedPosition, PackingShape<TwoDimensionalPacking> checkedShape) {
Note: See TracChangeset
for help on using the changeset viewer.